/** * Returns a new array of random values. * @param n1 1st array dimension. */ public static float[] randfloat(int n1) { return randfloat(_random,n1); }
/** * Returns a new array of random values. * @param n1 1st array dimension. * @param n2 2nd array dimension. */ public static float[][] randfloat(int n1, int n2) { return randfloat(_random,n1,n2); }
/** * Returns a new array of random values. * @param n1 1st array dimension. * @param n2 2nd array dimension. * @param n3 3rd array dimension. */ public static float[][][] randfloat(int n1, int n2, int n3) { return randfloat(_random,n1,n2,n3); }
private static float[][] randomInput() { int n1 = 5; int n2 = 5; return randfloat(n1,n2); }
private static float[] rands(int n1) { return sub(randfloat(n1),0.5f); } private static float[][] rands(int n1, int n2) {
private static float[][] rands(int n1, int n2) { return sub(randfloat(n1,n2),0.5f); } private static float[][][] rands(int n1, int n2, int n3) {
private static float[][] rands(int n1, int n2) { return sub(randfloat(n1,n2),0.5f); } private static float[][][] rands(int n1, int n2, int n3) {
private static float[] rands(int n1) { return sub(randfloat(n1),0.5f); } private static float[][] rands(int n1, int n2) {
private static float[][] rands(int n1, int n2) { return sub(randfloat(n1,n2),0.5f); } private static float[][][] rands(int n1, int n2, int n3) {
private static float[][][] rands(int n1, int n2, int n3) { return sub(randfloat(n1,n2,n3),0.5f); }
private static float[] rands(int n1) { return sub(randfloat(n1),0.5f); } private static float[][] rands(int n1, int n2) {
private static float[][] rands(int n1, int n2) { return sub(randfloat(n1,n2),0.5f); } private static float[][][] rands(int n1, int n2, int n3) {
private static float[] rands(int n1) { return sub(randfloat(n1),0.5f); } private static float[][] rands(int n1, int n2) {
private static float[][][] rands(int n1, int n2, int n3) { return sub(randfloat(n1,n2,n3),0.5f); }
public void testSolve() { int n = 100; float[] a = randfloat(n); float[] b = randfloat(n); float[] c = randfloat(n); for (int i=0; i<n; ++i) b[i] += a[i]+c[i]; // ensure non-singular (and positive-definite) TridiagonalFMatrix t = new TridiagonalFMatrix(n,a,b,c); float[] r = randfloat(n); float[] u = zerofloat(n); t.solve(r,u); float[] s = t.times(u); assertEqualFuzzy(r,s); }
private static float[][][] sampleTestFunction(int n1, int n2) { Random r = new Random(3); float[] x1 = mul(2.0f,randfloat(r,n1)); float[] x2 = mul(2.0f,randfloat(r,n2)); quickSort(x1); quickSort(x2); float[][] y = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = testFunction00(x1[i1],x2[i2]); return new float[][][]{new float[][]{x1,x2},y}; } private static float testFunction00(float x1, float x2) {
private static float[][][] sampleTestFunction(int n1, int n2) { Random r = new Random(3); float[] x1 = mul(2.0f,randfloat(r,n1)); float[] x2 = mul(2.0f,randfloat(r,n2)); quickSort(x1); quickSort(x2); float[][] y = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = testFunction00(x1[i1],x2[i2]); return new float[][][]{new float[][]{x1,x2},y}; } private static float testFunction00(float x1, float x2) {
public void testRandom() { int n1 = 10; int n2 = 11; int n3 = 12; float[][][] a = randfloat(n1,n2,n3); SimpleFloat3 sf3 = new SimpleFloat3(a); float[][][] c = copy(a); testRandom1(sf3,c); testRandom2(sf3,c); testRandom3(sf3,c); }
public void test123() { int n1 = 10; int n2 = 11; int n3 = 12; float[][][] a = randfloat(n1,n2,n3); SimpleFloat3 sf3 = new SimpleFloat3(a); float[][][] c = copy(a); test1(sf3,c); test2(sf3,c); test3(sf3,c); }