Java 对于稀疏矩阵,EJML重塑函数是否有效?
我想动态地改变稀疏矩阵的维数。然而,我关心的是效率。这个操作是否将第一个矩阵的所有内容复制到一个更大的矩阵中?在这种情况下,是否最好将矩阵维数增加100?在这种情况下,java文档似乎没有谈论效率。它不会复制值,应该非常快。它确实用零填充列索引,因为这是稀疏格式的一部分Java 对于稀疏矩阵,EJML重塑函数是否有效?,java,matrix,reshape,ejml,Java,Matrix,Reshape,Ejml,我想动态地改变稀疏矩阵的维数。然而,我关心的是效率。这个操作是否将第一个矩阵的所有内容复制到一个更大的矩阵中?在这种情况下,是否最好将矩阵维数增加100?在这种情况下,java文档似乎没有谈论效率。它不会复制值,应该非常快。它确实用零填充列索引,因为这是稀疏格式的一部分 @Override public void reshape( int numRows , int numCols , int arrayLength ) { // OK so technically it is sort
@Override
public void reshape( int numRows , int numCols , int arrayLength ) {
// OK so technically it is sorted, but forgetting to correctly set this flag is a common mistake so
// decided to be conservative and mark it as unsorted so that stuff doesn't blow up
this.indicesSorted = false;
this.numRows = numRows;
this.numCols = numCols;
growMaxLength( arrayLength , false);
this.nz_length = 0;
if( numCols+1 > col_idx.length ) {
col_idx = new int[ numCols+1 ];
} else {
Arrays.fill(col_idx,0,numCols+1,0);
}
}
它不会复制值,应该非常快。它确实用零填充列索引,因为这是稀疏格式的一部分
@Override
public void reshape( int numRows , int numCols , int arrayLength ) {
// OK so technically it is sorted, but forgetting to correctly set this flag is a common mistake so
// decided to be conservative and mark it as unsorted so that stuff doesn't blow up
this.indicesSorted = false;
this.numRows = numRows;
this.numCols = numCols;
growMaxLength( arrayLength , false);
this.nz_length = 0;
if( numCols+1 > col_idx.length ) {
col_idx = new int[ numCols+1 ];
} else {
Arrays.fill(col_idx,0,numCols+1,0);
}
}