public final class Mata extends Object
public static int printMataMatrix(String[] args) {
String name = args[0];
long numCol = Mata.getMataColTotal(name);
long numRow = Mata.getMataRowTotal(name);
if (Mata.isTypeReal(name)) {
for (long i = 0; i < numRow; i++) {
for (long j = 0; j < numCol; j++) {
double value = Mata.getMataRealAt(name, i, j);
String index = "[" + (i + 1) + ", " + (j + 1) + "]";
SFIToolkit.displayln(index + " = " + value);
}
}
}
else {
String type = Mata.getMataEltype(name);
SFIToolkit.errorln("Matrix is type " + type + "; real expected");
return (3250);
}
return 0;
}
. mata
// Matrix must be global for sfi.Mata to access
mat = (1, 3, 5 \ 5, 6, 4)
. end
. javacall Examples printMataMatrix, jar(examples.jar) args(mat)
[1, 1] = 1.0
[1, 2] = 3.0
[1, 3] = 5.0
[2, 1] = 5.0
[2, 2] = 6.0
[2, 3] = 4.0
Modifier and Type | Method and Description |
---|---|
static double[] |
getComplexAt(double[] matrix,
int colCount,
int row,
int col)
Get an element from a previously returned matrix.
|
static void |
getComplexValues(double[] complex,
Double real,
Double imaginary)
Get the real and imaginary parts from a complex result.
|
static long |
getMataColTotal(String name)
Get the number of columns in a Mata matrix.
|
static double[] |
getMataComp(String name)
Deprecated.
This method is not capable of returning the matrix if the
resulting array would exceed 2^31-1 elements. Use
Mata.getMataCompAt(String, long, long) instead. |
static double[] |
getMataCompAt(String name,
long row,
long col)
Read a complex Mata matrix element.
|
static String |
getMataEltype(String name)
Get the type of a Mata object.
|
static double[] |
getMataReal(String name)
Deprecated.
This method is not capable of returning the matrix if the
resulting array would exceed 2^31-1 elements. Use
Mata.getMataRealAt(String, long, long) instead. |
static double |
getMataRealAt(String name,
long row,
long col)
Read a real Mata matrix element.
|
static long |
getMataRowTotal(String name)
Get the number of rows in a Mata matrix.
|
static String[] |
getMataString(String name)
Deprecated.
This method is not capable of returning the matrix if the
resulting array would exceed 2^31-1 elements. Use
Mata.getMataStringAt(String, long, long) instead. |
static String |
getMataStringAt(String name,
long row,
long col)
Read a string Mata matrix element.
|
static double |
getRealAt(double[] matrix,
int colCount,
int row,
int col)
Get an element from a previously returned matrix.
|
static String |
getStringAt(String[] matrix,
int colCount,
int row,
int col)
Get an element from a previously returned matrix.
|
static boolean |
isTypeComplex(String name)
Determine if the matrix type is complex.
|
static boolean |
isTypeReal(String name)
Determine if the matrix type is real.
|
static boolean |
isTypeString(String name)
Determine if the matrix type is string.
|
@Synchronized public static double[] getComplexAt(double[] matrix, int colCount, int row, int col)
matrix
- The matrix.colCount
- The number of columns in the matrix. This value can be
obtained from getMataColTotal()
.row
- Zero-based row number.col
- Zero-based column number.@Synchronized public static void getComplexValues(double[] complex, Double real, Double imaginary)
@Synchronized public static long getMataColTotal(String name)
name
- Name of the Mata matrix.@Deprecated @Synchronized public static double[] getMataComp(String name)
Mata.getMataCompAt(String, long, long)
instead.name
- Name of the Mata matrix.@Synchronized public static double[] getMataCompAt(String name, long row, long col)
name
- Name of the Mata matrix.row
- Zero-based row number.col
- Zero-based column number.@Synchronized public static String getMataEltype(String name)
@Deprecated @Synchronized public static double[] getMataReal(String name)
Mata.getMataRealAt(String, long, long)
instead.name
- Name of the Mata matrix.@Synchronized public static double getMataRealAt(String name, long row, long col)
name
- Name of the Mata matrix.row
- Zero-based row number.col
- Zero-based column number.@Synchronized public static long getMataRowTotal(String name)
name
- Name of the Mata matrix.@Deprecated @Synchronized public static String[] getMataString(String name)
Mata.getMataStringAt(String, long, long)
instead.name
- Name of the Mata matrix.String
array containing the matrix values. Returns null
if an error occurs.@Synchronized public static String getMataStringAt(String name, long row, long col)
@Synchronized public static double getRealAt(double[] matrix, int colCount, int row, int col)
matrix
- The matrix.colCount
- The number of columns in the matrix. This value can be
obtained from getMataColTotal()
.row
- Zero-based row number.col
- Zero-based column number.@Synchronized public static String getStringAt(String[] matrix, int colCount, int row, int col)
matrix
- The matrix.colCount
- The number of columns in the matrix. This value can be
obtained from getMataColTotal()
.row
- Zero-based row number.col
- Zero-based column number.@Synchronized public static boolean isTypeComplex(String name)
name
- Name of the Mata matrix.@Synchronized public static boolean isTypeReal(String name)
name
- Name of the Mata matrix.@Synchronized public static boolean isTypeString(String name)
name
- Name of the Mata matrix.