Prints a sparse matrix.

@param A
sparse matrix (triplet ot column-compressed)
@param brief
print all of A if false, a few entries otherwise
@return true if successful, false on error
19174
public static boolean cs_print(Dcs A, boolean brief) {
        int p, j, m, n, nzmax, nz, Ap[], Ai[];
        double Ax[];
        if (A == null) {
            System.out.print("(null)\n");
            return (false);
        }
        m = A.m;
        n = A.n;
        Ap = A.p;
        Ai = A.i;
        Ax = A.x;
        nzmax = A.nzmax;
        nz = A.nz;
        System.out.print(String.format("CSparseJ Version %d.%d.%d, %s.  %s\n", Dcs_common.CS_VER, Dcs_common.CS_SUBVER,
                Dcs_common.CS_SUBSUB, Dcs_common.CS_DATE, Dcs_common.CS_COPYRIGHT));
        if (nz < 0) {
            System.out.print(String.format("%d-by-%d, nzmax: %d nnz: %d, 1-norm: %g\n", m, n, nzmax, Ap[n], Dcs_norm
                    .cs_norm(A)));
            for (j = 0; j < n; j++) {
                System.out.print(String.format("    col %d : locations %d to %d\n", j, Ap[j], Ap[j + 1] - 1));
                for (p = Ap[j]; p < Ap[j + 1]; p++) {
                    System.out.print(String.format("      %d : %g\n", Ai[p], Ax != null ? Ax[p] : 1));
                    if (brief && p > 20) {
                        System.out.print("  ...\n");
                        return (true);
                    }
                }
            }
        } else {
            System.out.print(String.format("triplet: %d-by-%d, nzmax: %d nnz: %d\n", m, n, nzmax, nz));
            for (p = 0; p < nz; p++) {
                System.out.print(String.format("    %d %d : %g\n", Ai[p], Ap[p], Ax != null ? Ax[p] : 1));
                if (brief && p > 20) {
                    System.out.print("  ...\n");
                    return (true);
                }
            }
        }
        return (true);
    }
1161229
public static SparseMatrix fromMatrixMarket(InputStream is) throws IOException {
        return Matrix.fromMatrixMarket(is).to(Matrices.SPARSE);
    }
723542
public SparseMatrix parse(InputStream stream) throws IOException, ParseException {
        int nrows = 0, ncols = 0, n = 0;
        int[] colIndex;
        int[] rowIndex;
        double[] data;

        try (Scanner scanner = new Scanner(stream)) {
            String line = scanner.nextLine();
            String[] tokens = line.split("\\s+");
            if (tokens.length == 3) {
                try {
                    nrows = Integer.parseInt(tokens[0]);
                    ncols = Integer.parseInt(tokens[1]);
                    n = Integer.parseInt(tokens[2]);
                } catch (Exception ex) {
                }
            }
            
            if (n == 0) {
                // Harwell-Boeing Exchange Format. We ignore first two lines.
                line = scanner.nextLine().trim();
                tokens = line.split("\\s+");
                int RHSCRD = Integer.parseInt(tokens[4]);

                line = scanner.nextLine().trim();
                if (!line.startsWith("R")) {
                    throw new UnsupportedOperationException("SparseMatrixParser supports only real-valued matrix.");
                }

                tokens = line.split("\\s+");
                nrows = Integer.parseInt(tokens[1]);
                ncols = Integer.parseInt(tokens[2]);
                n = Integer.parseInt(tokens[3]);

                line = scanner.nextLine();
                if (RHSCRD > 0) {
                    line = scanner.nextLine();
                }            
            }
            
            colIndex = new int[ncols + 1];
            rowIndex = new int[n];
            data = new double[n];
            for (int i = 0; i <= ncols; i++) {
                colIndex[i] = scanner.nextInt() - 1;
            }
            for (int i = 0; i < n; i++) {
                rowIndex[i] = scanner.nextInt() - 1;
            }
            for (int i = 0; i < n; i++) {
                data[i] = scanner.nextDouble();
            }
        }
        
        SparseMatrix matrix = new SparseMatrix(nrows, ncols, data, rowIndex, colIndex);
        return matrix;
    }
147386
protected void commonSetup(DMatrixRMaj A) {
        setExpectedMaxSize(A.numRows,A.numCols);

        QR.set(A);
    }
444580
public static void sort(DenseMatrix64F matrix, RowComparator comparator)
    {
        int len = matrix.numCols;
        quickSort(matrix.data, 0, matrix.numRows-1, len, comparator, new double[len], new double[len]);
    }
585093
public boolean hasFullRank() {
		// if (R == null) {
		// R = new SparseCCDoubleMatrix2D(N.U);
		// if (rcMatrix) {
		// R = ((SparseCCDoubleMatrix2D) R).getRowCompressed();
		// }
		//
		// }
		int mn = Math.min(m, n);
		double mng = Math.sqrt(m * n);
		// double threshold = ALG.property().tolerance();
		double threshold = mng * Utils.getDoubleMachineEpsilon();
		for (int j = 0; j < mn; j++) {
			// if (R.getQuick(j, j) == 0){
			double rjj = getQuick(N.U, j, j);
			// log.debug("r(" + j + "," + j + "): " + rjj);
			// if (rjj < Utils.getDoubleMachineEpsilon()) {
			// return false;
			// }
			if (rjj < threshold) {
				return false;
			}
		}
		return true;
	}
