[Home] Restricted access for guests. The link to Java source code is disabled
Java source code of 'jhplot.bsom.Matrix'
package jhplot.bsom;
/*
* @(#)Matrix.java 1.3 20/9/96 Akio Utsugi
*/
import java.util.Random;
import java.lang.Math;
/**
* Matrix is a class for matrix objects with basic linear calculation methods.
* @version 1.2 17 Sep 1996
* @author Akio Utsugi
*/
public class Matrix
{
final static double small = 1e-8;
int row, col;
double value[][];
/**
* Construct a square matrix object.
* @param n size
*/
public Matrix(int n)
{
this(n, n);
}
/**
* Construct a rectangle matrix object.
* @param row number of row
* @param col number of column
*/
public Matrix(int row, int col)
{
int i, j;
this.row = row;
this.col = col;
value = new double[row][col];
for(i=0; i=0;){
for(j = 0; j < n; j++){
w=U.value[i][j];
for(k = i+1; i < k+bw && k < m; k++){
w -= L.value[i][k] * ret.value[k][j];
}
ret.value[i][j] = w;
}
}
return ret;
}
/*
* Special purpose calculations
*/
/**
* Cross squared Euclidean distance Matrix: Z_{ij} = ||X_i - Y_j||^2
*/
public Matrix crossSqDistance(Matrix Y)
{
Matrix ret;
int i, j, k;
double s, d;
int Y_row = Y.row, Y_col = Y.col;
if(col != Y_col){
return null;
}
ret = new Matrix(row, Y_row);
for(i=0; i 0 ? 1 : -1));
a=1./Math.sqrt(1.+tn*tn);
b=a*tn;
for(i=0; i