Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 对于稀疏矩阵,EJML重塑函数是否有效?_Java_Matrix_Reshape_Ejml - Fatal编程技术网

Java 对于稀疏矩阵,EJML重塑函数是否有效?

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

我想动态地改变稀疏矩阵的维数。然而,我关心的是效率。这个操作是否将第一个矩阵的所有内容复制到一个更大的矩阵中?在这种情况下,是否最好将矩阵维数增加100?在这种情况下,java文档似乎没有谈论效率。

它不会复制值,应该非常快。它确实用零填充列索引,因为这是稀疏格式的一部分

@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);
    }
}