1262204
def sparse_is_desireable(lhs, rhs):
    '''
    
    '''
    return False
    if len(lhs.shape) == 1:
        return False
    else:
        lhs_rows, lhs_cols = lhs.shape

    if len(rhs.shape) == 1:
        rhs_rows = 1
        rhs_cols = rhs.size
    else:
        rhs_rows, rhs_cols = rhs.shape

    result_size = lhs_rows * rhs_cols

    if sp.issparse(lhs) and sp.issparse(rhs):
        return True
    elif sp.issparse(lhs):
        lhs_zero_rows = lhs_rows - np.unique(lhs.nonzero()[0]).size
        rhs_zero_cols = np.all(rhs==0, axis=0).sum()
        
    elif sp.issparse(rhs):
        lhs_zero_rows = np.all(lhs==0, axis=1).sum()
        rhs_zero_cols = rhs_cols- np.unique(rhs.nonzero()[1]).size
    else:
        lhs_zero_rows = np.all(lhs==0, axis=1).sum()
        rhs_zero_cols = np.all(rhs==0, axis=0).sum()

    num_zeros = lhs_zero_rows * rhs_cols + rhs_zero_cols * lhs_rows - lhs_zero_rows * rhs_zero_cols

    # A sparse matrix uses roughly 16 bytes per nonzero element (8 + 2 4-byte inds), while a dense matrix uses 8 bytes per element. So the break even point for sparsity is 50% nonzero. But in practice, it seems to be that the compression in a csc or csr matrix gets us break even at ~65% nonzero, which lets us say 50% is a conservative, worst cases cutoff.
    return (float(num_zeros) / float(size)) >= 0.5
1142662
public void applyQ( ZMatrixRMaj A ) {
        if( A.numRows != numRows )
            throw new IllegalArgumentException("A must have at least "+numRows+" rows.");

        for( int j = minLength-1; j >= 0; j-- ) {
            int diagIndex = (j*numRows+j)*2;
            double realBefore = QR.data[diagIndex];
            double imagBefore = QR.data[diagIndex+1];

            QR.data[diagIndex] = 1;
            QR.data[diagIndex+1] = 0;

            QrHelperFunctions_ZDRM.rank1UpdateMultR(A, QR.data, j * numRows, gammas[j], 0, j, numRows, v);

            QR.data[diagIndex] = realBefore;
            QR.data[diagIndex+1] = imagBefore;
        }
    }
868252
public void printMatrixSize(MatrixSize size) {
        format(Locale.ENGLISH, "%10d %10d %19d%n", size.numRows(),
                size.numColumns(), size.numEntries());
    }
1178250
public static void matrixCopy(Object[][] src, Object[][] dest) {
        if (src != null && dest != null) {
            for (int i = 0; i < src.length; i++) {
                System.arraycopy(src[i], 0, dest[i], 0, src[i].length);
            }
        }
    }
26909
public void sparsePrint(PrintStream stream) {
    if (mSeries.isEmpty()) {
      return;
    }
    long start = mSeries.firstKey();
    stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);

    for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
      stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
    }
  }
287064
protected boolean process(DMatrixRMaj A, DMatrixRMaj F ) {
		if( !solverNull.process(A,1,F) )
			return true;

		F.numRows = 3;
		F.numCols = 3;

		return false;
	}
1134610
public static SparseMatrix zero(int rows, int columns, int capacity) {
        return CRSMatrix.zero(rows, columns, capacity);
    }
853098
public void printSparseFeatureMatrix(PrintWriter pw) {
    String sep = "\t";
    for (int i = 0; i < size; i++) {
      pw.print(labelIndex.get(labels[i]));
      int[] datum = data[i];
      for (int j : datum) {
        pw.print(sep + featureIndex.get(j));
      }
      pw.println();
    }
  }
696101
public static void printDetail(Class<?> c, String msg) {
		if(Logger.printDetails) {
			String preamble;
			if(c != null)
				preamble = "["+c.getSimpleName()+"]";
			else
				preamble = "";
			
			synchronized(System.err) {
				System.err.println(preamble+" "+msg);
			}
		}
	}
46134
@Override
    public DMatrixRMaj getQ(DMatrixRMaj Q , boolean compact ) {
        if( compact ) {
            Q = UtilDecompositons_DDRM.checkIdentity(Q,numRows,minLength);
        } else {
            Q = UtilDecompositons_DDRM.checkIdentity(Q,numRows,numRows);
        }

        for( int j = minLength-1; j >= 0; j-- ) {
            double u[] = dataQR[j];

            double vv = u[j];
            u[j] = 1;
            QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u, gammas[j], j, j, numRows, v);
            u[j] = vv;
        }

        return Q;
    }
1123424
@Override
    public boolean decompose(DMatrixRBlock A) {
        if( A.numCols != A.numRows )
            throw new IllegalArgumentException("A must be square");

        this.T = A;

        if( lower )
            return decomposeLower();
        else
            return decomposeUpper();
    }