-2
public class SparseMatrix
{       
     static SparseObjectMatrix2D matrix = new SparseObjectMatrix2D(1000000, 1000000);

     public static void main(String[] args)
     {
            matrix.set(1, 2, 3.0);
     }      
}

これが私が得ているエラーです:

java.lang.ExceptionInInitializerError Caused by:
java.lang.IllegalArgumentException: matrix too large at
cern.colt.matrix.impl.AbstractMatrix2D.setUp(Unknown Source) at
cern.colt.matrix.impl.AbstractMatrix2D.setUp(Unknown Source) at
cern.colt.matrix.impl.SparseObjectMatrix2D.<init>(Unknown Source) at
cern.colt.matrix.impl.SparseObjectMatrix2D.<init>(Unknown Source) at
SparseMatrix.<clinit>(SparseMatrix.java:18) Exception in thread "main"
4

1 に答える 1

2

それはいけません。ドキュメントから:

スロー:
IllegalArgumentException - if rows<0 || columns<0 || > (double)columns*rows > Integer.MAX_VALUE.

x と y 座標でアドレス指定された行列を作成して a を返す代わりに、 を作成しValueますHashMap<Coordinates, Value>。ここで、Coordinatesは x と y を保持する単純なクラスです。

于 2014-12-10T20:57:24.180 に答える