#Region Project Attributes
#ApplicationLabel: JHSJAMA
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#AdditionalJar:JHSJAMA
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the a
Dim jo As JavaObject
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
jo.InitializeContext
'***********************************************************************************************
jo.RunMethod("initialize2", Array(4,4,3.0))
jo.RunMethod("times", Array(4.0))
'*************************************************************************************************
Dim c(5,4) As Double
Log(" ")
For i = 0 To 4
For j = 0 To 3
c(i,j) = Rnd(0,100)
Log(c(i,j))
Next
Next
Log(" ")
jo.RunMethod("initialize3", Array(c))
'*************************************************************************************************
Dim d(5,4) As Double
Log(" ")
For i = 0 To 4
For j = 0 To 3
d(i,j) = Rnd(0,100)
Log(d(i,j))
Next
Next
Log(" ")
jo.RunMethod("initialize4", Array(d, 3, 2))
'*************************************************************************************************
Dim e(20) As Double
Log(" ")
For i = 0 To 19
e(i) = Rnd(0,100)
Log(e(i))
Next
Log(" ")
jo.RunMethod("initialize5", Array(e,5))
Dim a(3,3) As Double
Log(" ")
a = jo.RunMethod("identity", Array(3,3))
For i = 0 To 2
For j= 0 To 2
Log(a(i,j))
Next
Next
'************************************************************************************************
Dim b(4,3) As Double
Log(" ")
b = jo.RunMethod("random", Array(4,3))
For i = 0 To 3
For j= 0 To 2
Log(b(i,j))
Next
Next
'************************************************************************************************
Dim f(4,3) As Double
Log(" ")
For i = 0 To 3
For j = 0 To 2
f(i,j) = Rnd(0,100)
Log(f(i,j))
Next
Next
Log(" ")
jo.RunMethod("initialize3", Array(f))
Log(" ")
Dim clmn() As Double
clmn = jo.RunMethod("getColumnPackedCopy", Null)
For i = 0 To 11
Log(clmn(i))
Next
Log(" ")
Dim rw() As Double
rw = jo.RunMethod("getRowPackedCopy", Null)
For i = 0 To 11
Log(rw(i))
Next
Log(" ")
Log(jo.RunMethod("getRowDimension", Null))
Log(jo.RunMethod("getColumnDimension", Null))
'************************************************************************************************
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#If Java
//this import needs to be here to call the methods in the Matrix class
import Jama.Matrix;
Matrix mm = null;
/** Construct an m-by-n matrix of zeros.
@param m Number of rows.
@param n Number of colums.
*/
public void initialize1 (int m, int n) {
mm = new Matrix(m,n);
}
//*********************************************************************************************
/** Construct an m-by-n constant matrix.
@param m Number of rows.
@param n Number of colums.
@param s Fill the matrix with this scalar value.
*/
public void initialize2 (int m, int n, double s) {
mm = new Matrix(m,n,s);
}
//*********************************************************************************************
/** Construct a matrix from a 2-D array.
@param A Two-dimensional array of doubles.
@exception IllegalArgumentException All rows must have the same length
@see #constructWithCopy
*/
public void initialize3 (double[][] A) {
mm = new Matrix(A);
double[][] C = mm.getArray();
for (int i = 0; i < C.length; i++) {
for (int j = 0; j < C[0].length; j++) {
BA.Log("" + C[i][j]);
}
}
}
//*********************************************************************************************
/** Construct a matrix quickly without checking arguments.
@param A Two-dimensional array of doubles.
@param m Number of rows.
@param n Number of colums.
*/
public void initialize4 (double[][] A, int m, int n) {
mm = new Matrix(A, m, n);
double[][] C = mm.getArray();
for (int i = 0; i < C.length; i++) {
for (int j = 0; j < C[0].length; j++) {
BA.Log("" + C[i][j]);
}
}
}
//*********************************************************************************************
/** Construct a matrix from a one-dimensional packed array
@param vals One-dimensional array of doubles, packed by columns (ala Fortran).
@param m Number of rows.
@exception IllegalArgumentException Array length must be a multiple of m.
*/
public void initialize5 (double vals[], int m) {
mm = new Matrix(vals,m);
double[][] C = mm.getArray();
for (int i = 0; i < C.length; i++) {
for (int j = 0; j < C[0].length; j++) {
BA.Log("" + C[i][j]);
}
}
}
//*********************************************************************************************
/** Multiply a matrix by a scalar, C = s*A
@param s scalar
@return s*A
*/
public void times(double paramDouble){
mm = mm.times(paramDouble);
double[][] C = mm.getArray();
BA.Log("" + C[0][0]);
}
//*********************************************************************************************
/** Generate identity matrix
@param m Number of rows.
@param n Number of colums.
@return An m-by-n matrix with ones on the diagonal and zeros elsewhere.
*/
public double[][] identity (int m, int n) {
Matrix a;
a = mm.identity(m,n);
double[][] C = a.getArray();
return C;
}
//*********************************************************************************************
/** Generate matrix with random elements
@param m Number of rows.
@param n Number of colums.
@return An m-by-n matrix with uniformly distributed random elements.
*/
public double[][] random (int m, int n) {
Matrix a;
a = mm.random(m,n);
double[][] C = a.getArray();
return C;
}
//*********************************************************************************************
/** Make a one-dimensional column packed copy of the internal array.
@return Matrix elements packed in a one-dimensional array by columns.
*/
public double[] getColumnPackedCopy () {
double[] a;
a = mm.getColumnPackedCopy();
return a;
}
//*********************************************************************************************
/** Make a one-dimensional row packed copy of the internal array.
@return Matrix elements packed in a one-dimensional array by rows.
*/
public double[] getRowPackedCopy () {
double[] a;
a = mm.getRowPackedCopy();
return a;
}
//*********************************************************************************************
/** Get row dimension.
@return m, the number of rows.
*/
public int getRowDimension () {
return mm.getRowDimension ();
}
//*********************************************************************************************
/** Get column dimension.
@return n, the number of columns.
*/
public int getColumnDimension () {
return mm.getColumnDimension ();
}
#End If