Extracts the null space and converts it into the Q matrix
358801
private void extractSolutionForQ( DMatrix4x4 Q ) {
		DMatrixRMaj nv = new DMatrixRMaj(10,1);
		SingularOps_DDRM.nullVector(svd,true,nv);

		// Convert the solution into a fixed sized matrix because it's easier to read
		encodeQ(Q,nv.data);

		// diagonal elements must be positive because Q = [K*K' .. ; ... ]
		// If they are a mix of positive and negative that's bad and can't be fixed
		// All 3 are checked because technically they could be zero. Not a physically useful solution but...
		if( Q.a11 < 0 || Q.a22 < 0 || Q.a33 < 0 ){
			CommonOps_DDF4.scale(-1,Q);
		}
	}
68052
def toSparse(self):
        """"""
        if self.isTransposed:
            values = np.ravel(self.toArray(), order='F')
        else:
            values = self.values
        indices = np.nonzero(values)[0]
        colCounts = np.bincount(indices // self.numRows)
        colPtrs = np.cumsum(np.hstack(
            (0, colCounts, np.zeros(self.numCols - colCounts.size))))
        values = values[indices]
        rowIndices = indices % self.numRows

        return SparseMatrix(self.numRows, self.numCols, colPtrs, rowIndices, values)
314865
def split_qname(qname):
        """"""
        res = qname.split(YinParser.ns_sep)
        if len(res) == 1:       # no namespace
            return None, res[0]
        else:
            return res
1223240
function fromString(string) {
    var parsed = string.match(matrixRegex);
    if (parsed === null || parsed.length < 7) throw new Error('\'' + string + '\' is not a matrix');
    return {
        a: parseFloat(parsed[1]),
        b: parseFloat(parsed[2]),
        c: parseFloat(parsed[3]),
        d: parseFloat(parsed[4]),
        e: parseFloat(parsed[5]),
        f: parseFloat(parsed[6])
    };
}
588293
public DenseMatrix getQ() {
        int m = qr.nrows();
        int n = qr.ncols();
        DenseMatrix Q = Matrix.zeros(m, n);
        for (int k = n - 1; k >= 0; k--) {
            Q.set(k, k, 1.0);
            for (int j = k; j < n; j++) {
                if (qr.get(k, k) != 0) {
                    double s = 0.0;
                    for (int i = k; i < m; i++) {
                        s += qr.get(i, k) * Q.get(i, j);
                    }
                    s = -s / qr.get(k, k);
                    for (int i = k; i < m; i++) {
                        Q.add(i, j, s * qr.get(i, k));
                    }
                }
            }
        }
        return Q;
    }
580848
function() {
            	if (!this.isSquare()) { return null; }
            	if (this.cols == 1 && this.rows == 1) { return this.row(1); }
            	if (this.cols == 0 && this.rows == 0) { return 1; }
            	var M = this.toRightTriangular();
            	var det = M.elements[0][0], n = M.elements.length;
            	for (var i = 1; i < n; i++) {
            	    det = det * M.elements[i][i];
            	}
            	return det;
                }
928979
public static DMatrixRMaj nullspaceSVD( DMatrixRMaj A , int totalSingular ) {
        SolveNullSpace<DMatrixRMaj> solver = new SolveNullSpaceSvd_DDRM();

        DMatrixRMaj nullspace = new DMatrixRMaj(1,1);

        if( !solver.process(A,totalSingular,nullspace))
            throw new RuntimeException("Solver failed. try SVD based method instead?");

        return nullspace;
    }
519338
def getQRArray(text, errorCorrection):
	
	# White is True (1)
	# Black is False (0)
	# ECC: L7, M15, Q25, H30

	# Create the object
	qr = pyqrcode.create(text, error=errorCorrection)

	# Get the terminal representation and split by lines (get rid of top and bottom white spaces)
	plainOut = qr.terminal().split("\n")[5:-5]

	# Initialize the output 2D list
	out = []

	for line in plainOut:
		thisOut = []
		for char in line:
			if char == u'7':
				# This is white
				thisOut.append(1)
			elif char == u'4':
				# This is black, it's part of the u'49'
				thisOut.append(0)
		# Finally add everything to the output, stipping whitespaces at start and end
		out.append(thisOut[4:-4])

	# Everything is done, return the qr code list
	return out
417852
public static DMatrixRMaj nullspaceQR( DMatrixRMaj A , int totalSingular ) {
        SolveNullSpaceQR_DDRM solver = new SolveNullSpaceQR_DDRM();

        DMatrixRMaj nullspace = new DMatrixRMaj(1,1);

        if( !solver.process(A,totalSingular,nullspace))
            throw new RuntimeException("Solver failed. try SVD based method instead?");

        return nullspace;
    }
1364933
def stripnull(string):
    """"""
    i = string.find(b'\x00')
    return string if (i < 0) else string[:i]
602332
@Override
    public ZMatrixRMaj getQ(ZMatrixRMaj Q , boolean compact ) {
        if( compact )
            Q = UtilDecompositons_ZDRM.checkIdentity(Q,numRows,minLength);
        else
            Q = UtilDecompositons_ZDRM.checkIdentity(Q,numRows,numRows);

        for( int j = minLength-1; j >= 0; j-- ) {
            QrHelperFunctions_ZDRM.extractHouseholderColumn(QR,j,numRows,j,u,0);
            QrHelperFunctions_ZDRM.rank1UpdateMultR(Q,u,0,gammas[j],j,j,numRows,v);
        }

        return Q;
    }
342399
public Matrix getQ () {
		Matrix X = new Matrix(m,n);
		double[][] Q = X.getArray();
		for (int k = n-1; k >= 0; k--) {
			for (int i = 0; i < m; i++) {
				Q[i][k] = 0.0;
			}
			Q[k][k] = 1.0;
			for (int j = k; j < n; j++) {
				if (QR[k][k] != 0) {
					double s = 0.0;
					for (int i = k; i < m; i++) {
						s += QR[i][k]*Q[i][j];
					}
					s = -s/QR[k][k];
					for (int i = k; i < m; i++) {
						Q[i][j] += s*QR[i][k];
					}
				}
			}
		}
		return X;
	}
1079289
public boolean process(DMatrixRMaj A , int numSingularValues, DMatrixRMaj nullspace ) {
        decomposition.decompose(A);

        if( A.numRows > A.numCols ) {
            Q.reshape(A.numCols,Math.min(A.numRows,A.numCols));
            decomposition.getQ(Q, true);
        } else {
            Q.reshape(A.numCols, A.numCols);
            decomposition.getQ(Q, false);
        }

        nullspace.reshape(Q.numRows,numSingularValues);
        CommonOps_DDRM.extract(Q,0,Q.numRows,Q.numCols-numSingularValues,Q.numCols,nullspace,0,0);

        return true;
    }
768050
private List<MatrixQueryData.QName> splitMatrixKeysFromRaw(String raw)
  {
    LinkedList<MatrixQueryData.QName> result = new LinkedList<>();

    String[] split = raw.split(",");
    for (String s : split)
    {
      String[] nameSplit = s.trim().split(":", 2);
      MatrixQueryData.QName qname = new MatrixQueryData.QName();
      if (nameSplit.length == 2)
      {
        qname.namespace = nameSplit[0].trim();
        qname.name = nameSplit[1].trim();
      }
      else
      {
        qname.name = nameSplit[0].trim();
      }
      result.add(qname);
    }

    return result;
  }
215830
def nullval(cls):
        """"""

        d = dict(cls.__dict__.items())

        for k in d:
            d[k] = 0

        d['sl'] = cls.sl
        d[cls.level] = 0

        return cls(**d)
289749
def remove_nullchars(block):
    """"""
    data = block.lstrip(b'\00')

    padding = b'\00' * ((len(block) - len(data)) % 8)

    return padding + data
1071969
def _q_to_dcm(self, q):
        
        assert(len(q) == 4)
        assert(np.allclose(QuaternionBase.norm_array(q), 1))
        dcm = np.zeros([3, 3])
        a = q[0]
        b = q[1]
        c = q[2]
        d = q[3]
        a_sq = a * a
        b_sq = b * b
        c_sq = c * c
        d_sq = d * d
        dcm[0][0] = a_sq + b_sq - c_sq - d_sq
        dcm[0][1] = 2 * (b * c - a * d)
        dcm[0][2] = 2 * (a * c + b * d)
        dcm[1][0] = 2 * (b * c + a * d)
        dcm[1][1] = a_sq - b_sq + c_sq - d_sq
        dcm[1][2] = 2 * (c * d - a * b)
        dcm[2][0] = 2 * (b * d - a * c)
        dcm[2][1] = 2 * (a * b + c * d)
        dcm[2][2] = a_sq - b_sq - c_sq + d_sq
        return dcm