1 package JSci.util; 2 3 import JSci.maths.Complex; 4 import JSci.maths.vectors.*; 5 6 10 public final class VectorToolkit { 11 private VectorToolkit() {} 12 13 16 public static AbstractDoubleVector randomVector(int size) { 17 return new DoubleVector(size).mapComponents(RandomMap.MAP); 18 } 19 22 public static AbstractComplexVector randomComplexVector(int size) { 23 return new ComplexVector(size).mapComponents(RandomMap.MAP); 24 } 25 28 public static double[] toArray(AbstractDoubleVector v) { 29 double array[]=new double[v.dimension()]; 30 array[0]=v.getComponent(0); 31 for(int i=1;i<array.length;i++) 32 array[i]=v.getComponent(i); 33 return array; 34 } 35 38 public static Complex[] toArray(AbstractComplexVector v) { 39 Complex array[]=new Complex[v.dimension()]; 40 array[0]=v.getComponent(0); 41 for(int i=1;i<array.length;i++) 42 array[i]=v.getComponent(i); 43 return array; 44 } 45 } 46 | Popular Tags |