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"
你不能。从文档中:
抛出:
IllegalArgumentException
- 如果rows<0 || columns<0 || > (double)columns*rows > Integer.MAX_VALUE
.
与其创建一个用x和y坐标寻址的矩阵,返回一个Value
,不如创建一个HashMap<Coordinates, Value>
,其中Coordinates
是一个包含x和y的简单类。