id
stringlengths
36
36
text
stringlengths
1
1.25M
1ab489cf-7a0a-44a4-b590-b031797ee795
@Override protected void write(char[] arr, int offset, int size) { int tailLen = capacity - putIndex; long address = block.address; if(size <= tailLen) { writeChars(address, putIndex, arr, offset, offset+size); }else { writeChars(address, putIndex, arr, offset, offset+tailLen); writeChars(address, 0, ...
34494b6d-ae30-4515-ab63-98951a8f2695
@Override protected char read() { return readChar(block.address, takeIndex); }
2ea58785-c469-42e4-86d6-49e3c88b0170
@Override protected void read(char[] arr, int offset, int size) { long address = block.address; if(putIndex <= takeIndex) { int tailLen = capacity - takeIndex; if(size <= tailLen) { readChars(address, takeIndex, arr, offset, offset+size); }else { readChars(address, takeIndex, arr, offset, offset+t...
cc16ae65-2646-4dca-b227-c904f33df565
@Override protected boolean isArrayBacked() { return false; }
f4760802-ef89-41d7-a90b-ca883007bfec
@Override protected char[] backendArray() { throw new UnsupportedOperationException("rolling direct char buffer"); }
120b9460-df34-42e9-a1fb-3a67b7fb7d4e
MemoryBlock(int capacity) { address = allocateMemory(capacity); cleaner = Cleaner.create(this, new Deallocator(address)); }
96282c66-26a6-4a69-8948-02f8afdd8ec5
static MemoryBlock allocate(int capacity) { return new MemoryBlock(capacity); }
72534af1-cab7-46ff-a99c-394792bdc917
static void deallocate(MemoryBlock block) { if(block != null) { block.cleaner.clean(); } }
6c165c69-70b2-4a22-8adc-278bc1b116d7
private Deallocator(long address) { this.address = address; }
05f2d566-a58c-4ea7-8f5c-aba3a4538682
public void run() { if(address == 0) { return; } freeMemory(address); address = 0; }
c3d04566-6595-49c3-9f3b-8045ab6ad3d1
@Override protected void clean() { resetIndex(); capacity = 0; if(block != null) { MemoryBlock.deallocate(block); block = null; } }
7121b427-d677-4161-9c1f-c372477d66b4
RollingHeapCharBuffer(int capacity) { super(); buffer = new char[capacity]; }
1867b797-f921-4b63-b4a8-db58e8f4a870
RollingHeapCharBuffer(char[] array) { super(); buffer = array; }
1034f609-ce1a-498d-9c80-a900a7b0db1d
@Override protected int retCapacity() { return buffer.length; }
c72f746e-d167-45d1-a8ea-be2fbccf2828
@Override protected void ensureCapacity(int incCap) { if(incCap < remained()) { return; } int capacity = capacity(); int newCapacity = 0; if(2*incCap <= capacity) { newCapacity = capacity * 3 / 2 + 1; }else { newCapacity = capacity * 2; } char[] newBuf = new char[newCapacity]; if(size > 0) { ...
107873a4-fff3-41cf-9fdf-98ececdfdbef
@Override protected void write(char ch) { buffer[putIndex] = ch; }
0bd4196d-ad98-4c8a-a888-5d70ecb57e82
@Override protected void write(char[] arr, int offset, int size) { int tailLen = buffer.length - putIndex; if(tailLen >= size) { System.arraycopy(arr, offset, buffer, putIndex, size); }else { System.arraycopy(arr, offset, buffer, putIndex, tailLen); System.arraycopy(arr, offset+tailLen, buffer, 0, size-...
0e29d00e-bbd5-4914-a865-2d88b929f8a5
@Override protected char read() { return buffer[takeIndex]; }
bda9ee55-77d1-4dd9-b070-c5a6d42c2100
@Override protected void read(char[] arr, int offset, int size) { if(putIndex <= takeIndex) { int len = buffer.length - takeIndex; if(size <= len) { System.arraycopy(buffer, takeIndex, arr, offset, size); }else { System.arraycopy(buffer, takeIndex, arr, offset, len); System.arraycopy(buffer, 0, ...
fa06d69d-31ff-47bc-b1f3-19cae33d6524
@Override protected boolean isArrayBacked() { return true; }
869dc099-2420-4d79-80c5-e295b1bda959
@Override protected char[] backendArray() { return buffer; }
c8b3cfc0-dc4c-450f-b1dc-766ab92cbf26
@Override protected void clean() { resetIndex(); if(buffer != null) { buffer = null; } }
959903c0-3a7d-48cc-8cf1-9bf1b79ef2d2
public static boolean hasUnsafe() { return UNSAFE != null; }
3b01f496-2d1e-40eb-b7dd-7a61a89f6c2f
public static int memoryPageSize() { if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: memoryPageSize()"); } return UNSAFE.pageSize() / (int)CHAR_ARRAY_SCALE; }
05c49eed-c2c0-4edc-bcee-6bec366a29f2
public static long allocateMemory(long chars) { if(chars < 0) { throw new IllegalArgumentException("illegal argument for allocate memory operaion"); } if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: allcateMemory(long)"); } return UNSAFE.allocateMemory(CHAR_ARRAY_SCALE...
b3c29246-aa23-46ed-b665-5cf1811ad084
public static void freeMemory(long address) { if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: freeMemory(long)"); } UNSAFE.freeMemory(address); }
0dffbb8c-6bb3-4c3a-8901-c5cebff79930
public static char readChar(long address, int offset) { if(address == 0 || offset < 0) { throw new IllegalArgumentException("illegal argument for read char operaion"); } if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: readChar(long)"); } return UNSAFE.getChar(address+o...
a9e59faa-bd2d-403f-a554-c9d8719e77ee
public static void readChars(long address, int offset, char[] arr) { if(address == 0 || offset < 0 || arr == null) { throw new IllegalArgumentException("illegal argument for read chars opertaion"); } if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: readChars(long, char[])")...
8fe101e4-319c-4517-979f-1718b42a5ae3
public static void readChars(long address, int offset, char[] arr, int beginIndex, int endIndex) { if(address == 0 || offset < 0 || arr == null) { throw new IllegalArgumentException("illegal argument for read chars opertaion"); } if(beginIndex < 0 || endIndex > arr.length) { throw new ArrayIndexOutOfBoundsE...
b537fb1a-6415-40ae-980e-f0db0acbbc69
public static void writeChar(long address, int offset, char ch) { if(address == 0 || offset < 0) { throw new IllegalArgumentException("illegal argument for write char operaion"); } if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: writeChar(long, char)"); } UNSAFE.putCha...
9db759bf-4b42-429b-987b-780d1724491f
public static void writeChars(long address, int offset, char[] arr) { if(address == 0 || offset < 0 || arr == null) { throw new IllegalArgumentException("illegal argument for write chars opertaion"); } if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: writeChars(long, char[]...
377af205-f97b-4f4f-aef6-ea673de72015
public static void writeChars(long address, int offset, char[] arr, int beginIndex, int endIndex) { if(address == 0 || offset < 0 || arr == null) { throw new IllegalArgumentException("illegal argument for write chars opertaion"); } if(beginIndex < 0 || endIndex > arr.length) { throw new ArrayIndexOutOfBound...
53ae9fa5-3f3a-4d59-81a0-bea3de58f4c2
public static void copyMemory(long srcMemAddr, int srcOffset, long destMemAddr, int destOffset, long chars) { if(!hasUnsafe()) { throw new UnsupportedOperationException("unsupported opertaion: copyMemory(long, long, long)"); } UNSAFE.copyMemory(srcMemAddr+srcOffset*CHAR_ARRAY_SCALE, destMemAddr+destOff...
36518aeb-c8a0-47d7-b8fa-a231723a9a20
private static void copyMemory(char[] srcArray, int srcOffset, long destMemAddr, int destOffset, long chars) { UNSAFE.copyMemory(srcArray, CHAR_ARRAY_OFFSET+srcOffset*CHAR_ARRAY_SCALE, null, destMemAddr+destOffset*CHAR_ARRAY_SCALE, chars*CHAR_ARRAY_SCALE); }
e32a00ea-0cda-43e7-9a4e-f6a20af1bda2
private static void copyMemory(long srcMemAddr, int srcOffset, char[] destArray, int destOffset, long chars) { UNSAFE.copyMemory(null, srcMemAddr+srcOffset*CHAR_ARRAY_SCALE, destArray, CHAR_ARRAY_OFFSET+destOffset*CHAR_ARRAY_SCALE, chars*CHAR_ARRAY_SCALE); }
58f4154b-0b9d-4e12-bc25-5fb5b92a1217
public static void main(String[] args) { char[] src = new char[] {'1','2','3'}; long dest = allocateMemory(3); writeChar(dest, 0, 'a'); writeChar(dest, 1, 'a'); writeChar(dest, 2, 'a'); writeChars(dest, 1, src, 1, 3); System.out.println(readChar(dest, 1)); System.out.println(readChar(dest, 2)); ...
d3372f0b-b463-4add-8a0d-e12be9c69029
public static void main(String[] args) throws Exception { // testAccessJavaCharArray(); // testReallocateMemory(); // testCopyJavaMemory(); testPageSize(); }
5d4043e4-9603-4c05-98fa-6010926144f4
public static void testAccessJavaCharArray() throws Exception { char[] chars = new char[] {'1', '2', '3'}; Unsafe unsafe = getUnsafe(); long address = unsafe.arrayBaseOffset(char[].class); int scale = unsafe.arrayIndexScale(char[].class); println("scale = "+scale); println(unsafe.getChar(chars, address)); ...
c445e39c-445e-483b-8245-e5412bfdf71c
public static void testReallocateMemory() throws Exception { Unsafe unsafe = getUnsafe(); long addr = unsafe.allocateMemory(2); unsafe.putByte(addr, (byte)1); unsafe.putByte(addr+1, (byte)2); println(unsafe.getByte(addr)); println(unsafe.getByte(addr+1)); long newAddr = unsafe.reallocateMemory(addr, 4); ...
5c2f8543-b2e8-4b2f-93a4-7a66bd61750f
public static void testCopyJavaMemory() throws Exception { Unsafe unsafe = getUnsafe(); char[] src = new char[] {'1', '2', '3'}; long offset = unsafe.arrayBaseOffset(char[].class); long scale = unsafe.arrayIndexScale(char[].class); long dest = unsafe.allocateMemory(3); unsafe.putChar(dest, '4'); unsafe...
9472d7d1-3810-4d2b-8b11-b6bf15f22052
private static void testPageSize() throws Exception { Unsafe unsafe = getUnsafe(); println(unsafe.pageSize()); }
2387d9a8-8a29-47ed-8daf-254e40378b00
private static Unsafe getUnsafe() throws Exception { Field f = Unsafe.class.getDeclaredField("theUnsafe"); f.setAccessible(true); return (Unsafe) f.get(null); }
e54b8fee-3cf0-4647-9fb8-1a1bc747ac5d
private static <T> void println(T obj) { System.out.println(obj); }
3973655d-950b-4560-bde7-3f4556fc9eb1
public static void main(String[] args) throws Exception { testRollingHeapCharBuffer(); testRollingDirectCharBuffer(); }
5c027fda-9b30-46db-a50a-87454911daae
public static void testRollingHeapCharBuffer() { testOpSeq(RollingCharBuffer.allocate(6)); }
79932c58-8c25-4e7b-925e-1b4c902859ee
public static void testRollingDirectCharBuffer() { testOpSeq(RollingCharBuffer.allocate(6, true)); }
65250a73-3c68-493d-8c17-104333c27003
private static void testOpSeq(RollingCharBuffer buffer) { println("====================="+buffer.getClass().getSimpleName()+"====================="); boolean hasArray = buffer.hasArray(); println(hasArray); buffer.put('1'); buffer.put(new char[]{'2', '3'}); buffer.put(new char[]{'4', '5'}); println(...
62fbfead-6986-479e-b634-d8190c5cbb3d
private static <T> void println(T obj) { System.out.println(obj); }
d35deae8-466b-4aa8-8f93-f6fa9c35f6a4
public void setup(Context context) { System.out.println("============== SETUP () ============"); FileSplit fileSplit = (FileSplit)context.getInputSplit(); inpFile = fileSplit.getPath().getName(); }
a5209e50-f154-4e9f-b8bb-c4e8b5bd0f42
public void map(LongWritable key, Text value, Context context) throws IOException { String line = value.toString(); line = line.replaceAll("[^a-zA-Z0-9]+"," "); line = line.toLowerCase(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) ...
0432437f-daf7-4e03-ba2b-6b8f4633fddc
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException { Set<String> fileSet = new HashSet<String>(); int sum = 0, dc = 0; for(Text val:values) { fileSet.add(val.toString()); sum++; ...
22335325-7d9c-4abf-a606-bb6ba204ca69
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = new Job(conf, "TermIndexer Job"); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setJarByClass(TermIndexer.class...
4bf52eac-e4d2-4132-b5b6-e538347d1db6
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if (otherArgs.length != 6) { System.err.println("Usage: wordcount <in> <out> <NoOfClusters K> <CentroidFile> <MaxIterations>...
d9464f08-e0ab-4022-839e-3212f7352a07
public void reduce(IntWritable key, Iterable<Text> values, Context context ) throws IOException, InterruptedException { double[] intArray = null; int flag =1; int size = 0; int counter = 0; //key is unique for each reducer hence append C to it ...
7e069b44-618e-48b6-8303-c532bb8b0628
public void setup(Context context) { Configuration conf = context.getConfiguration(); try { FileSystem fs = FileSystem.get(conf); Path infile = new Path(conf.get("CentroidFile")); //give it as an argument if (!fs.exists(infile)) System.out.println("Centroids.txt does not exist"); ...
871215c6-c65f-4652-abc8-f4c7c26938d2
private double EucledianDistance(String s1, String s2) { StringTokenizer itr1 = new StringTokenizer(s1); StringTokenizer itr2 = new StringTokenizer(s2); String id1 = itr1.nextToken("\t");//Do not remove (needed to remove the first id element) String id2 = itr2.nextToken("\t");//Do not remove (needed...
6170a51c-c7b6-4e1c-9e05-54e4bcd1b009
public void map(Object key, Text value, Context context ) throws IOException, InterruptedException { int minCentroidID=0; double dist, mindist = -1.0; Iterator<Integer> keyIter = Centroids.keySet().iterator(); while (keyIter.hasNext()) { Integer Centr...
acc8f689-8520-45b5-9017-d089b9500532
public CholeskyDecomposition (Matrix Arg) { // Initialize. double[][] A = Arg.getArray(); n = Arg.getRowDimension(); L = new double[n][n]; isspd = (Arg.getColumnDimension() == n); // Main loop. for (int j = 0; j < n; j++) { double[] Lrowj = L[j]; double d = 0...
beccf7a7-b711-4a57-a342-dc5604d800f5
public boolean isSPD () { return isspd; }
8aedf833-a888-45ed-8828-59aeedc8b870
public Matrix getL () { return new Matrix(L,n,n); }
40227f17-5af7-4ec1-80d7-d165ea0b6f95
public Matrix solve (Matrix B) { if (B.getRowDimension() != n) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!isspd) { throw new RuntimeException("Matrix is not symmetric positive definite."); } // Copy right hand side. double[][]...
9f318c4c-df4b-4aaa-b24c-687280a8bde4
public QRDecomposition (Matrix A) { // Initialize. QR = A.getArrayCopy(); m = A.getRowDimension(); n = A.getColumnDimension(); Rdiag = new double[n]; // Main loop. for (int k = 0; k < n; k++) { // Compute 2-norm of k-th column without under/overflow. double n...
60d3c62f-0e25-4394-980a-a033afaa065d
public boolean isFullRank () { for (int j = 0; j < n; j++) { if (Rdiag[j] == 0) return false; } return true; }
38386247-2902-4beb-81a1-7d8f65836013
public Matrix getH () { Matrix X = new Matrix(m,n); double[][] H = X.getArray(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (i >= j) { H[i][j] = QR[i][j]; } else { H[i][j] = 0.0; } } } r...
dec8e4ea-0a8b-4d24-9143-1735c328625a
public Matrix getR () { Matrix X = new Matrix(n,n); double[][] R = X.getArray(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i < j) { R[i][j] = QR[i][j]; } else if (i == j) { R[i][j] = Rdiag[i]; } else { ...
a8dd944a-b65b-41fe-9127-b129be0dedf3
public Matrix getQ () { Matrix X = new Matrix(m,n); double[][] Q = X.getArray(); for (int k = n-1; k >= 0; k--) { for (int i = 0; i < m; i++) { Q[i][k] = 0.0; } Q[k][k] = 1.0; for (int j = k; j < n; j++) { if (QR[k][k] != 0) { ...
04653fa9-8e49-464e-a67a-aca2e5e7e36e
public Matrix solve (Matrix B) { if (B.getRowDimension() != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!this.isFullRank()) { throw new RuntimeException("Matrix is rank deficient."); } // Copy right hand side int nx = B...
a8e66b2f-d44c-4631-aca4-5fcc8fb9752a
private void tred2 () { // This is derived from the Algol procedures tred2 by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding // Fortran subroutine in EISPACK. for (int j = 0; j < n; j++) { d[j] = V[n-1][j]; } ...
42ffc857-75b1-4e12-b605-ef74f8583f9d
private void tql2 () { // This is derived from the Algol procedures tql2, by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding // Fortran subroutine in EISPACK. for (int i = 1; i < n; i++) { e[i-1] = e[i]; } ...
d2cc762f-1eac-48c0-8384-a75daf688a8c
private void orthes () { // This is derived from the Algol procedures orthes and ortran, // by Martin and Wilkinson, Handbook for Auto. Comp., // Vol.ii-Linear Algebra, and the corresponding // Fortran subroutines in EISPACK. int low = 0; int high = n-1; for (in...
24418583-9faf-4cfe-b49f-a74042c1f029
private void cdiv(double xr, double xi, double yr, double yi) { double r,d; if (Math.abs(yr) > Math.abs(yi)) { r = yi/yr; d = yr + r*yi; cdivr = (xr + r*xi)/d; cdivi = (xi - r*xr)/d; } else { r = yr/yi; d = yi + r*yr; cdivr = (r*xr + xi)/d...
8ed29a83-f691-4705-b37d-df65d8b90f8c
private void hqr2 () { // This is derived from the Algol procedure hqr2, // by Martin and Wilkinson, Handbook for Auto. Comp., // Vol.ii-Linear Algebra, and the corresponding // Fortran subroutine in EISPACK. // Initialize int nn = this.n; int n = nn-1; in...
ae53e0e9-3910-4ea1-836d-467e4b367fc5
public EigenvalueDecomposition (Matrix Arg) { double[][] A = Arg.getArray(); n = Arg.getColumnDimension(); V = new double[n][n]; d = new double[n]; e = new double[n]; issymmetric = true; for (int j = 0; (j < n) & issymmetric; j++) { for (int i = 0; (i < n) & issymmetr...
95bcc4ec-e658-4702-bb12-113f42d5290a
public Matrix getV () { return new Matrix(V,n,n); }
9e15abaf-d478-4e58-ab53-a8fed77d5714
public double[] getRealEigenvalues () { return d; }
7a459517-02fd-4d35-b69f-4070d44971ee
public double[] getImagEigenvalues () { return e; }
783986b8-d1dd-4d16-ad6c-53ab249be07e
public Matrix getD () { Matrix X = new Matrix(n,n); double[][] D = X.getArray(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { D[i][j] = 0.0; } D[i][i] = d[i]; if (e[i] > 0) { D[i][i+1] = e[i]; } else if (e[i] < 0) { ...
9e1fe2c6-7389-4658-b58a-0cb66310ec7b
public LUDecomposition (Matrix A) { // Use a "left-looking", dot-product, Crout/Doolittle algorithm. LU = A.getArrayCopy(); m = A.getRowDimension(); n = A.getColumnDimension(); piv = new int[m]; for (int i = 0; i < m; i++) { piv[i] = i; } pivsign = 1; double...
a77aa531-4fb6-40a0-83c7-52f25bc25106
public boolean isNonsingular () { for (int j = 0; j < n; j++) { if (LU[j][j] == 0) return false; } return true; }
3983d676-00a3-4ff9-8fc6-2dc387faa48b
public Matrix getL () { Matrix X = new Matrix(m,n); double[][] L = X.getArray(); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (i > j) { L[i][j] = LU[i][j]; } else if (i == j) { L[i][j] = 1.0; } else { ...
434564fc-2a3a-48e8-85df-5d0ab6422a42
public Matrix getU () { Matrix X = new Matrix(n,n); double[][] U = X.getArray(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i <= j) { U[i][j] = LU[i][j]; } else { U[i][j] = 0.0; } } } r...
16c2ab45-6cf3-4927-824c-f552c4013b2f
public int[] getPivot () { int[] p = new int[m]; for (int i = 0; i < m; i++) { p[i] = piv[i]; } return p; }
0716eac4-4749-4638-968e-7e37ec63d0ca
public double[] getDoublePivot () { double[] vals = new double[m]; for (int i = 0; i < m; i++) { vals[i] = (double) piv[i]; } return vals; }
e4fb89b8-cefd-4d75-98a0-2b3c985a5ef7
public double det () { if (m != n) { throw new IllegalArgumentException("Matrix must be square."); } double d = (double) pivsign; for (int j = 0; j < n; j++) { d *= LU[j][j]; } return d; }
c0679dc9-9d68-4334-8e04-3ca1f33a4129
public Matrix solve (Matrix B) { if (B.getRowDimension() != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!this.isNonsingular()) { throw new RuntimeException("Matrix is singular."); } // Copy right hand side with pivoting int n...
972522eb-f30f-4b3e-a5af-80b3b498f1be
public static double hypot(double a, double b) { double r; if (Math.abs(a) > Math.abs(b)) { r = b/a; r = Math.abs(a)*Math.sqrt(1+r*r); } else if (b != 0) { r = a/b; r = Math.abs(b)*Math.sqrt(1+r*r); } else { r = 0.0; } return r;...
4c7e796d-b2f3-4474-beaf-903507fe2e8f
public SingularValueDecomposition (Matrix Arg) { // Derived from LINPACK code. // Initialize. double[][] A = Arg.getArrayCopy(); m = Arg.getRowDimension(); n = Arg.getColumnDimension(); /* Apparently the failing cases are only a proper subset of (m<n), so let's not throw error. ...
ee50e98d-e8d5-48f0-9461-ea3d2ae7f83d
public Matrix getU () { return new Matrix(U,m,Math.min(m+1,n)); }
52fd3690-e267-4435-9abe-3797e7ca9135
public Matrix getV () { return new Matrix(V,n,n); }
243ac612-8e90-47cf-ba17-b04877041123
public double[] getSingularValues () { return s; }
97968674-e7f6-4d7a-8ac9-16945eea8d33
public Matrix getS () { Matrix X = new Matrix(n,n); double[][] S = X.getArray(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { S[i][j] = 0.0; } S[i][i] = this.s[i]; } return X; }
e4c337b3-9c81-4730-b6f3-26b218f3345a
public double norm2 () { return s[0]; }
8673de25-7522-4230-9c8f-d4a02eb99eac
public double cond () { return s[0]/s[Math.min(m,n)-1]; }
af12e3f1-71e5-402c-bc1c-c709389d6ee1
public int rank () { double eps = Math.pow(2.0,-52.0); double tol = Math.max(m,n)*s[0]*eps; int r = 0; for (int i = 0; i < s.length; i++) { if (s[i] > tol) { r++; } } return r; }
1072d7dd-da80-4220-a8cc-6f87c34c252f
public Matrix (int m, int n) { this.m = m; this.n = n; A = new double[m][n]; }
e0ca8768-c967-4e1f-b303-70b9393c6701
public Matrix (int m, int n, double s) { this.m = m; this.n = n; A = new double[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { A[i][j] = s; } } }
d2b7337e-c20b-4a95-8fb6-ad68296b3036
public Matrix (double[][] A) { m = A.length; n = A[0].length; for (int i = 0; i < m; i++) { if (A[i].length != n) { throw new IllegalArgumentException("All rows must have the same length."); } } this.A = A; }
968ffc8d-beb9-4a4f-9c55-791516e970f7
public Matrix (double[][] A, int m, int n) { this.A = A; this.m = m; this.n = n; }
c06f15c2-d0f6-43f5-87d1-b7e9836e9ce4
public Matrix (double vals[], int m) { this.m = m; n = (m != 0 ? vals.length/m : 0); if (m*n != vals.length) { throw new IllegalArgumentException("Array length must be a multiple of m."); } A = new double[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j...
0b0ca987-6997-4a1b-a344-da35440d4145
public static Matrix constructWithCopy(double[][] A) { int m = A.length; int n = A[0].length; Matrix X = new Matrix(m,n); double[][] C = X.getArray(); for (int i = 0; i < m; i++) { if (A[i].length != n) { throw new IllegalArgumentException ("All rows mus...