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 Java types matching the primitive type imaginary 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 Java types matching the primitive type imaginary 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 Java types matching the primitive type imaginary 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 Java types matching the primitive type imaginary integer.
|
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 Java types matching the primitive type imaginary 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 Java types matching the primitive type imaginary 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 integer.
|
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 Java types matching the primitive type byte.
|
java.lang.Object |
toDoubleArray()
Returns an array of Java types matching the primitive type double.
|
java.lang.Object |
toFloatArray()
Returns an array of Java types matching the 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 Java types matching the primitive type imaginary byte.
|
java.lang.Object |
toImagDoubleArray()
Returns an array of Java types matching the primitive type imaginary double.
|
java.lang.Object |
toImagFloatArray()
Returns an array of Java types matching the primitive type imaginary float.
|
java.lang.Object |
toImagIntArray()
Returns an array of Java types matching the primitive type imaginary integer.
|
java.lang.Object |
toImagLongArray()
Returns an array of Java types matching the primitive type imaginary long.
|
java.lang.Object |
toImagShortArray()
Returns an array of Java types matching the primitive type imaginary short.
|
java.lang.Object |
toIntArray()
Returns an array of Java types matching the primitive type int.
|
java.lang.Object |
toLongArray()
Returns an array of Java types matching the primitive type long.
|
java.lang.Object |
toShortArray()
Returns an array of Java types matching the primitive type short.
|
java.lang.String |
toString()
Returns a string representation of this array.
|
protected void |
validate()
Validates the internal array handle.
|
disposeArraypublic MWNumericArray()
MWNumericArray of type MWClassID.DOUBLE.public MWNumericArray(MWClassID classid)
MWNumericArray of the specified type.
In addition to using the MWNumericArray constructor, you can also use
the newSparse method to construct an MWNumericArray. This
offers better performance than using the constructor.
MWNumericArray A = new MWNumericArray(MWClassID.INT64);
System.out.println("A = " + A);
When you run this example, the results are as follows:
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 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.java.lang.ArrayStoreException - A non-numeric array type was specified.
double AReal = 24;
MWNumericArray A = new MWNumericArray(AReal, MWClassID.INT16);
System.out.println("Array A of type " + A.classID() + " = \n" + A);
When you run this example, the results are as follows:
Array A of type int16 =
24
double AReal = 24;
double AImag = 5;
MWNumericArray A = new MWNumericArray(AReal, AImag);
System.out.println("Array A of type " + A.classID() + " = \n" + A);
When you run this example, the results are as follows:
Array A of type double =
24.0000 + 5.0000i
public MWNumericArray(double rVal)
MWClassID.DOUBLE that represents the primitive double argument.rVal - The value to initialize the array with.
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(double rVal,
double iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.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.
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(double rVal,
double iVal)
MWClassID.DOUBLE that represents the primitive double arguments.rVal - The value to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(float rVal,
MWClassID classid)
rVal - The value 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.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 to initialize the array with.public MWNumericArray(float rVal,
float iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.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 to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(byte rVal,
MWClassID classid)
rVal - The value 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.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 to initialize the array with.public MWNumericArray(byte rVal,
byte iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.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 to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(int rVal,
MWClassID classid)
rVal - The value 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.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 to initialize the array with.public MWNumericArray(int rVal,
int iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.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 to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(short rVal,
MWClassID classid)
rVal - The value 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.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 to initialize the array with.public MWNumericArray(short rVal,
short iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.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 to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(long rVal)
MWClassID.INT64 that represents the primitive long argument.rVal - The value to initialize the array with.public MWNumericArray(long rVal,
long iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.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 to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.public MWNumericArray(boolean rVal,
MWClassID classid)
rVal - The value 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.java.lang.ArrayStoreException - A non-numeric array type was specified.public MWNumericArray(boolean rVal,
boolean iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.java.lang.ArrayStoreException - A non-numeric array type was specified.public MWNumericArray(java.lang.Object rVal,
MWClassID classid)
rVal - The value 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.java.lang.ArrayStoreException - A non-numeric array type was specified.public MWNumericArray(java.lang.Object rVal,
java.lang.Object iVal,
MWClassID classid)
rVal - The value to initialize the real part of the array with.iVal - The value 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.java.lang.ArrayStoreException - A non-numeric array type was specified.public MWNumericArray(java.lang.Object rVal)
rVal - The value to initialize the array with.java.lang.ArrayStoreException - An invalid input array was specified.public MWNumericArray(java.lang.Object rVal,
java.lang.Object iVal)
rVal - The value to initialize the real part of the array with.iVal - The value to initialize the imaginary part of the array with.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.
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.
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.
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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.
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.0000i
Get 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 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 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 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.
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 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 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 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 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 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 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 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 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.
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.0000i
Now, 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 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()
public java.lang.Object toDoubleArray()
public java.lang.Object toFloatArray()
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);
}
public java.lang.Object toIntArray()
public java.lang.Object toLongArray()
public java.lang.Object toShortArray()
public java.lang.Object toImagByteArray()
public java.lang.Object toImagDoubleArray()
public java.lang.Object toImagFloatArray()
public java.lang.Object toImagIntArray()
public java.lang.Object toImagLongArray()
public java.lang.Object toImagShortArray()
public java.lang.Object toImagArray()
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.0000i
Get 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()
public double[] getDoubleData()
public float[] getFloatData()
public int[] getIntData()
public long[] getLongData()
public short[] getShortData()
public byte[] getImagByteData()
public double[] getImagDoubleData()
public float[] getImagFloatData()
public int[] getImagIntData()
public long[] getImagLongData()
public short[] getImagShortData()
public java.lang.Object getImagData()
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.0000i
Get 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)
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
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
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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 incompatable 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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 indeces.colindex - Array of 1-based column indeces.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 incompatable 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 incompatable 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 incompatable 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)
value - double value to test 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)
value - double value to test 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)
value - double value to test 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()
public static MWArray deserialize(byte[] data)
data - serialized array returned from MWArray.serializepublic MWClassID classID()
public int numberOfDimensions()
numberOfDimensions in class MWArraypublic int[] getDimensions()
getDimensions in class MWArraypublic 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 MWArraypublic int numberOfNonZeros()
numberOfElements().numberOfNonZeros in class MWArraypublic int maximumNonZeros()
numberOfElements().maximumNonZeros in class MWArraypublic void dispose()
dispose in interface Disposabledispose in class MWArraypublic java.lang.Object get(int index)
public java.lang.Object get(int[] index)
get in class MWArrayindex - 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 MWArrayindex - 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 MWArraynumberOfElements() for a non-sparse array, and numberOfNonZeros()
for a sparse array.public int[] rowIndex()
public int[] columnIndex()
columnIndex in class MWArrayprotected java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.InvalidObjectException - Attempt to load an invalid array handle.java.io.ObjectStreamException© 1994-2008 The MathWorks, Inc. Terms of Use Patents Trademarks