public class MWNumericArray extends MWArray
MWNumericArray
class is the base class for all numeric MATLAB array types.EMPTY_ARRAY
Constructor and Description |
---|
MWNumericArray()
Creates an empty
MWNumericArray of type MWClassID.DOUBLE . |
MWNumericArray(boolean rVal,
boolean iVal,
MWClassID classid)
Constructs a complex numeric double array that represents the primitive boolean arguments.
|
MWNumericArray(boolean rVal,
MWClassID classid)
Constructs a real scalar numeric array that represents the primitive boolean argument.
|
MWNumericArray(byte rVal)
Constructs a real scalar numeric array of type
MWClassID.INT8 that represents the primitive byte argument. |
MWNumericArray(byte rVal,
byte iVal)
Constructs a complex scalar numeric array of type
MWClassID.INT8 that represents the primitive byte arguments. |
MWNumericArray(byte rVal,
byte iVal,
MWClassID classid)
Constructs a complex scalar numeric array that represents the primitive byte arguments.
|
MWNumericArray(byte rVal,
MWClassID classid)
Constructs a real scalar numeric array that represents the primitive byte argument.
|
MWNumericArray(double rVal)
Constructs a real scalar array of type
MWClassID.DOUBLE that represents the primitive double argument. |
MWNumericArray(double rVal,
double iVal)
Constructs a complex scalar array of type
MWClassID.DOUBLE that represents the primitive double arguments. |
MWNumericArray(double rVal,
double iVal,
MWClassID classid)
Constructs a complex scalar array that represents the primitive double arguments.
|
MWNumericArray(double rVal,
MWClassID classid)
Constructs a real scalar array that represents the primitive double argument.
|
MWNumericArray(float rVal)
Constructs a real scalar numeric array of type
MWClassID.SINGLE that represents the primitive float argument. |
MWNumericArray(float rVal,
float iVal)
Constructs a complex scalar numeric array of type
MWClassID.SINGLE that represents the primitive float arguments. |
MWNumericArray(float rVal,
float iVal,
MWClassID classid)
Constructs a complex scalar numeric array that represents the primitive float arguments.
|
MWNumericArray(float rVal,
MWClassID classid)
Constructs a real scalar numeric array that represents the primitive float argument.
|
MWNumericArray(int rVal)
Constructs a real scalar numeric array of type
MWClassID.INT32 that represents the primitive int argument. |
MWNumericArray(int rVal,
int iVal)
Constructs a complex scalar numeric array of type
MWClassID.INT32 that represents the primitive int arguments. |
MWNumericArray(int rVal,
int iVal,
MWClassID classid)
Constructs a complex scalar numeric array that represents the primitive int arguments.
|
MWNumericArray(int rVal,
MWClassID classid)
Constructs a real scalar numeric array that represents the primitive int argument.
|
MWNumericArray(long rVal)
Constructs a real scalar numeric array of type
MWClassID.INT64 that represents the primitive long argument. |
MWNumericArray(long rVal,
long iVal)
Constructs a complex numeric double array of type
MWClassID.INT64 that represents the primitive long arguments. |
MWNumericArray(long rVal,
long iVal,
MWClassID classid)
Constructs a complex numeric double array that represents the primitive long arguments.
|
MWNumericArray(MWClassID classid)
Creates an empty
MWNumericArray of the specified type. |
MWNumericArray(java.lang.Object rVal)
Constructs a real numeric array that represents the Object argument using default conversion
rules.
|
MWNumericArray(java.lang.Object rVal,
MWClassID classid)
Constructs a real numeric array that represents the Object argument.
|
MWNumericArray(java.lang.Object rVal,
java.lang.Object iVal)
Constructs a complex numeric array that represents the Object arguments using default conversion
rules.
|
MWNumericArray(java.lang.Object rVal,
java.lang.Object iVal,
MWClassID classid)
Constructs a complex numeric array that represents the Object arguments.
|
MWNumericArray(short rVal)
Constructs a real scalar numeric array of type
MWClassID.INT16 that represents the primitive short argument. |
MWNumericArray(short rVal,
MWClassID classid)
Constructs a real scalar numeric array that represents the primitive short argument.
|
MWNumericArray(short rVal,
short iVal)
Constructs a complex scalar numeric array of type
MWClassID.INT16 that represents the primitive short arguments. |
MWNumericArray(short rVal,
short iVal,
MWClassID classid)
Constructs a complex scalar numeric array that represents the primitive short arguments.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
applyVisitor(AbstractMWArrayVisitor<T> v) |
MWClassID |
classID()
Returns the MATLAB type of this array.
|
java.lang.Object |
clone()
Creates and returns a deep copy of this array.
|
int[] |
columnIndex()
Returns an array containing the column index of each element in the underlying MATLAB array.
|
int |
compareTo(java.lang.Object obj)
Compares this array with the specified array for order.
|
MWComplexity |
complexity()
Returns the complexity of this array.
|
static MWArray |
deserialize(byte[] data)
Create a new MWArray from serialized data.
|
void |
dispose()
Frees the native MATLAB array contained by this array.
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other array is equal to this one.
|
java.lang.Object |
get(int index)
Returns the element at the specified 1-based offset in this array.
|
java.lang.Object |
get(int[] index)
Returns the element at the specified 1-based index-array in this array.
|
byte |
getByte()
Return this array as a scalar byte.
|
byte |
getByte(int index)
Returns the real part at the specified 1-based offset as a byte value.
|
byte |
getByte(int[] index)
Returns the real part at the specified 1-based index-array as a byte value.
|
byte[] |
getByteData()
This method returns a one-dimensional array
of Java types matching the primitive type
byte . |
java.lang.Object |
getData()
Returns a 1-D array containing a copy of the data in the underlying MATLAB array.
|
int[] |
getDimensions()
Returns an array containing the size of each dimension of this array.
|
double |
getDouble()
Return this array as a scalar double.
|
double |
getDouble(int index)
Returns the real part at the specified 1-based offset as a double value.
|
double |
getDouble(int[] index)
Returns the real part at the specified 1-based index-array as a double value.
|
double[] |
getDoubleData()
This method returns a one-dimensional array
of Java types matching the primitive type
double . |
static double |
getEps()
Returns MATLAB's concept of eps.
|
float |
getFloat()
Return this array as a scalar float.
|
float |
getFloat(int index)
Returns the real part at the specified 1-based offset as a float value.
|
float |
getFloat(int[] index)
Returns the real part at the specified 1-based index-array as a float value.
|
float[] |
getFloatData()
This method returns a one-dimensional array
of Java types matching the primitive type
float . |
java.lang.Object |
getImag(int index)
Returns the imaginary part at the specified 1-based offset in this array.
|
java.lang.Object |
getImag(int[] index)
Returns the imaginary part at the specified 1-based index-array in this array.
|
byte |
getImagByte()
Return imaginary component of this array as a scalar byte.
|
byte |
getImagByte(int index)
Returns the imaginary part at the specified 1-based offset as a byte value.
|
byte |
getImagByte(int[] index)
Returns the imaginary part at the specified 1-based index-array as a byte value.
|
byte[] |
getImagByteData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
byte . |
java.lang.Object |
getImagData()
Returns a 1-D array containing a copy of the imaginary data in the underlying MATLAB array.
|
double |
getImagDouble()
Return imaginary component of this array as a scalar double.
|
double |
getImagDouble(int index)
Returns the imaginary part at the specified 1-based offset as a double value.
|
double |
getImagDouble(int[] index)
Returns the imaginary part at the specified 1-based index-array as a double value.
|
double[] |
getImagDoubleData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
double . |
float |
getImagFloat()
Return imaginary component of this array as a scalar float.
|
float |
getImagFloat(int index)
Returns the imaginary part at the specified 1-based offset as a float value.
|
float |
getImagFloat(int[] index)
Returns the imaginary part at the specified 1-based index-array as a float value.
|
float[] |
getImagFloatData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
float . |
int |
getImagInt()
Return imaginary component of this array as a scalar int.
|
int |
getImagInt(int index)
Returns the imaginary part at the specified 1-based offset as an int value.
|
int |
getImagInt(int[] index)
Returns the imaginary part at the specified 1-based index-array as an int value.
|
int[] |
getImagIntData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
int . |
long |
getImagLong()
Return imaginary component of this array as a scalar long.
|
long |
getImagLong(int index)
Returns the imaginary part at the specified 1-based offset as a long value.
|
long |
getImagLong(int[] index)
Returns the imaginary part at the specified 1-based index-array as a long value.
|
long[] |
getImagLongData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
long . |
short |
getImagShort()
Return imaginary component of this array as a scalar short.
|
short |
getImagShort(int index)
Returns the imaginary part at the specified 1-based offset as a short value.
|
short |
getImagShort(int[] index)
Returns the imaginary part at the specified 1-based index-array as a short value.
|
short[] |
getImagShortData()
This method returns a one-dimensional array of imaginary elements
of the Java primitive type
short . |
static double |
getInf()
Returns MATLAB's concept of Inf.
|
int |
getInt()
Return this array as a scalar int.
|
int |
getInt(int index)
Returns the real part at the specified 1-based offset as an int value.
|
int |
getInt(int[] index)
Returns the real part at the specified 1-based index-array as an int value.
|
int[] |
getIntData()
This method returns a one-dimensional array
of Java types matching the primitive type
int . |
long |
getLong()
Return this array as a scalar long.
|
long |
getLong(int index)
Returns the real part at the specified 1-based offset as a long value.
|
long |
getLong(int[] index)
Returns the real part at the specified 1-based index-array as a long value.
|
long[] |
getLongData()
This method returns a one-dimensional array
of Java types matching the primitive type
long . |
static double |
getNaN()
Returns MATLAB's concept of NaN.
|
short |
getShort()
Return this array as a scalar short.
|
short |
getShort(int index)
Returns the real part at the specified 1-based offset as a short value.
|
short |
getShort(int[] index)
Returns the real part at the specified 1-based index-array as a short value.
|
short[] |
getShortData()
This method returns a one-dimensional array
of Java types matching the primitive type
short . |
int |
hashCode()
Returns a hash code value for this array.
|
boolean |
isEmpty()
Tests if this array has no elements.
|
static boolean |
isFinite(double x)
Test for finiteness in a machine-independent manner.
|
static boolean |
isInf(double x)
Test for infinity in a machine-independent manner.
|
static boolean |
isNaN(double x)
Test for NaN in a machine-independent manner.
|
boolean |
isSparse()
Tests if this array is sparse.
|
int |
maximumNonZeros()
Returns the allocated capacity of a sparse array.
|
static MWNumericArray |
newInstance(int[] dims,
MWClassID classid,
MWComplexity cmplx)
Constructs a numeric array with the specified dimensions and complexity.
|
static MWNumericArray |
newInstance(int[] dims,
java.lang.Object rData,
MWClassID classid)
Constructs a real numeric array with the specified dimensions and initializes the array with the supplied data.
|
static MWNumericArray |
newInstance(int[] dims,
java.lang.Object rData,
java.lang.Object iData,
MWClassID classid)
Constructs a complex numeric array with the specified dimensions and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
int rows,
int cols,
int nzmax,
MWClassID classid)
Constructs a real sparse numeric matrix with the specified number of rows and columns,
maximum nonzero elements, and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
int rows,
int cols,
MWClassID classid)
Constructs a real sparse numeric matrix with the specified number of rows and columns,
and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
MWClassID classid)
Constructs a real sparse numeric matrix with the number of rows = max{rowindex(k)} and the number of columns = max{colindex(k)},
and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
java.lang.Object iData,
int rows,
int cols,
int nzmax,
MWClassID classid)
Constructs a complex sparse numeric matrix with the specified number of rows and columns,
maximum nonzero elements, and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
java.lang.Object iData,
int rows,
int cols,
MWClassID classid)
Constructs a complex sparse numeric matrix with the specified number of rows and columns,
and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int[] rowindex,
int[] colindex,
java.lang.Object rData,
java.lang.Object iData,
MWClassID classid)
Constructs a complex sparse numeric matrix with the number of rows = max{rowindex(k)} and the number of columns = max{colindex(k)},
and initializes the array with the supplied data.
|
static MWNumericArray |
newSparse(int rows,
int cols,
int nzmax,
MWClassID classid,
MWComplexity cmplx)
Constructs a sparse numeric matrix with no nonzero elements.
|
static MWNumericArray |
newSparse(java.lang.Object rArr,
MWClassID classid)
Constructs a real sparse numeric matrix from the supplied full matrix.
|
static MWNumericArray |
newSparse(java.lang.Object rArr,
java.lang.Object iArr,
MWClassID classid)
Constructs a complex sparse numeric matrix from the supplied full matrices.
|
int |
numberOfDimensions()
Returns the number of dimensions of this array.
|
int |
numberOfElements()
Returns the total number of elements in this array.
|
int |
numberOfNonZeros()
Returns the number of non-zero elements in a sparse array.
|
protected java.lang.Object |
readResolve()
Called by serialization mechanism when loading a new array from a byte stream.
|
int[] |
rowIndex()
Returns an array containing the row index of each element in the underlying MATLAB array.
|
byte[] |
serialize()
Serialize the MATLAB array to a byte array.
|
void |
set(int[] index,
byte element)
Replaces the real part at the specified 1-based index-array in this array with the specified byte value.
|
void |
set(int[] index,
double element)
Replaces the real part at the specified 1-based index-array in this array with the specified double value.
|
void |
set(int[] index,
float element)
Replaces the real part at the specified 1-based index-array in this array with the specified float value.
|
void |
set(int[] index,
int element)
Replaces the real part at the specified 1-based index-array in this array with the specified int value.
|
void |
set(int[] index,
long element)
Replaces the real part at the specified 1-based index-array in this array with the specified long value.
|
void |
set(int[] index,
java.lang.Object element)
Replaces the element at the specified 1-based index-array in this array with the specified element.
|
void |
set(int[] index,
short element)
Replaces the real part at the specified 1-based index-array in this array with the specified short value.
|
void |
set(int index,
byte element)
Replaces the real part at the specified 1-based offset in this array with the specified byte value.
|
void |
set(int index,
double element)
Replaces the real part at the specified 1-based offset in this array with the specified double value.
|
void |
set(int index,
float element)
Replaces the real part at the specified 1-based offset in this array with the specified float value.
|
void |
set(int index,
int element)
Replaces the real part at the specified 1-based offset in this array with the specified int value.
|
void |
set(int index,
long element)
Replaces the real part at the specified 1-based offset in this array with the specified long value.
|
void |
set(int index,
java.lang.Object element)
Replaces the element at the specified 1-based offset in this array with the specified element.
|
void |
set(int index,
short element)
Replaces the real part at the specified 1-based offset in this array with the specified short value.
|
void |
setData(java.lang.Object data) |
void |
setImag(int[] index,
byte element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified byte value.
|
void |
setImag(int[] index,
double element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified double value.
|
void |
setImag(int[] index,
float element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified float value.
|
void |
setImag(int[] index,
int element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified int value.
|
void |
setImag(int[] index,
long element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified long value.
|
void |
setImag(int[] index,
java.lang.Object element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified element.
|
void |
setImag(int[] index,
short element)
Replaces the imaginary part at the specified 1-based index-array in this array with the specified short value.
|
void |
setImag(int index,
byte element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified byte value.
|
void |
setImag(int index,
double element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified double value.
|
void |
setImag(int index,
float element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified float value.
|
void |
setImag(int index,
int element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified int value.
|
void |
setImag(int index,
long element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified long value.
|
void |
setImag(int index,
java.lang.Object element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified element.
|
void |
setImag(int index,
short element)
Replaces the imaginary part at the specified 1-based offset in this array with the specified short value.
|
void |
setImagData(java.lang.Object data)
Initializes imaginary component of MATLAB array data.
|
java.lang.Object |
sharedCopy()
Creates and returns a shared copy of this array.
|
java.lang.Object[] |
toArray()
Returns an array containing a copy of the data in the underlying MATLAB array.
|
java.lang.Object |
toByteArray()
Returns an array of elements of the Java primitive type
byte . |
java.lang.Object |
toDoubleArray()
Returns an array of elements of the Java primitive type
double . |
java.lang.Object |
toFloatArray()
Returns an array of elements of the Java primitive type
float . |
java.lang.Object |
toImagArray()
Returns an array containing a copy of the imaginary data in the underlying MATLAB array.
|
java.lang.Object |
toImagByteArray()
Returns an array of imaginary elements of the Java primitive type
byte . |
java.lang.Object |
toImagDoubleArray()
Returns an array of imaginary elements of the Java primitive type
double . |
java.lang.Object |
toImagFloatArray()
Returns an array of imaginary elements of the Java primitive type
float . |
java.lang.Object |
toImagIntArray()
Returns an array of imaginary elements of the Java primitive type
int . |
java.lang.Object |
toImagLongArray()
Returns an array of imaginary elements of the Java primitive type
long . |
java.lang.Object |
toImagShortArray()
Returns an array of imaginary elements of the Java primitive type
short . |
java.lang.Object |
toIntArray()
Returns an array of elements of the Java primitive type
int . |
java.lang.Object |
toLongArray()
Returns an array of elements of the Java primitive type
long . |
java.lang.Object |
toShortArray()
Returns an array of elements of the Java primitive type
short . |
java.lang.String |
toString()
Returns a string representation of this array.
|
protected void |
validate()
Validates the internal array handle.
|
disposeArray
public MWNumericArray()
MWNumericArray
of type MWClassID.DOUBLE
.public MWNumericArray(MWClassID classid)
MWNumericArray
of the specified type.
Alternatively, you can use the newInstance or
newSparse methods, which offer better performance.
Example: Constructing an Empty Numeric Array Object
Create an empty scalar of type int64:MWNumericArray A = new MWNumericArray(MWClassID.INT64); System.out.println("A = " + A);When run, the example displays this output:
A = []
classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(double rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.
Example: Constructing an Integer Array Object
Construct a scalar numeric array of type MWClassID.INT16:double AReal = 24; MWNumericArray A = new MWNumericArray(AReal, MWClassID.INT16); System.out.println("Array A of type " + A.classID() + " = \n" + A);When run, the example displays this output:
Array A of type int16 = 24
public MWNumericArray(double rVal)
MWClassID.DOUBLE
that represents the primitive double argument.rVal
- The value with which to initialize the array.
Example: Constructing a Double Array Object
Construct a scalar numeric array of type MWClassID.DOUBLE:double AData = 12; MWNumericArray A = new MWNumericArray(AData, MWClassID.DOUBLE); System.out.println("Array A = \n" + A);When run, the example displays this output:
Array A = 12
public MWNumericArray(double rVal, double iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the fo`llowing types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.
public MWNumericArray(double rVal, double iVal)
MWClassID.DOUBLE
that represents the primitive double arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.
Example: Constructing a Complex Scalar Object
Construct a numeric scalar having real and imaginary parts:double AReal = 24; double AImag = 5; MWNumericArray A = new MWNumericArray(AReal, AImag); System.out.println("Array A of type " + A.classID() + " = \n" + A);When run, the example displays this output:
Array A of type double = 24.0000 + 5.0000i
public MWNumericArray(float rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(float rVal)
MWClassID.SINGLE
that represents the primitive float argument.rVal
- The value with which to initialize the array.public MWNumericArray(float rVal, float iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(float rVal, float iVal)
MWClassID.SINGLE
that represents the primitive float arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.public MWNumericArray(byte rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(byte rVal)
MWClassID.INT8
that represents the primitive byte argument.rVal
- The value with which to initialize the array.public MWNumericArray(byte rVal, byte iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(byte rVal, byte iVal)
MWClassID.INT8
that represents the primitive byte arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.public MWNumericArray(int rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(int rVal)
MWClassID.INT32
that represents the primitive int argument.rVal
- The value with which to initialize the array.public MWNumericArray(int rVal, int iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(int rVal, int iVal)
MWClassID.INT32
that represents the primitive int arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.public MWNumericArray(short rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(short rVal)
MWClassID.INT16
that represents the primitive short argument.rVal
- The value with which to initialize the array.public MWNumericArray(short rVal, short iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(short rVal, short iVal)
MWClassID.INT16
that represents the primitive short arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.public MWNumericArray(long rVal)
MWClassID.INT64
that represents the primitive long argument.rVal
- The value with which to initialize the array.public MWNumericArray(long rVal, long iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(long rVal, long iVal)
MWClassID.INT64
that represents the primitive long arguments.rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.public MWNumericArray(boolean rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(boolean rVal, boolean iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.public MWNumericArray(java.lang.Object rVal, MWClassID classid)
rVal
- The value with which to initialize the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.
Example: Constructing a Real Array of a Specific Type
Construct a 3-by-6 real array of type MWClassID.SINGLE:double[][] AData = {{ 1, 2, 3, 4, 5, 6}, { 7, 8 , 9, 10, 11, 12}, {13, 14, 15, 16, 17, 18}}; MWNumericArray A = new MWNumericArray(AData, MWClassID.SINGLE); System.out.println("Array A = \n" + A);When run, the example displays this output:
A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public MWNumericArray(java.lang.Object rVal, java.lang.Object iVal, MWClassID classid)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.java.lang.ArrayStoreException
- A non-numeric array type was specified.
Example: Constructing a Complex Array of a Specific Type
Construct a 1-by-3 complex array of MWClassID.DOUBLE:double[] AReal = {24.2, -7, 113}; double[] AImag = {5, 31, 27}; MWNumericArray A = new MWNumericArray(AReal, AImag, MWClassID.DOUBLE); System.out.println("Array A of type " + A.classID() + " = \n" + A);When run, the example displays this output:
Array A of type double = 1.0e+002 * 0.2420 + 0.0500i -0.0700 + 0.3100i 1.1300 + 0.2700i
public MWNumericArray(java.lang.Object rVal)
rVal
- The value with which to initialize the array.java.lang.ArrayStoreException
- An invalid input array was specified.public MWNumericArray(java.lang.Object rVal, java.lang.Object iVal)
rVal
- The value with which to initialize the real part of the array.iVal
- The value with which to initialize the imaginary part of the array.java.lang.ArrayStoreException
- An invalid input array was specified.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
MWNumericArray
instance representing a deep copy of the
underlying MATLAB array.
Example: Cloning a Numeric Array Object
Create a 3-by-6 array of type double:double[][] AData = {{ 1, 2, 3, 4, 5, 6}, { 7, 8 , 9, 10, 11, 12}, {13, 14, 15, 16, 17, 18}}; MWNumericArray A = new MWNumericArray(AData, MWClassID.DOUBLE);Create a clone of the MWNumericArray object A:
Object C = A.clone(); System.out.println("Clone of matrix A is:"); System.out.println(C.toString());When run, the example displays this output:
Clone of matrix A is: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
java.lang.CloneNotSupportedException
- - The object's class does not implement the Cloneable interface.public java.lang.Object sharedCopy()
MWNumericArray
instance representing a shared copy of the
underlying MATLAB array.
Example: Making a Shared Copy of a Numeric Array Object
Create a shared copy of MWArray object A:Object S = A.sharedCopy(); System.out.println("Shared copy of matrix A is:"); System.out.println(S.toString());When run, the example displays this output:
Shared copy of matrix A is: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
public MWComplexity complexity()
MWComplexity.REAL
for a real array. Returns MWComplexity.COMPLEX
for a complex array.
Example: Testing for a Complex Array
Determine whether matrix A is real or complex:double AReal = 24; double AImag = 5; MWNumericArray A = new MWNumericArray(AReal, AImag); System.out.println("A is a " + A.complexity() + " matrix");When run, the example displays this output:
A is a complex matrix
public void set(int index, double element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, float element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, byte element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, int element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, short element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, long element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, double element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, float element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, byte element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, int element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, short element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int[] index, long element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, java.lang.Object element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New element to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, double element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, float element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, byte element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, int element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, short element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int index, long element)
index
- The index of the element to replace. Valid range: 1 <= index <= N, where N = total number of elements in the array.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, java.lang.Object element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New element to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, double element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, float element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, byte element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, int element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, short element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void setImag(int[] index, long element)
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New value to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public double getDouble()
public double getDouble(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public double getDouble(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public double getImagDouble()
public double getImagDouble(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.
Example: Getting Complex Data of a Specific Type
Start by creating a two-dimensional array of complex values:double[][] Rdata = {{ 2, 3, 4}, { 8 , 9, 10}, {14, 15, 16}}; double[][] Idata = {{ 6, 5, 14}, { 7 , 1, 23}, { 1, 1, 9}}; MWNumericArray A = new MWNumericArray(Rdata, Idata, MWClassID.DOUBLE); System.out.println("Complex matrix A ="); System.out.println(A.toString());Here is the complex array that is displayed:
2.0000 + 6.0000i 3.0000 + 5.0000i 4.0000 + 14.0000i 8.0000 + 7.0000i 9.0000 + 1.0000i 10.0000 + 23.0000i 14.0000 + 1.0000i 15.0000 + 1.0000i 16.0000 + 9.0000iGet the real and imaginary parts of one element of the MWNumericArray:
int[] index = {2, 3}; System.out.println("The real part of A(2,3) = " + A.getDouble(index)); System.out.println("The imaginary part of A(2,3) = " + A.getImagDouble(index));When run, the example displays this output:
The real part of A(2,3) = 10.0 The imaginary part of A(2,3) = 23.0
public double getImagDouble(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public float getFloat()
public float getFloat(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public float getFloat(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public float getImagFloat()
public float getImagFloat(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public float getImagFloat(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public byte getByte()
public byte getByte(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.
Example: Getting a Short Value from a Numeric Array
The following examples use this array:short[][] Adata = {{ 1, 2, 3, 4, 5, 6}, { 7, 8 , 9, 10, 11, 12}, {13, 14, 15, 16, 17, 18}}; MWNumericArray A = new MWNumericArray(Adata, MWClassID.INT16); int[] index = {2, 4}; System.out.println("A(2,4) = " + A.getShort(index));When run, the example displays this output:
A(2,4) = 10
Example: Using get and set on a Numeric Array
Given the same MWNumericArray used in the previous example, get and then modify the value of element (2, 3):int[] idx = {2, 3}; System.out.println("A(2, 3) is " + A.get(idx).toString()); System.out.println(""); System.out.println("Setting A(2, 3) to a new value ..."); A.set(idx, 555); System.out.println(""); System.out.println("A(2, 3) is now " + A.get(idx).toString());When run, the example displays this output:
A(2, 3) is 9.0 Setting A(2, 3) to a new value ... A(2, 3) is now 555.0
public byte getByte(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public byte getImagByte()
public byte getImagByte(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public byte getImagByte(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public int getInt()
public int getInt(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public int getInt(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public int getImagInt()
public int getImagInt(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public int getImagInt(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public short getShort()
public short getShort(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public short getShort(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public short getImagShort()
public short getImagShort(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public short getImagShort(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public long getLong()
public long getLong(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public long getLong(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public long getImagLong()
public long getImagLong(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public long getImagLong(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public java.lang.Object getImag(int index)
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.
Example: Getting the Real and Imaginary Parts of an Array
Start by creating a two-dimensional array of complex values:double[][] Rdata = {{ 2, 3, 4}, { 8 , 9, 10}, {14, 15, 16}}; double[][] Idata = {{ 6, 5, 14}, { 7 , 1, 23}, { 1, 1, 9}}; MWNumericArray A = new MWNumericArray(Rdata, Idata, MWClassID.DOUBLE); System.out.println("Complex matrix A ="); System.out.println(A.toString());Here is the complex array that is displayed:
2.0000 + 6.0000i 3.0000 + 5.0000i 4.0000 + 14.0000i 8.0000 + 7.0000i 9.0000 + 1.0000i 10.0000 + 23.0000i 14.0000 + 1.0000i 15.0000 + 1.0000i 16.0000 + 9.0000iNow, use get and getImag to read the real and imaginary parts of the element at index (2, 3):
int[] index = {2, 3}; System.out.println("The real part of A(2,3) = " + A.get(index)); System.out.println("The imaginary part of A(2,3) = " + A.getImag(index));When run, the example displays this output:
The real part of A(2,3) = 10.0 The imaginary part of A(2,3) = 23.0
public java.lang.Object getImag(int[] index)
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element i of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public java.lang.Object toByteArray()
byte
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toByteArray, an array of
type byte is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.byte
public java.lang.Object toDoubleArray()
double
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toDoubleArray, an array of
type double is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.double
public java.lang.Object toFloatArray()
float
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toFloatArray, an array of
type float is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
Example: Using toTypeArray Methods
This example demonstrates how you can coerce or force data to a specified numeric type by invoking any of the toTypeArray methods.Object results = null; try { // call a compiled m-function results = myobject.myfunction(2); // first output is known to be a numeric matrix MWNumericArray resultA = (MWNumericArray) results[0]; double[][] a = resultA.toDoubleArray(); // second output is known to be a 3-dimensional numeric array MWNumericArray resultB = (MWNumericArray) results[1]; int[][][] b = resultB.toIntArray(); } finally { MWNumericArray.disposeArray(results); }
float
public java.lang.Object toIntArray()
int
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toIntArray, an array of
type int is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.int
public java.lang.Object toLongArray()
long
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toLongArray, an array of
type long is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.long
public java.lang.Object toShortArray()
short
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toShortArray, an array of
type short is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.short
public java.lang.Object toImagByteArray()
byte
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagByteArray, an array of
type byte is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.byte
public java.lang.Object toImagDoubleArray()
double
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagDoubleArray, an array of
type double is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.double
public java.lang.Object toImagFloatArray()
float
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagFloatArray, an array of
type float is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.float
public java.lang.Object toImagIntArray()
int
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagIntArray, an array of
type int is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.int
public java.lang.Object toImagLongArray()
long
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagLongArray, an array of
type long is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.long
public java.lang.Object toImagShortArray()
short
.
The returned array is of the same
dimension as the underlying MATLAB array.
For example, if you call toImagShortArray, an array of
type short is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary, and the
array's original dimensions are preserved upon
return.
If conversion is performed, truncation or other
loss of precision may occur.
See example in toDoubleArray.short
public java.lang.Object toImagArray()
Example: Getting Complex Data with toImagArray
Start by creating a two-dimensional array of complex values:double[][] Rdata = {{ 2, 3, 4}, { 8 , 9, 10}, {14, 15, 16}}; double[][] Idata = {{ 6, 5, 14}, { 7 , 1, 23}, { 1, 1, 9}}; MWNumericArray A = new MWNumericArray(Rdata, Idata, MWClassID.DOUBLE); System.out.println("Complex matrix A ="); System.out.println(A.toString());Here is the complex array that is displayed:
2.0000 + 6.0000i 3.0000 + 5.0000i 4.0000 + 14.0000i 8.0000 + 7.0000i 9.0000 + 1.0000i 10.0000 + 23.0000i 14.0000 + 1.0000i 15.0000 + 1.0000i 16.0000 + 9.0000iGet and display a copy of the imaginary part of this array:
double[][] x = (double[][]) A.toImagArray(); int[] dimA = A.getDimensions(); System.out.println("The imaginary part of matrix A is:"); for (int i = 0; i < dimA[0]; i++) { for (int j = 0; j < dimA[1]; j++) { System.out.print(" " + x[i][j]); } System.out.println(); }When run, the example displays this output:
The imaginary part of matrix A is: 6.0 5.0 14.0 7.0 1.0 23.0 1.0 1.0 9.0
public byte[] getByteData()
byte
.
For example, if you call getByteData, an array of
type byte is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.byte
public double[] getDoubleData()
double
.
For example, if you call getDoubleData, an array of
type double is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.double
public float[] getFloatData()
float
.
For example, if you call getFloatData, an array of
type float is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.float
public int[] getIntData()
int
.
For example, if you call getIntData, an array of
type int is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.int
public long[] getLongData()
long
.
For example, if you call getLongData, an array of
type long is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.long
public short[] getShortData()
short
.
For example, if you call getShortData, an array of
type short is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.short
public byte[] getImagByteData()
byte
.
For example, if you call getImagByteData, an array of
type byte is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.byte
public double[] getImagDoubleData()
double
.
For example, if you call getImagDoubleData, an array of
type double is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.double
public float[] getImagFloatData()
float
.
For example, if you call getImagFloatData, an array of
type float is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.float
public int[] getImagIntData()
int
.
For example, if you call getImagIntData, an array of
type int is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.int
public long[] getImagLongData()
long
.
For example, if you call getImagLongData, an array of
type long is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.long
public short[] getImagShortData()
short
.
For example, if you call getImagShortData, an array of
type short is returned regardless of the data type
in the underlying array. The data is converted
from another primitive type, if necessary.
If conversion is performed, truncation or
other loss of precision may occur.short
public java.lang.Object getImagData()
Example: Getting Data from a Complex Array
Start by creating a two-dimensional array of complex values:double[][] Rdata = {{ 2, 3, 4}, { 8 , 9, 10}, {14, 15, 16}}; double[][] Idata = {{ 6, 5, 14}, { 7 , 1, 23}, { 1, 1, 9}}; MWNumericArray A = new MWNumericArray(Rdata, Idata, MWClassID.DOUBLE); System.out.println("Complex matrix A ="); System.out.println(A.toString());Here is the complex array that is displayed:
2.0000 + 6.0000i 3.0000 + 5.0000i 4.0000 + 14.0000i 8.0000 + 7.0000i 9.0000 + 1.0000i 10.0000 + 23.0000i 14.0000 + 1.0000i 15.0000 + 1.0000i 16.0000 + 9.0000iGet the entire contents of the complex array:
int[] index = {2, 3}; double[] x; System.out.println("The real data in matrix A is:"); x = (double[]) A.getData(); for (int i = 0; i < x.length; i++) System.out.print(" " + x[i]); System.out.println(); System.out.println(); System.out.println("The imaginary data in matrix A is:"); x = (double[]) A.getImagData(); for (int i = 0; i < x.length; i++) System.out.print(" " + x[i]); System.out.println();When run, the example displays this output:
The real data in matrix A is: 2.0 8.0 14.0 3.0 9.0 15.0 4.0 10.0 16.0 The imaginary data in matrix A is: 6.0 7.0 1.0 5.0 1.0 1.0 14.0 23.0 9.0
public void setImagData(java.lang.Object data)
data
- a single dimensional array containing all element values in row-major order.java.lang.ArrayStoreException
- Thrown if data type is non-numeric.public <T> T applyVisitor(AbstractMWArrayVisitor<T> v)
protected void validate()
public static MWNumericArray newInstance(int[] dims, MWClassID classid, MWComplexity cmplx)
newInstance(int[] dims, MWClassID classid, MWComplexity cmplx)To construct and initialize a real numeric array, use:
newInstance(int[] dims, Object rData, MWClassID classid)To construct and initialize a complex numeric array, use
newInstance(int[] dims, Object rData, Object iData, MWClassID classid)
Example: Constructing a Numeric Array Object with newInstance
Construct a 3-by-6 real numeric array using the newInstance method. Note that data in the Java array must be stored in column-major order so that it will be in the correct order in the final MWNumericArray object.int[] dims = {3, 6}; double[] Adata = { 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10, 16, 5, 11, 17, 6, 12, 18}; MWNumericArray A = MWNumericArray.newInstance(dims, Adata, MWClassID.DOUBLE); System.out.println("A = " + A);When run, the example displays this output:
A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
dims
- array of dimension sizes. Each dimension size must be non-negative.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.cmplx
- Array complexity. MWComplexity.REAL
= Real array, MWComplexity.COMPLEX
= Complex array.MWNumericArray
with the specified size, type, and complexity.java.lang.NegativeArraySizeException
- A negative dimension size is supplied.public static MWNumericArray newInstance(int[] dims, java.lang.Object rData, MWClassID classid)
dims
- Array of dimension sizes. Each dimension size must be non-negative.rData
- Data to initialize the array with.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.MWNumericArray
with the specified dimensions and type, and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative dimension size is supplied.java.lang.ArrayStoreException
- A non-numeric array type was specified.public static MWNumericArray newInstance(int[] dims, java.lang.Object rData, java.lang.Object iData, MWClassID classid)
dims
- Array of dimension sizes. Each dimension size must be non-negative.rData
- Data to initialize the real part of the array with.iData
- Data to initialize the imaginary part of the array with.classid
- MWClassID
representing the MATLAB type of the array.
For numeric arrays, the following types are allowed: MWClassID.DOUBLE
,
MWClassID.SINGLE
, MWClassID.INT8
, MWClassID.UINT8
,
MWClassID.INT16
, MWClassID.UINT16
, MWClassID.INT32
,
MWClassID.UINT32
, MWClassID.INT64
, MWClassID.UINT64
.MWNumericArray
with the specified dimensions and type, and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative dimension size is supplied.java.lang.ArrayStoreException
- A non-numeric array type was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, int rows, int cols, int nzmax, MWClassID classid)
newSparse(int rows, int cols, int nzmax, MWClassID classid, MWComplexity cmplx)To construct a real sparse array from an existing nonsparse two-dimensional array, use:
newSparse(Object realData, MWClassID classid)To construct and initialize a new real sparse array, use:
newSparse(int[] rowindex, int[] colindex, Object realData, MWClassID classid)To construct and initialize a new real sparse array, specifying its dimensions, use:
newSparse(int[] rowindex, int[] colindex, Object realData, int rows, int cols, MWClassID classid)To construct and initialize a new real sparse array, specifying its dimensions and maximum number of nonzeros, use:
newSparse(int[] rowindex, int[] colindex, Object realData, int rows, int cols, int nzmax, MWClassID classid)To construct a complex sparse array from an existing nonsparse two-dimensional array, use:
newSparse(Object realData, Object imagData, MWClassID classid)To construct and initialize a new complex sparse array, use:
newSparse(int[] rowindex, int[] colindex, Object realData, Object imagData, MWClassID classid)To construct and initialize a new complex sparse array, specifying its dimensions, use:
newSparse(int[] rowindex, int[] colindex, Object realData, Object imagData, int rows, int cols, MWClassID classid)To construct and initialize a new complex sparse array, specifying its dimensions and maximum number of nonzeros, use:
newSparse(int[] rowindex, int[] colindex, Object realData, Object imagData, int rows, int cols, int nzmax, MWClassID classid)
Example: Constructing a Sparse Array Object with newSparse
To create a sparse complex MWNumericArray, construct a two-dimensional complex sparse MWNumericArray from the real and imaginary double vectors:double[][] rData = {{ 0, 0, 0, 16, 0}, {71, 63, 32, 0, 0}}; double[][] iData = {{ 0, 0, 0, 41, 0}, { 0, 0, 32, 0, 2}}; MWNumericArray A = MWNumericArray.newSparse(rData, iData, MWClassID.DOUBLE); System.out.println("A = " + A.toString());When run, the example displays this output:
A = (2,1) 71.0000 (2,2) 63.0000 (2,3) 32.0000 +32.0000i (1,4) 16.0000 +41.0000i (2,5) 0 + 2.0000i
Example: Using newSparse with Row and Column Indices
Construct a sparse MWNumericArray from vector Adata:double[] Adata = { 0, 10, 0, 0, 40, 50, 60, 0, 0, 90}; int[] ri = {1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; int[] ci = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5}; MWNumericArray A = MWNumericArray.newSparse(ri, ci, Adata, MWClassID.DOUBLE); System.out.println("A = " + A.toString());When run, the example displays this output:
(2,1) 50 (1,2) 10 (2,2) 60 (1,5) 40 (2,5) 90
Example: Assigning Multiple Values to a Single Array Element
Create a sparse MWNumericArray using the rowindex and colindex arguments, specifying multiple values for the array element at index (2, 5). The result is that this element stores the sum of the values from Adata(1), Adata(7), Adata(8), and Adata(9), which is equal to 250.double[] Adata = { 0, 10, 0, 0, 40, 50, 60, 70, 80, 90}; int[] ri = {1, 2, 1, 1, 1, 2, 2, 2, 2, 2}; int[] ci = {1, 5, 2, 3, 5, 1, 2, 5, 5, 5}; MWNumericArray A = MWNumericArray.newSparse(ri, ci, Adata, 4, 5, MWClassID.DOUBLE); System.out.println("A = " + A.toString());When run, the example displays this output:
(2,1) 50 (2,2) 60 (1,5) 40 (2,5) 250
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.nzmax
- Maximum number of nonzero elements.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, int rows, int cols, MWClassID classid)
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.rows
- Number of rows.cols
- Number of columns.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, MWClassID classid)
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(java.lang.Object rArr, MWClassID classid)
rArr
- Array to convert.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
initialized with the supplied data.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, java.lang.Object iData, int rows, int cols, int nzmax, MWClassID classid)
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.iData
- Data to initialize the imaginary part of the array with.rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.nzmax
- Maximum number of nonzero elements.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, java.lang.Object iData, int rows, int cols, MWClassID classid)
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.iData
- Data to initialize the imaginary part of the array with.rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(int[] rowindex, int[] colindex, java.lang.Object rData, java.lang.Object iData, MWClassID classid)
rowindex
- Array of 1-based row indices.colindex
- Array of 1-based column indices.rData
- Data to initialize the real part of the array with.iData
- Data to initialize the imaginary part of the array with.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size and initialized with the supplied data.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static MWNumericArray newSparse(java.lang.Object rArr, java.lang.Object iArr, MWClassID classid)
rArr
- Array to convert to real part of matrix.iArr
- Array to convert to imaginary part of matrix.classid
- MWClassID
representing the MATLAB type of the array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
initialized with the supplied data.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.public static MWNumericArray newSparse(int rows, int cols, int nzmax, MWClassID classid, MWComplexity cmplx)
rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.nzmax
- Maximum number of nonzero elements.classid
- MWClassID
representing the MATLAB type of the array.cmplx
- Array complexity. MWComplexity.REAL
= Real array, MWComplexity.COMPLEX
= Complex array.
Currently, the only type allowed is MWClassID.DOUBLE
.MWNumericArray
with the specified size.java.lang.NegativeArraySizeException
- A negative row or column size is supplied.java.lang.ArrayStoreException
- An incompatible array type or invalid array data was specified.java.lang.IndexOutOfBoundsException
- An invalid row or column index was specified.public static double getNaN()
public static double getEps()
public static double getInf()
public static boolean isFinite(double x)
x
- double value to test forExample: Testing for Finite Array Values
Test x for finiteness:double x = 25; if (MWNumericArray.isFinite(x)) System.out.println("The input value is finite");When run, the example displays this output:
The input value is finite
public static boolean isInf(double x)
x
- double value to test for infinityExample: Test x for infinity
double x = 1.0 / 0.0; if (MWNumericArray.isInf(x)) System.out.println("The input value is infinite");When run, the example displays this output:
The input value is infinite
public static boolean isNaN(double x)
x
- double value to test for NaNExample: Testing for NaN Array Values
Test x for NaN:double x = 0.0 / 0.0; if (MWNumericArray.isNaN(x)) System.out.println("The input value is not a number.");When run, the example displays this output:
The input value is not a number
public byte[] serialize() throws java.io.IOException
java.io.IOException
- if the array cannot be serialized. For
example, executable content (function handles, class instances) cannot
be serialized.public static MWArray deserialize(byte[] data)
data
- serialized array returned from MWArray.serializepublic MWClassID classID()
public int numberOfDimensions()
numberOfDimensions
in class MWArray
public int[] getDimensions()
getDimensions
in class MWArray
public boolean isEmpty()
public boolean isSparse()
public boolean equals(java.lang.Object obj)
public int compareTo(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
public int numberOfElements()
numberOfElements
in class MWArray
public int numberOfNonZeros()
numberOfElements()
.numberOfNonZeros
in class MWArray
public int maximumNonZeros()
numberOfElements()
.maximumNonZeros
in class MWArray
public void dispose()
dispose
in interface Disposable
dispose
in class MWArray
public java.lang.Object get(int index)
get
in class MWArray
index
- The index of the requested element. Valid range: 1 <= index <= N, where N = total number of elements in the array.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public java.lang.Object get(int[] index)
get
in class MWArray
index
- Array of indices specifying the location of the requested element.
The length of the index array must be exactly the number of dimensions of this array.
Each element of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public void set(int index, java.lang.Object element)
public void set(int[] index, java.lang.Object element)
set
in class MWArray
index
- Array of indices specifying the location of the element to replace.
The length of the index array must be exactly the number of dimensions of this array.
Each element of the index array has the valid range: 1 <= index[i] <= N[i], where N[i] = the size of the ith dimension.element
- New element to replace at index.java.lang.IndexOutOfBoundsException
- An invalid index has been supplied.public java.lang.Object[] toArray()
toArray
returns the real part. If the underlying array is sparse, a full representation of
the array is returned. Care should be taken when calling toArray
on a
sparse array with large row and column dimensions, as this action may exhaust system
memory. If the underlying array is a cell or struct array, toArray
is
recursively called on each cell.public java.lang.Object getData()
getData
returns
the real part. If the underlying array is a cell or struct array, toArray
is
recursively called on each cell.getData
in class MWArray
numberOfElements()
for a non-sparse array, and numberOfNonZeros()
for a sparse array.public int[] rowIndex()
public int[] columnIndex()
columnIndex
in class MWArray
protected java.lang.Object readResolve() throws java.io.ObjectStreamException
java.io.InvalidObjectException
- Attempt to load an invalid array handle.java.io.ObjectStreamException
© 1994-2017 The MathWorks, Inc. Patents Trademarks