repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java | QRDecompositionHouseholder_DDRB.setup | private void setup(DMatrixRBlock orig) {
blockLength = orig.blockLength;
dataW.blockLength = blockLength;
dataWTA.blockLength = blockLength;
this.dataA = orig;
A.original = dataA;
int l = Math.min(blockLength,orig.numCols);
dataW.reshape(orig.numRows,l,false);
dataWTA.reshape(l,orig.numRows,false);
Y.original = orig;
Y.row1 = W.row1 = orig.numRows;
if( temp.length < blockLength )
temp = new double[blockLength];
if( gammas.length < orig.numCols )
gammas = new double[ orig.numCols ];
if( saveW ) {
dataW.reshape(orig.numRows,orig.numCols,false);
}
} | java | private void setup(DMatrixRBlock orig) {
blockLength = orig.blockLength;
dataW.blockLength = blockLength;
dataWTA.blockLength = blockLength;
this.dataA = orig;
A.original = dataA;
int l = Math.min(blockLength,orig.numCols);
dataW.reshape(orig.numRows,l,false);
dataWTA.reshape(l,orig.numRows,false);
Y.original = orig;
Y.row1 = W.row1 = orig.numRows;
if( temp.length < blockLength )
temp = new double[blockLength];
if( gammas.length < orig.numCols )
gammas = new double[ orig.numCols ];
if( saveW ) {
dataW.reshape(orig.numRows,orig.numCols,false);
}
} | [
"private",
"void",
"setup",
"(",
"DMatrixRBlock",
"orig",
")",
"{",
"blockLength",
"=",
"orig",
".",
"blockLength",
";",
"dataW",
".",
"blockLength",
"=",
"blockLength",
";",
"dataWTA",
".",
"blockLength",
"=",
"blockLength",
";",
"this",
".",
"dataA",
"=",
... | Adjust submatrices and helper data structures for the input matrix. Must be called
before the decomposition can be computed.
@param orig | [
"Adjust",
"submatrices",
"and",
"helper",
"data",
"structures",
"for",
"the",
"input",
"matrix",
".",
"Must",
"be",
"called",
"before",
"the",
"decomposition",
"can",
"be",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java#L326-L347 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java | QRDecompositionHouseholder_DDRB.setW | private void setW() {
if( saveW ) {
W.col0 = Y.col0;
W.col1 = Y.col1;
W.row0 = Y.row0;
W.row1 = Y.row1;
} else {
W.col1 = Y.col1 - Y.col0;
W.row0 = Y.row0;
}
} | java | private void setW() {
if( saveW ) {
W.col0 = Y.col0;
W.col1 = Y.col1;
W.row0 = Y.row0;
W.row1 = Y.row1;
} else {
W.col1 = Y.col1 - Y.col0;
W.row0 = Y.row0;
}
} | [
"private",
"void",
"setW",
"(",
")",
"{",
"if",
"(",
"saveW",
")",
"{",
"W",
".",
"col0",
"=",
"Y",
".",
"col0",
";",
"W",
".",
"col1",
"=",
"Y",
".",
"col1",
";",
"W",
".",
"row0",
"=",
"Y",
".",
"row0",
";",
"W",
".",
"row1",
"=",
"Y",
... | Sets the submatrix of W up give Y is already configured and if it is being cached or not. | [
"Sets",
"the",
"submatrix",
"of",
"W",
"up",
"give",
"Y",
"is",
"already",
"configured",
"and",
"if",
"it",
"is",
"being",
"cached",
"or",
"not",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/decomposition/qr/QRDecompositionHouseholder_DDRB.java#L385-L395 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java | LinearSolverChol_ZDRM.solveInternalL | private void solveInternalL() {
// This takes advantage of the diagonal elements always being real numbers
// solve L*y=b storing y in x
TriangularSolver_ZDRM.solveL_diagReal(t, vv, n);
// solve L^T*x=y
TriangularSolver_ZDRM.solveConjTranL_diagReal(t, vv, n);
} | java | private void solveInternalL() {
// This takes advantage of the diagonal elements always being real numbers
// solve L*y=b storing y in x
TriangularSolver_ZDRM.solveL_diagReal(t, vv, n);
// solve L^T*x=y
TriangularSolver_ZDRM.solveConjTranL_diagReal(t, vv, n);
} | [
"private",
"void",
"solveInternalL",
"(",
")",
"{",
"// This takes advantage of the diagonal elements always being real numbers",
"// solve L*y=b storing y in x",
"TriangularSolver_ZDRM",
".",
"solveL_diagReal",
"(",
"t",
",",
"vv",
",",
"n",
")",
";",
"// solve L^T*x=y",
"Tr... | Used internally to find the solution to a single column vector. | [
"Used",
"internally",
"to",
"find",
"the",
"solution",
"to",
"a",
"single",
"column",
"vector",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java#L114-L122 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java | LinearSolverChol_ZDRM.invert | @Override
public void invert( ZMatrixRMaj inv ) {
if( inv.numRows != n || inv.numCols != n ) {
throw new RuntimeException("Unexpected matrix dimension");
}
if( inv.data == t ) {
throw new IllegalArgumentException("Passing in the same matrix that was decomposed.");
}
if(decomposer.isLower()) {
setToInverseL(inv.data);
} else {
throw new RuntimeException("Implement");
}
} | java | @Override
public void invert( ZMatrixRMaj inv ) {
if( inv.numRows != n || inv.numCols != n ) {
throw new RuntimeException("Unexpected matrix dimension");
}
if( inv.data == t ) {
throw new IllegalArgumentException("Passing in the same matrix that was decomposed.");
}
if(decomposer.isLower()) {
setToInverseL(inv.data);
} else {
throw new RuntimeException("Implement");
}
} | [
"@",
"Override",
"public",
"void",
"invert",
"(",
"ZMatrixRMaj",
"inv",
")",
"{",
"if",
"(",
"inv",
".",
"numRows",
"!=",
"n",
"||",
"inv",
".",
"numCols",
"!=",
"n",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected matrix dimension\"",
")"... | Sets the matrix 'inv' equal to the inverse of the matrix that was decomposed.
@param inv Where the value of the inverse will be stored. Modified. | [
"Sets",
"the",
"matrix",
"inv",
"equal",
"to",
"the",
"inverse",
"of",
"the",
"matrix",
"that",
"was",
"decomposed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/linsol/chol/LinearSolverChol_ZDRM.java#L129-L143 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.declareInternalData | public void declareInternalData(int maxRows, int maxCols) {
this.maxRows = maxRows;
this.maxCols = maxCols;
U_tran = new DMatrixRMaj(maxRows,maxRows);
Qm = new DMatrixRMaj(maxRows,maxRows);
r_row = new double[ maxCols ];
} | java | public void declareInternalData(int maxRows, int maxCols) {
this.maxRows = maxRows;
this.maxCols = maxCols;
U_tran = new DMatrixRMaj(maxRows,maxRows);
Qm = new DMatrixRMaj(maxRows,maxRows);
r_row = new double[ maxCols ];
} | [
"public",
"void",
"declareInternalData",
"(",
"int",
"maxRows",
",",
"int",
"maxCols",
")",
"{",
"this",
".",
"maxRows",
"=",
"maxRows",
";",
"this",
".",
"maxCols",
"=",
"maxCols",
";",
"U_tran",
"=",
"new",
"DMatrixRMaj",
"(",
"maxRows",
",",
"maxRows",
... | Declares the internal data structures so that it can process matrices up to the specified size.
@param maxRows
@param maxCols | [
"Declares",
"the",
"internal",
"data",
"structures",
"so",
"that",
"it",
"can",
"process",
"matrices",
"up",
"to",
"the",
"specified",
"size",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L114-L122 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.setQR | private void setQR(DMatrixRMaj Q , DMatrixRMaj R , int growRows ) {
if( Q.numRows != Q.numCols ) {
throw new IllegalArgumentException("Q should be square.");
}
this.Q = Q;
this.R = R;
m = Q.numRows;
n = R.numCols;
if( m+growRows > maxRows || n > maxCols ) {
if( autoGrow ) {
declareInternalData(m+growRows,n);
} else {
throw new IllegalArgumentException("Autogrow has been set to false and the maximum number of rows" +
" or columns has been exceeded.");
}
}
} | java | private void setQR(DMatrixRMaj Q , DMatrixRMaj R , int growRows ) {
if( Q.numRows != Q.numCols ) {
throw new IllegalArgumentException("Q should be square.");
}
this.Q = Q;
this.R = R;
m = Q.numRows;
n = R.numCols;
if( m+growRows > maxRows || n > maxCols ) {
if( autoGrow ) {
declareInternalData(m+growRows,n);
} else {
throw new IllegalArgumentException("Autogrow has been set to false and the maximum number of rows" +
" or columns has been exceeded.");
}
}
} | [
"private",
"void",
"setQR",
"(",
"DMatrixRMaj",
"Q",
",",
"DMatrixRMaj",
"R",
",",
"int",
"growRows",
")",
"{",
"if",
"(",
"Q",
".",
"numRows",
"!=",
"Q",
".",
"numCols",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Q should be square.\"",
... | Provides the results of a QR decomposition. These will be modified by adding or removing
rows from the original 'A' matrix.
@param Q The Q matrix which is to be modified. Is modified later and reference saved.
@param R The R matrix which is to be modified. Is modified later and reference saved. | [
"Provides",
"the",
"results",
"of",
"a",
"QR",
"decomposition",
".",
"These",
"will",
"be",
"modified",
"by",
"adding",
"or",
"removing",
"rows",
"from",
"the",
"original",
"A",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L215-L234 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.updateRemoveQ | private void updateRemoveQ( int rowIndex ) {
Qm.set(Q);
Q.reshape(m_m,m_m, false);
for( int i = 0; i < rowIndex; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[i*m_m+j-1] = sum;
}
}
for( int i = rowIndex+1; i < m; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[(i-1)*m_m+j-1] = sum;
}
}
} | java | private void updateRemoveQ( int rowIndex ) {
Qm.set(Q);
Q.reshape(m_m,m_m, false);
for( int i = 0; i < rowIndex; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[i*m_m+j-1] = sum;
}
}
for( int i = rowIndex+1; i < m; i++ ) {
for( int j = 1; j < m; j++ ) {
double sum = 0;
for( int k = 0; k < m; k++ ) {
sum += Qm.data[i*m+k]* U_tran.data[j*m+k];
}
Q.data[(i-1)*m_m+j-1] = sum;
}
}
} | [
"private",
"void",
"updateRemoveQ",
"(",
"int",
"rowIndex",
")",
"{",
"Qm",
".",
"set",
"(",
"Q",
")",
";",
"Q",
".",
"reshape",
"(",
"m_m",
",",
"m_m",
",",
"false",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowIndex",
";",
... | Updates the Q matrix to take inaccount the row that was removed by only multiplying e
lements that need to be. There is still some room for improvement here...
@param rowIndex | [
"Updates",
"the",
"Q",
"matrix",
"to",
"take",
"inaccount",
"the",
"row",
"that",
"was",
"removed",
"by",
"only",
"multiplying",
"e",
"lements",
"that",
"need",
"to",
"be",
".",
"There",
"is",
"still",
"some",
"room",
"for",
"improvement",
"here",
"..."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L275-L298 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java | QrUpdate_DDRM.updateRemoveR | private void updateRemoveR() {
for( int i = 1; i < n+1; i++ ) {
for( int j = 0; j < n; j++ ) {
double sum = 0;
for( int k = i-1; k <= j; k++ ) {
sum += U_tran.data[i*m+k] * R.data[k*n+j];
}
R.data[(i-1)*n+j] = sum;
}
}
} | java | private void updateRemoveR() {
for( int i = 1; i < n+1; i++ ) {
for( int j = 0; j < n; j++ ) {
double sum = 0;
for( int k = i-1; k <= j; k++ ) {
sum += U_tran.data[i*m+k] * R.data[k*n+j];
}
R.data[(i-1)*n+j] = sum;
}
}
} | [
"private",
"void",
"updateRemoveR",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"n",
"+",
"1",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"double",
"sum",
... | Updates the R matrix to take in account the removed row. | [
"Updates",
"the",
"R",
"matrix",
"to",
"take",
"in",
"account",
"the",
"removed",
"row",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/qr/QrUpdate_DDRM.java#L303-L313 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normalizeF | public static void normalizeF( DMatrixRMaj A ) {
double val = normF(A);
if( val == 0 )
return;
int size = A.getNumElements();
for( int i = 0; i < size; i++) {
A.div(i , val);
}
} | java | public static void normalizeF( DMatrixRMaj A ) {
double val = normF(A);
if( val == 0 )
return;
int size = A.getNumElements();
for( int i = 0; i < size; i++) {
A.div(i , val);
}
} | [
"public",
"static",
"void",
"normalizeF",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"double",
"val",
"=",
"normF",
"(",
"A",
")",
";",
"if",
"(",
"val",
"==",
"0",
")",
"return",
";",
"int",
"size",
"=",
"A",
".",
"getNumElements",
"(",
")",
";",
"for",
... | Normalizes the matrix such that the Frobenius norm is equal to one.
@param A The matrix that is to be normalized. | [
"Normalizes",
"the",
"matrix",
"such",
"that",
"the",
"Frobenius",
"norm",
"is",
"equal",
"to",
"one",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L71-L82 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP | public static double normP(DMatrixRMaj A , double p ) {
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return normP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return elementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | java | public static double normP(DMatrixRMaj A , double p ) {
if( p == 1 ) {
return normP1(A);
} else if( p == 2 ) {
return normP2(A);
} else if( Double.isInfinite(p)) {
return normPInf(A);
}
if( MatrixFeatures_DDRM.isVector(A) ) {
return elementP(A,p);
} else {
throw new IllegalArgumentException("Doesn't support induced norms yet.");
}
} | [
"public",
"static",
"double",
"normP",
"(",
"DMatrixRMaj",
"A",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"1",
")",
"{",
"return",
"normP1",
"(",
"A",
")",
";",
"}",
"else",
"if",
"(",
"p",
"==",
"2",
")",
"{",
"return",
"normP2",
"("... | Computes either the vector p-norm or the induced matrix p-norm depending on A
being a vector or a matrix respectively.
@param A Vector or matrix whose norm is to be computed.
@param p The p value of the p-norm.
@return The computed norm. | [
"Computes",
"either",
"the",
"vector",
"p",
"-",
"norm",
"or",
"the",
"induced",
"matrix",
"p",
"-",
"norm",
"depending",
"on",
"A",
"being",
"a",
"vector",
"or",
"a",
"matrix",
"respectively",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L285-L298 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP1 | public static double normP1( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return CommonOps_DDRM.elementSumAbs(A);
} else {
return inducedP1(A);
}
} | java | public static double normP1( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return CommonOps_DDRM.elementSumAbs(A);
} else {
return inducedP1(A);
}
} | [
"public",
"static",
"double",
"normP1",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"CommonOps_DDRM",
".",
"elementSumAbs",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"indu... | Computes the p=1 norm. If A is a matrix then the induced norm is computed.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"1",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L329-L335 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.normP2 | public static double normP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return normF(A);
} else {
return inducedP2(A);
}
} | java | public static double normP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return normF(A);
} else {
return inducedP2(A);
}
} | [
"public",
"static",
"double",
"normP2",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"normF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"inducedP2",
"(",
"A",
")",
";",... | Computes the p=2 norm. If A is a matrix then the induced norm is computed.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"2",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L343-L349 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.fastNormP2 | public static double fastNormP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return fastNormF(A);
} else {
return inducedP2(A);
}
} | java | public static double fastNormP2( DMatrixRMaj A ) {
if( MatrixFeatures_DDRM.isVector(A)) {
return fastNormF(A);
} else {
return inducedP2(A);
}
} | [
"public",
"static",
"double",
"fastNormP2",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"MatrixFeatures_DDRM",
".",
"isVector",
"(",
"A",
")",
")",
"{",
"return",
"fastNormF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"return",
"inducedP2",
"(",
"A",
")"... | Computes the p=2 norm. If A is a matrix then the induced norm is computed. This
implementation is faster, but more prone to buffer overflow or underflow problems.
@param A Matrix or vector.
@return The norm. | [
"Computes",
"the",
"p",
"=",
"2",
"norm",
".",
"If",
"A",
"is",
"a",
"matrix",
"then",
"the",
"induced",
"norm",
"is",
"computed",
".",
"This",
"implementation",
"is",
"faster",
"but",
"more",
"prone",
"to",
"buffer",
"overflow",
"or",
"underflow",
"prob... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L358-L364 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ReadCsv.java | ReadCsv.extractWords | protected List<String> extractWords() throws IOException
{
while( true ) {
lineNumber++;
String line = in.readLine();
if( line == null ) {
return null;
}
// skip comment lines
if( hasComment ) {
if( line.charAt(0) == comment )
continue;
}
// extract the words, which are the variables encoded
return parseWords(line);
}
} | java | protected List<String> extractWords() throws IOException
{
while( true ) {
lineNumber++;
String line = in.readLine();
if( line == null ) {
return null;
}
// skip comment lines
if( hasComment ) {
if( line.charAt(0) == comment )
continue;
}
// extract the words, which are the variables encoded
return parseWords(line);
}
} | [
"protected",
"List",
"<",
"String",
">",
"extractWords",
"(",
")",
"throws",
"IOException",
"{",
"while",
"(",
"true",
")",
"{",
"lineNumber",
"++",
";",
"String",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")... | Finds the next valid line of words in the stream and extracts them.
@return List of valid words on the line. null if the end of the file has been reached.
@throws java.io.IOException | [
"Finds",
"the",
"next",
"valid",
"line",
"of",
"words",
"in",
"the",
"stream",
"and",
"extracts",
"them",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ReadCsv.java#L96-L114 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ReadCsv.java | ReadCsv.parseWords | protected List<String> parseWords(String line) {
List<String> words = new ArrayList<String>();
boolean insideWord = !isSpace(line.charAt(0));
int last = 0;
for( int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if( insideWord ) {
// see if its at the end of a word
if( isSpace(c)) {
words.add( line.substring(last,i) );
insideWord = false;
}
} else {
if( !isSpace(c)) {
last = i;
insideWord = true;
}
}
}
// if the line ended add the final word
if( insideWord ) {
words.add( line.substring(last));
}
return words;
} | java | protected List<String> parseWords(String line) {
List<String> words = new ArrayList<String>();
boolean insideWord = !isSpace(line.charAt(0));
int last = 0;
for( int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if( insideWord ) {
// see if its at the end of a word
if( isSpace(c)) {
words.add( line.substring(last,i) );
insideWord = false;
}
} else {
if( !isSpace(c)) {
last = i;
insideWord = true;
}
}
}
// if the line ended add the final word
if( insideWord ) {
words.add( line.substring(last));
}
return words;
} | [
"protected",
"List",
"<",
"String",
">",
"parseWords",
"(",
"String",
"line",
")",
"{",
"List",
"<",
"String",
">",
"words",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"boolean",
"insideWord",
"=",
"!",
"isSpace",
"(",
"line",
".",
"... | Extracts the words from a string. Words are seperated by a space character.
@param line The line that is being parsed.
@return A list of words contained on the line. | [
"Extracts",
"the",
"words",
"from",
"a",
"string",
".",
"Words",
"are",
"seperated",
"by",
"a",
"space",
"character",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ReadCsv.java#L122-L148 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.findMax | public static double findMax( double[] u, int startU , int length ) {
double max = -1;
int index = startU*2;
int stopIndex = (startU + length)*2;
for( ; index < stopIndex;) {
double real = u[index++];
double img = u[index++];
double val = real*real + img*img;
if( val > max ) {
max = val;
}
}
return Math.sqrt(max);
} | java | public static double findMax( double[] u, int startU , int length ) {
double max = -1;
int index = startU*2;
int stopIndex = (startU + length)*2;
for( ; index < stopIndex;) {
double real = u[index++];
double img = u[index++];
double val = real*real + img*img;
if( val > max ) {
max = val;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"findMax",
"(",
"double",
"[",
"]",
"u",
",",
"int",
"startU",
",",
"int",
"length",
")",
"{",
"double",
"max",
"=",
"-",
"1",
";",
"int",
"index",
"=",
"startU",
"*",
"2",
";",
"int",
"stopIndex",
"=",
"(",
"startU",
... | Returns the maximum magnitude of the complex numbers
@param u Array of complex numbers
@param startU first index to consider in u
@param length Number of complex numebrs to consider
@return magnitude | [
"Returns",
"the",
"maximum",
"magnitude",
"of",
"the",
"complex",
"numbers"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L55-L72 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractHouseholderColumn | public static void extractHouseholderColumn( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU )
{
int indexU = (row0+offsetU)*2;
u[indexU++] = 1;
u[indexU++] = 0;
for (int row = row0+1; row < row1; row++) {
int indexA = A.getIndex(row,col);
u[indexU++] = A.data[indexA];
u[indexU++] = A.data[indexA+1];
}
} | java | public static void extractHouseholderColumn( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU )
{
int indexU = (row0+offsetU)*2;
u[indexU++] = 1;
u[indexU++] = 0;
for (int row = row0+1; row < row1; row++) {
int indexA = A.getIndex(row,col);
u[indexU++] = A.data[indexA];
u[indexU++] = A.data[indexA+1];
}
} | [
"public",
"static",
"void",
"extractHouseholderColumn",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row0",
",",
"int",
"row1",
",",
"int",
"col",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"row0",
"+",
"offsetU"... | Extracts a house holder vector from the column of A and stores it in u
@param A Complex matrix with householder vectors stored in the lower left triangle
@param row0 first row in A (implicitly assumed to be r + i0)
@param row1 last row + 1 in A
@param col Column in A
@param u Output array storage
@param offsetU first index in U | [
"Extracts",
"a",
"house",
"holder",
"vector",
"from",
"the",
"column",
"of",
"A",
"and",
"stores",
"it",
"in",
"u"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L319-L332 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractHouseholderRow | public static void extractHouseholderRow( ZMatrixRMaj A ,
int row ,
int col0, int col1 , double u[], int offsetU )
{
int indexU = (offsetU+col0)*2;
u[indexU] = 1;
u[indexU+1] = 0;
int indexA = (row*A.numCols + (col0+1))*2;
System.arraycopy(A.data,indexA,u,indexU+2,(col1-col0-1)*2);
} | java | public static void extractHouseholderRow( ZMatrixRMaj A ,
int row ,
int col0, int col1 , double u[], int offsetU )
{
int indexU = (offsetU+col0)*2;
u[indexU] = 1;
u[indexU+1] = 0;
int indexA = (row*A.numCols + (col0+1))*2;
System.arraycopy(A.data,indexA,u,indexU+2,(col1-col0-1)*2);
} | [
"public",
"static",
"void",
"extractHouseholderRow",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row",
",",
"int",
"col0",
",",
"int",
"col1",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"offsetU",
"+",
"col0",
... | Extracts a house holder vector from the rows of A and stores it in u
@param A Complex matrix with householder vectors stored in the upper right triangle
@param row Row in A
@param col0 first row in A (implicitly assumed to be r + i0)
@param col1 last row +1 in A
@param u Output array storage
@param offsetU first index in U | [
"Extracts",
"a",
"house",
"holder",
"vector",
"from",
"the",
"rows",
"of",
"A",
"and",
"stores",
"it",
"in",
"u"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L343-L353 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.extractColumnAndMax | public static double extractColumnAndMax( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU) {
int indexU = (offsetU+row0)*2;
// find the largest value in this column
// this is used to normalize the column and mitigate overflow/underflow
double max = 0;
int indexA = A.getIndex(row0,col);
double h[] = A.data;
for( int i = row0; i < row1; i++, indexA += A.numCols*2 ) {
// copy the householder vector to an array to reduce cache misses
// big improvement on larger matrices and a relatively small performance hit on small matrices.
double realVal = u[indexU++] = h[indexA];
double imagVal = u[indexU++] = h[indexA+1];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | java | public static double extractColumnAndMax( ZMatrixRMaj A ,
int row0 , int row1 ,
int col , double u[], int offsetU) {
int indexU = (offsetU+row0)*2;
// find the largest value in this column
// this is used to normalize the column and mitigate overflow/underflow
double max = 0;
int indexA = A.getIndex(row0,col);
double h[] = A.data;
for( int i = row0; i < row1; i++, indexA += A.numCols*2 ) {
// copy the householder vector to an array to reduce cache misses
// big improvement on larger matrices and a relatively small performance hit on small matrices.
double realVal = u[indexU++] = h[indexA];
double imagVal = u[indexU++] = h[indexA+1];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"extractColumnAndMax",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row0",
",",
"int",
"row1",
",",
"int",
"col",
",",
"double",
"u",
"[",
"]",
",",
"int",
"offsetU",
")",
"{",
"int",
"indexU",
"=",
"(",
"offsetU",
"+",
"row0",
... | Extracts the column of A and copies it into u while computing the magnitude of the
largest element and returning it.
<pre>
u[ (offsetU+row0+i)*2 ] = A.getReal(row0+i,col)
u[ (offsetU+row0+i)*2 + 1] = A.getImag(row0+i,col)
</pre>
@param A Complex matrix
@param row0 First row in A to be copied
@param row1 Last row in A + 1 to be copied
@param col Column in A
@param u Output array storage
@param offsetU first index in U
@return magnitude of largest element | [
"Extracts",
"the",
"column",
"of",
"A",
"and",
"copies",
"it",
"into",
"u",
"while",
"computing",
"the",
"magnitude",
"of",
"the",
"largest",
"element",
"and",
"returning",
"it",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L372-L396 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java | QrHelperFunctions_ZDRM.computeRowMax | public static double computeRowMax( ZMatrixRMaj A ,
int row , int col0 , int col1 ) {
double max = 0;
int indexA = A.getIndex(row,col0);
double h[] = A.data;
for (int i = col0; i < col1; i++) {
double realVal = h[indexA++];
double imagVal = h[indexA++];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | java | public static double computeRowMax( ZMatrixRMaj A ,
int row , int col0 , int col1 ) {
double max = 0;
int indexA = A.getIndex(row,col0);
double h[] = A.data;
for (int i = col0; i < col1; i++) {
double realVal = h[indexA++];
double imagVal = h[indexA++];
double magVal = realVal*realVal + imagVal*imagVal;
if( max < magVal ) {
max = magVal;
}
}
return Math.sqrt(max);
} | [
"public",
"static",
"double",
"computeRowMax",
"(",
"ZMatrixRMaj",
"A",
",",
"int",
"row",
",",
"int",
"col0",
",",
"int",
"col1",
")",
"{",
"double",
"max",
"=",
"0",
";",
"int",
"indexA",
"=",
"A",
".",
"getIndex",
"(",
"row",
",",
"col0",
")",
"... | Finds the magnitude of the largest element in the row
@param A Complex matrix
@param row Row in A
@param col0 First column in A to be copied
@param col1 Last column in A + 1 to be copied
@return magnitude of largest element | [
"Finds",
"the",
"magnitude",
"of",
"the",
"largest",
"element",
"in",
"the",
"row"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/qr/QrHelperFunctions_ZDRM.java#L406-L423 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java | RandomMatrices_ZDRM.hermitian | public static ZMatrixRMaj hermitian(int length, double min, double max, Random rand) {
ZMatrixRMaj A = new ZMatrixRMaj(length,length);
fillHermitian(A, min, max, rand);
return A;
} | java | public static ZMatrixRMaj hermitian(int length, double min, double max, Random rand) {
ZMatrixRMaj A = new ZMatrixRMaj(length,length);
fillHermitian(A, min, max, rand);
return A;
} | [
"public",
"static",
"ZMatrixRMaj",
"hermitian",
"(",
"int",
"length",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"ZMatrixRMaj",
"A",
"=",
"new",
"ZMatrixRMaj",
"(",
"length",
",",
"length",
")",
";",
"fillHermitian",
"(",
... | Creates a random Hermitian matrix with elements from min to max value.
@param length Width and height of the matrix.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator.
@return A symmetric matrix. | [
"Creates",
"a",
"random",
"Hermitian",
"matrix",
"with",
"elements",
"from",
"min",
"to",
"max",
"value",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java#L135-L141 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java | RandomMatrices_ZDRM.fillHermitian | public static void fillHermitian(ZMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
A.set(i,i,rand.nextDouble()*range + min,0);
for( int j = i+1; j < length; j++ ) {
double real = rand.nextDouble()*range + min;
double imaginary = rand.nextDouble()*range + min;
A.set(i,j,real,imaginary);
A.set(j,i,real,-imaginary);
}
}
} | java | public static void fillHermitian(ZMatrixRMaj A, double min, double max, Random rand) {
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be a square matrix");
double range = max-min;
int length = A.numRows;
for( int i = 0; i < length; i++ ) {
A.set(i,i,rand.nextDouble()*range + min,0);
for( int j = i+1; j < length; j++ ) {
double real = rand.nextDouble()*range + min;
double imaginary = rand.nextDouble()*range + min;
A.set(i,j,real,imaginary);
A.set(j,i,real,-imaginary);
}
}
} | [
"public",
"static",
"void",
"fillHermitian",
"(",
"ZMatrixRMaj",
"A",
",",
"double",
"min",
",",
"double",
"max",
",",
"Random",
"rand",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
... | Assigns the provided square matrix to be a random Hermitian matrix with elements from min to max value.
@param A The matrix that is to be modified. Must be square. Modified.
@param min Minimum value an element can have.
@param max Maximum value an element can have.
@param rand Random number generator. | [
"Assigns",
"the",
"provided",
"square",
"matrix",
"to",
"be",
"a",
"random",
"Hermitian",
"matrix",
"with",
"elements",
"from",
"min",
"to",
"max",
"value",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/RandomMatrices_ZDRM.java#L151-L169 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java | SimpleMatrix.wrap | public static SimpleMatrix wrap( Matrix internalMat ) {
SimpleMatrix ret = new SimpleMatrix();
ret.setMatrix(internalMat);
return ret;
} | java | public static SimpleMatrix wrap( Matrix internalMat ) {
SimpleMatrix ret = new SimpleMatrix();
ret.setMatrix(internalMat);
return ret;
} | [
"public",
"static",
"SimpleMatrix",
"wrap",
"(",
"Matrix",
"internalMat",
")",
"{",
"SimpleMatrix",
"ret",
"=",
"new",
"SimpleMatrix",
"(",
")",
";",
"ret",
".",
"setMatrix",
"(",
"internalMat",
")",
";",
"return",
"ret",
";",
"}"
] | Creates a new SimpleMatrix with the specified DMatrixRMaj used as its internal matrix. This means
that the reference is saved and calls made to the returned SimpleMatrix will modify the passed in DMatrixRMaj.
@param internalMat The internal DMatrixRMaj of the returned SimpleMatrix. Will be modified. | [
"Creates",
"a",
"new",
"SimpleMatrix",
"with",
"the",
"specified",
"DMatrixRMaj",
"used",
"as",
"its",
"internal",
"matrix",
".",
"This",
"means",
"that",
"the",
"reference",
"is",
"saved",
"and",
"calls",
"made",
"to",
"the",
"returned",
"SimpleMatrix",
"will... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java#L221-L225 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java | SimpleMatrix.diag | public static SimpleMatrix diag( Class type, double ...vals ) {
SimpleMatrix M = new SimpleMatrix(vals.length,vals.length,type);
for (int i = 0; i < vals.length; i++) {
M.set(i,i,vals[i]);
}
return M;
} | java | public static SimpleMatrix diag( Class type, double ...vals ) {
SimpleMatrix M = new SimpleMatrix(vals.length,vals.length,type);
for (int i = 0; i < vals.length; i++) {
M.set(i,i,vals[i]);
}
return M;
} | [
"public",
"static",
"SimpleMatrix",
"diag",
"(",
"Class",
"type",
",",
"double",
"...",
"vals",
")",
"{",
"SimpleMatrix",
"M",
"=",
"new",
"SimpleMatrix",
"(",
"vals",
".",
"length",
",",
"vals",
".",
"length",
",",
"type",
")",
";",
"for",
"(",
"int",... | Creates a real valued diagonal matrix of the specified type | [
"Creates",
"a",
"real",
"valued",
"diagonal",
"matrix",
"of",
"the",
"specified",
"type"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleMatrix.java#L269-L275 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java | CommonOps_ZDRM.convert | public static void convert(DMatrixD1 input , ZMatrixD1 output ) {
if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
Arrays.fill(output.data, 0, output.getDataLength(), 0);
final int length = output.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i] = input.data[i/2];
}
} | java | public static void convert(DMatrixD1 input , ZMatrixD1 output ) {
if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
Arrays.fill(output.data, 0, output.getDataLength(), 0);
final int length = output.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i] = input.data[i/2];
}
} | [
"public",
"static",
"void",
"convert",
"(",
"DMatrixD1",
"input",
",",
"ZMatrixD1",
"output",
")",
"{",
"if",
"(",
"input",
".",
"numCols",
"!=",
"output",
".",
"numCols",
"||",
"input",
".",
"numRows",
"!=",
"output",
".",
"numRows",
")",
"{",
"throw",
... | Converts the real matrix into a complex matrix.
@param input Real matrix. Not modified.
@param output Complex matrix. Modified. | [
"Converts",
"the",
"real",
"matrix",
"into",
"a",
"complex",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java#L144-L156 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java | CommonOps_ZDRM.stripReal | public static DMatrixRMaj stripReal(ZMatrixD1 input , DMatrixRMaj output ) {
if( output == null ) {
output = new DMatrixRMaj(input.numRows,input.numCols);
} else if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
final int length = input.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i/2] = input.data[i];
}
return output;
} | java | public static DMatrixRMaj stripReal(ZMatrixD1 input , DMatrixRMaj output ) {
if( output == null ) {
output = new DMatrixRMaj(input.numRows,input.numCols);
} else if( input.numCols != output.numCols || input.numRows != output.numRows ) {
throw new IllegalArgumentException("The matrices are not all the same dimension.");
}
final int length = input.getDataLength();
for( int i = 0; i < length; i += 2 ) {
output.data[i/2] = input.data[i];
}
return output;
} | [
"public",
"static",
"DMatrixRMaj",
"stripReal",
"(",
"ZMatrixD1",
"input",
",",
"DMatrixRMaj",
"output",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"output",
"=",
"new",
"DMatrixRMaj",
"(",
"input",
".",
"numRows",
",",
"input",
".",
"numCols",... | Places the real component of the input matrix into the output matrix.
@param input Complex matrix. Not modified.
@param output real matrix. Modified. | [
"Places",
"the",
"real",
"component",
"of",
"the",
"input",
"matrix",
"into",
"the",
"output",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/CommonOps_ZDRM.java#L164-L177 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.convert | public static DMatrixRMaj convert(DMatrixRBlock src , DMatrixRMaj dst )
{
return ConvertDMatrixStruct.convert(src,dst);
} | java | public static DMatrixRMaj convert(DMatrixRBlock src , DMatrixRMaj dst )
{
return ConvertDMatrixStruct.convert(src,dst);
} | [
"public",
"static",
"DMatrixRMaj",
"convert",
"(",
"DMatrixRBlock",
"src",
",",
"DMatrixRMaj",
"dst",
")",
"{",
"return",
"ConvertDMatrixStruct",
".",
"convert",
"(",
"src",
",",
"dst",
")",
";",
"}"
] | Converts a row major block matrix into a row major matrix.
@param src Original DMatrixRBlock.. Not modified.
@param dst Equivalent DMatrixRMaj. Modified. | [
"Converts",
"a",
"row",
"major",
"block",
"matrix",
"into",
"a",
"row",
"major",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L96-L99 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.convertTranSrc | public static void convertTranSrc(DMatrixRMaj src , DMatrixRBlock dst )
{
if( src.numRows != dst.numCols || src.numCols != dst.numRows )
throw new IllegalArgumentException("Incompatible matrix shapes.");
for( int i = 0; i < dst.numRows; i += dst.blockLength ) {
int blockHeight = Math.min( dst.blockLength , dst.numRows - i);
for( int j = 0; j < dst.numCols; j += dst.blockLength ) {
int blockWidth = Math.min( dst.blockLength , dst.numCols - j);
int indexDst = i*dst.numCols + blockHeight*j;
int indexSrc = j*src.numCols + i;
for( int l = 0; l < blockWidth; l++ ) {
int rowSrc = indexSrc + l*src.numCols;
int rowDst = indexDst + l;
for( int k = 0; k < blockHeight; k++ , rowDst += blockWidth ) {
dst.data[ rowDst ] = src.data[rowSrc++];
}
}
}
}
} | java | public static void convertTranSrc(DMatrixRMaj src , DMatrixRBlock dst )
{
if( src.numRows != dst.numCols || src.numCols != dst.numRows )
throw new IllegalArgumentException("Incompatible matrix shapes.");
for( int i = 0; i < dst.numRows; i += dst.blockLength ) {
int blockHeight = Math.min( dst.blockLength , dst.numRows - i);
for( int j = 0; j < dst.numCols; j += dst.blockLength ) {
int blockWidth = Math.min( dst.blockLength , dst.numCols - j);
int indexDst = i*dst.numCols + blockHeight*j;
int indexSrc = j*src.numCols + i;
for( int l = 0; l < blockWidth; l++ ) {
int rowSrc = indexSrc + l*src.numCols;
int rowDst = indexDst + l;
for( int k = 0; k < blockHeight; k++ , rowDst += blockWidth ) {
dst.data[ rowDst ] = src.data[rowSrc++];
}
}
}
}
} | [
"public",
"static",
"void",
"convertTranSrc",
"(",
"DMatrixRMaj",
"src",
",",
"DMatrixRBlock",
"dst",
")",
"{",
"if",
"(",
"src",
".",
"numRows",
"!=",
"dst",
".",
"numCols",
"||",
"src",
".",
"numCols",
"!=",
"dst",
".",
"numRows",
")",
"throw",
"new",
... | Converts the transpose of a row major matrix into a row major block matrix.
@param src Original DMatrixRMaj. Not modified.
@param dst Equivalent DMatrixRBlock. Modified. | [
"Converts",
"the",
"transpose",
"of",
"a",
"row",
"major",
"matrix",
"into",
"a",
"row",
"major",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L146-L169 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.transpose | public static DMatrixRBlock transpose(DMatrixRBlock A , DMatrixRBlock A_tran )
{
if( A_tran != null ) {
if( A.numRows != A_tran.numCols || A.numCols != A_tran.numRows )
throw new IllegalArgumentException("Incompatible dimensions.");
if( A.blockLength != A_tran.blockLength )
throw new IllegalArgumentException("Incompatible block size.");
} else {
A_tran = new DMatrixRBlock(A.numCols,A.numRows,A.blockLength);
}
for( int i = 0; i < A.numRows; i += A.blockLength ) {
int blockHeight = Math.min( A.blockLength , A.numRows - i);
for( int j = 0; j < A.numCols; j += A.blockLength ) {
int blockWidth = Math.min( A.blockLength , A.numCols - j);
int indexA = i*A.numCols + blockHeight*j;
int indexC = j*A_tran.numCols + blockWidth*i;
transposeBlock( A , A_tran , indexA , indexC , blockWidth , blockHeight );
}
}
return A_tran;
} | java | public static DMatrixRBlock transpose(DMatrixRBlock A , DMatrixRBlock A_tran )
{
if( A_tran != null ) {
if( A.numRows != A_tran.numCols || A.numCols != A_tran.numRows )
throw new IllegalArgumentException("Incompatible dimensions.");
if( A.blockLength != A_tran.blockLength )
throw new IllegalArgumentException("Incompatible block size.");
} else {
A_tran = new DMatrixRBlock(A.numCols,A.numRows,A.blockLength);
}
for( int i = 0; i < A.numRows; i += A.blockLength ) {
int blockHeight = Math.min( A.blockLength , A.numRows - i);
for( int j = 0; j < A.numCols; j += A.blockLength ) {
int blockWidth = Math.min( A.blockLength , A.numCols - j);
int indexA = i*A.numCols + blockHeight*j;
int indexC = j*A_tran.numCols + blockWidth*i;
transposeBlock( A , A_tran , indexA , indexC , blockWidth , blockHeight );
}
}
return A_tran;
} | [
"public",
"static",
"DMatrixRBlock",
"transpose",
"(",
"DMatrixRBlock",
"A",
",",
"DMatrixRBlock",
"A_tran",
")",
"{",
"if",
"(",
"A_tran",
"!=",
"null",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A_tran",
".",
"numCols",
"||",
"A",
".",
"numCols",... | Transposes a block matrix.
@param A Original matrix. Not modified.
@param A_tran Transposed matrix. Modified. | [
"Transposes",
"a",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L239-L265 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.transposeBlock | private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
int indexA , int indexC ,
int width , int height )
{
for( int i = 0; i < height; i++ ) {
int rowIndexC = indexC + i;
int rowIndexA = indexA + width*i;
int end = rowIndexA + width;
for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
}
}
} | java | private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
int indexA , int indexC ,
int width , int height )
{
for( int i = 0; i < height; i++ ) {
int rowIndexC = indexC + i;
int rowIndexA = indexA + width*i;
int end = rowIndexA + width;
for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
}
}
} | [
"private",
"static",
"void",
"transposeBlock",
"(",
"DMatrixRBlock",
"A",
",",
"DMatrixRBlock",
"A_tran",
",",
"int",
"indexA",
",",
"int",
"indexC",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | Transposes an individual block inside a block matrix. | [
"Transposes",
"an",
"individual",
"block",
"inside",
"a",
"block",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L270-L282 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.zeroTriangle | public static void zeroTriangle( boolean upper , DMatrixRBlock A )
{
int blockLength = A.blockLength;
if( upper ) {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = i; j < A.numCols; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
for( int l = k+1; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
} else {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = 0; j <= i; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
int z = Math.min(k,w);
for( int l = 0; l < z; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
}
} | java | public static void zeroTriangle( boolean upper , DMatrixRBlock A )
{
int blockLength = A.blockLength;
if( upper ) {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = i; j < A.numCols; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
for( int l = k+1; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
} else {
for( int i = 0; i < A.numRows; i += blockLength ) {
int h = Math.min(blockLength,A.numRows-i);
for( int j = 0; j <= i; j += blockLength ) {
int w = Math.min(blockLength,A.numCols-j);
int index = i*A.numCols + h*j;
if( j == i ) {
for( int k = 0; k < h; k++ ) {
int z = Math.min(k,w);
for( int l = 0; l < z; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
} else {
for( int k = 0; k < h; k++ ) {
for( int l = 0; l < w; l++ ) {
A.data[index + w*k+l ] = 0;
}
}
}
}
}
}
} | [
"public",
"static",
"void",
"zeroTriangle",
"(",
"boolean",
"upper",
",",
"DMatrixRBlock",
"A",
")",
"{",
"int",
"blockLength",
"=",
"A",
".",
"blockLength",
";",
"if",
"(",
"upper",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
"... | Sets either the upper or low triangle of a matrix to zero | [
"Sets",
"either",
"the",
"upper",
"or",
"low",
"triangle",
"of",
"a",
"matrix",
"to",
"zero"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L337-L391 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java | MatrixOps_DDRB.blockAligned | public static boolean blockAligned( int blockLength , DSubmatrixD1 A ) {
if( A.col0 % blockLength != 0 )
return false;
if( A.row0 % blockLength != 0 )
return false;
if( A.col1 % blockLength != 0 && A.col1 != A.original.numCols ) {
return false;
}
if( A.row1 % blockLength != 0 && A.row1 != A.original.numRows) {
return false;
}
return true;
} | java | public static boolean blockAligned( int blockLength , DSubmatrixD1 A ) {
if( A.col0 % blockLength != 0 )
return false;
if( A.row0 % blockLength != 0 )
return false;
if( A.col1 % blockLength != 0 && A.col1 != A.original.numCols ) {
return false;
}
if( A.row1 % blockLength != 0 && A.row1 != A.original.numRows) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"blockAligned",
"(",
"int",
"blockLength",
",",
"DSubmatrixD1",
"A",
")",
"{",
"if",
"(",
"A",
".",
"col0",
"%",
"blockLength",
"!=",
"0",
")",
"return",
"false",
";",
"if",
"(",
"A",
".",
"row0",
"%",
"blockLength",
"!="... | Checks to see if the submatrix has its boundaries along inner blocks.
@param blockLength Size of an inner block.
@param A Submatrix.
@return If it is block aligned or not. | [
"Checks",
"to",
"see",
"if",
"the",
"submatrix",
"has",
"its",
"boundaries",
"along",
"inner",
"blocks",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/block/MatrixOps_DDRB.java#L604-L619 | train |
lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_Ultimate.java | SvdImplicitQrDecompose_Ultimate.makeSingularPositive | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = singularValues[i];
if( val < 0 ) {
singularValues[i] = -val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.data[j] = -Ut.data[j];
}
}
}
}
} | java | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = singularValues[i];
if( val < 0 ) {
singularValues[i] = -val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.data[j] = -Ut.data[j];
}
}
}
}
} | [
"private",
"void",
"makeSingularPositive",
"(",
")",
"{",
"numSingular",
"=",
"qralg",
".",
"getNumberOfSingularValues",
"(",
")",
";",
"singularValues",
"=",
"qralg",
".",
"getSingularValues",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<"... | With the QR algorithm it is possible for the found singular values to be native. This
makes them all positive by multiplying it by a diagonal matrix that has | [
"With",
"the",
"QR",
"algorithm",
"it",
"is",
"possible",
"for",
"the",
"found",
"singular",
"values",
"to",
"be",
"native",
".",
"This",
"makes",
"them",
"all",
"positive",
"by",
"multiplying",
"it",
"by",
"a",
"diagonal",
"matrix",
"that",
"has"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_Ultimate.java#L279-L301 | train |
lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.fit | public void fit( double samplePoints[] , double[] observations ) {
// Create a copy of the observations and put it into a matrix
y.reshape(observations.length,1,false);
System.arraycopy(observations,0, y.data,0,observations.length);
// reshape the matrix to avoid unnecessarily declaring new memory
// save values is set to false since its old values don't matter
A.reshape(y.numRows, coef.numRows,false);
// set up the A matrix
for( int i = 0; i < observations.length; i++ ) {
double obs = 1;
for( int j = 0; j < coef.numRows; j++ ) {
A.set(i,j,obs);
obs *= samplePoints[i];
}
}
// process the A matrix and see if it failed
if( !solver.setA(A) )
throw new RuntimeException("Solver failed");
// solver the the coefficients
solver.solve(y,coef);
} | java | public void fit( double samplePoints[] , double[] observations ) {
// Create a copy of the observations and put it into a matrix
y.reshape(observations.length,1,false);
System.arraycopy(observations,0, y.data,0,observations.length);
// reshape the matrix to avoid unnecessarily declaring new memory
// save values is set to false since its old values don't matter
A.reshape(y.numRows, coef.numRows,false);
// set up the A matrix
for( int i = 0; i < observations.length; i++ ) {
double obs = 1;
for( int j = 0; j < coef.numRows; j++ ) {
A.set(i,j,obs);
obs *= samplePoints[i];
}
}
// process the A matrix and see if it failed
if( !solver.setA(A) )
throw new RuntimeException("Solver failed");
// solver the the coefficients
solver.solve(y,coef);
} | [
"public",
"void",
"fit",
"(",
"double",
"samplePoints",
"[",
"]",
",",
"double",
"[",
"]",
"observations",
")",
"{",
"// Create a copy of the observations and put it into a matrix",
"y",
".",
"reshape",
"(",
"observations",
".",
"length",
",",
"1",
",",
"false",
... | Computes the best fit set of polynomial coefficients to the provided observations.
@param samplePoints where the observations were sampled.
@param observations A set of observations. | [
"Computes",
"the",
"best",
"fit",
"set",
"of",
"polynomial",
"coefficients",
"to",
"the",
"provided",
"observations",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L82-L108 | train |
lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.removeWorstFit | public void removeWorstFit() {
// find the observation with the most error
int worstIndex=-1;
double worstError = -1;
for( int i = 0; i < y.numRows; i++ ) {
double predictedObs = 0;
for( int j = 0; j < coef.numRows; j++ ) {
predictedObs += A.get(i,j)*coef.get(j,0);
}
double error = Math.abs(predictedObs- y.get(i,0));
if( error > worstError ) {
worstError = error;
worstIndex = i;
}
}
// nothing left to remove, so just return
if( worstIndex == -1 )
return;
// remove that observation
removeObservation(worstIndex);
// update A
solver.removeRowFromA(worstIndex);
// solve for the parameters again
solver.solve(y,coef);
} | java | public void removeWorstFit() {
// find the observation with the most error
int worstIndex=-1;
double worstError = -1;
for( int i = 0; i < y.numRows; i++ ) {
double predictedObs = 0;
for( int j = 0; j < coef.numRows; j++ ) {
predictedObs += A.get(i,j)*coef.get(j,0);
}
double error = Math.abs(predictedObs- y.get(i,0));
if( error > worstError ) {
worstError = error;
worstIndex = i;
}
}
// nothing left to remove, so just return
if( worstIndex == -1 )
return;
// remove that observation
removeObservation(worstIndex);
// update A
solver.removeRowFromA(worstIndex);
// solve for the parameters again
solver.solve(y,coef);
} | [
"public",
"void",
"removeWorstFit",
"(",
")",
"{",
"// find the observation with the most error",
"int",
"worstIndex",
"=",
"-",
"1",
";",
"double",
"worstError",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"y",
".",
"numRows",
"... | Removes the observation that fits the model the worst and recomputes the coefficients.
This is done efficiently by using an adjustable solver. Often times the elements with
the largest errors are outliers and not part of the system being modeled. By removing them
a more accurate set of coefficients can be computed. | [
"Removes",
"the",
"observation",
"that",
"fits",
"the",
"model",
"the",
"worst",
"and",
"recomputes",
"the",
"coefficients",
".",
"This",
"is",
"done",
"efficiently",
"by",
"using",
"an",
"adjustable",
"solver",
".",
"Often",
"times",
"the",
"elements",
"with"... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L116-L148 | train |
lessthanoptimal/ejml | examples/src/org/ejml/example/PolynomialFit.java | PolynomialFit.removeObservation | private void removeObservation( int index ) {
final int N = y.numRows-1;
final double d[] = y.data;
// shift
for( int i = index; i < N; i++ ) {
d[i] = d[i+1];
}
y.numRows--;
} | java | private void removeObservation( int index ) {
final int N = y.numRows-1;
final double d[] = y.data;
// shift
for( int i = index; i < N; i++ ) {
d[i] = d[i+1];
}
y.numRows--;
} | [
"private",
"void",
"removeObservation",
"(",
"int",
"index",
")",
"{",
"final",
"int",
"N",
"=",
"y",
".",
"numRows",
"-",
"1",
";",
"final",
"double",
"d",
"[",
"]",
"=",
"y",
".",
"data",
";",
"// shift",
"for",
"(",
"int",
"i",
"=",
"index",
"... | Removes an element from the observation matrix.
@param index which element is to be removed | [
"Removes",
"an",
"element",
"from",
"the",
"observation",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/PolynomialFit.java#L155-L164 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/SpecializedOps_ZDRM.java | SpecializedOps_ZDRM.householderVector | public static ZMatrixRMaj householderVector(ZMatrixRMaj x ) {
ZMatrixRMaj u = x.copy();
double max = CommonOps_ZDRM.elementMaxAbs(u);
CommonOps_ZDRM.elementDivide(u, max, 0, u);
double nx = NormOps_ZDRM.normF(u);
Complex_F64 c = new Complex_F64();
u.get(0,0,c);
double realTau,imagTau;
if( c.getMagnitude() == 0 ) {
realTau = nx;
imagTau = 0;
} else {
realTau = c.real/c.getMagnitude()*nx;
imagTau = c.imaginary/c.getMagnitude()*nx;
}
u.set(0,0,c.real + realTau,c.imaginary + imagTau);
CommonOps_ZDRM.elementDivide(u,u.getReal(0,0),u.getImag(0,0),u);
return u;
} | java | public static ZMatrixRMaj householderVector(ZMatrixRMaj x ) {
ZMatrixRMaj u = x.copy();
double max = CommonOps_ZDRM.elementMaxAbs(u);
CommonOps_ZDRM.elementDivide(u, max, 0, u);
double nx = NormOps_ZDRM.normF(u);
Complex_F64 c = new Complex_F64();
u.get(0,0,c);
double realTau,imagTau;
if( c.getMagnitude() == 0 ) {
realTau = nx;
imagTau = 0;
} else {
realTau = c.real/c.getMagnitude()*nx;
imagTau = c.imaginary/c.getMagnitude()*nx;
}
u.set(0,0,c.real + realTau,c.imaginary + imagTau);
CommonOps_ZDRM.elementDivide(u,u.getReal(0,0),u.getImag(0,0),u);
return u;
} | [
"public",
"static",
"ZMatrixRMaj",
"householderVector",
"(",
"ZMatrixRMaj",
"x",
")",
"{",
"ZMatrixRMaj",
"u",
"=",
"x",
".",
"copy",
"(",
")",
";",
"double",
"max",
"=",
"CommonOps_ZDRM",
".",
"elementMaxAbs",
"(",
"u",
")",
";",
"CommonOps_ZDRM",
".",
"e... | Computes the householder vector used in QR decomposition.
u = x / max(x)
u(0) = u(0) + |u|
u = u / u(0)
@param x Input vector. Unmodified.
@return The found householder reflector vector | [
"Computes",
"the",
"householder",
"vector",
"used",
"in",
"QR",
"decomposition",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/SpecializedOps_ZDRM.java#L217-L242 | train |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/decompose/hessenberg/HessenbergSimilarDecomposition_ZDRM.java | HessenbergSimilarDecomposition_ZDRM.decompose | @Override
public boolean decompose( ZMatrixRMaj A )
{
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be square.");
if( A.numRows <= 0 )
return false;
QH = A;
N = A.numCols;
if( b.length < N*2 ) {
b = new double[ N*2 ];
gammas = new double[ N ];
u = new double[ N*2 ];
}
return _decompose();
} | java | @Override
public boolean decompose( ZMatrixRMaj A )
{
if( A.numRows != A.numCols )
throw new IllegalArgumentException("A must be square.");
if( A.numRows <= 0 )
return false;
QH = A;
N = A.numCols;
if( b.length < N*2 ) {
b = new double[ N*2 ];
gammas = new double[ N ];
u = new double[ N*2 ];
}
return _decompose();
} | [
"@",
"Override",
"public",
"boolean",
"decompose",
"(",
"ZMatrixRMaj",
"A",
")",
"{",
"if",
"(",
"A",
".",
"numRows",
"!=",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A must be square.\"",
")",
";",
"if",
"(",
"A",
".",
... | Computes the decomposition of the provided matrix. If no errors are detected then true is returned,
false otherwise.
@param A The matrix that is being decomposed. Not modified.
@return If it detects any errors or not. | [
"Computes",
"the",
"decomposition",
"of",
"the",
"provided",
"matrix",
".",
"If",
"no",
"errors",
"are",
"detected",
"then",
"true",
"is",
"returned",
"false",
"otherwise",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/decompose/hessenberg/HessenbergSimilarDecomposition_ZDRM.java#L86-L104 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/AdjLinearSolverQr_DDRM.java | AdjLinearSolverQr_DDRM.getA | @Override
public DMatrixRMaj getA() {
if( A.data.length < numRows*numCols ) {
A = new DMatrixRMaj(numRows,numCols);
}
A.reshape(numRows,numCols, false);
CommonOps_DDRM.mult(Q,R,A);
return A;
} | java | @Override
public DMatrixRMaj getA() {
if( A.data.length < numRows*numCols ) {
A = new DMatrixRMaj(numRows,numCols);
}
A.reshape(numRows,numCols, false);
CommonOps_DDRM.mult(Q,R,A);
return A;
} | [
"@",
"Override",
"public",
"DMatrixRMaj",
"getA",
"(",
")",
"{",
"if",
"(",
"A",
".",
"data",
".",
"length",
"<",
"numRows",
"*",
"numCols",
")",
"{",
"A",
"=",
"new",
"DMatrixRMaj",
"(",
"numRows",
",",
"numCols",
")",
";",
"}",
"A",
".",
"reshape... | Compute the A matrix from the Q and R matrices.
@return The A matrix. | [
"Compute",
"the",
"A",
"matrix",
"from",
"the",
"Q",
"and",
"R",
"matrices",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/AdjLinearSolverQr_DDRM.java#L60-L69 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( T a ) {
if( a.getType() == getType() )
mat.set(a.getMatrix());
else {
setMatrix(a.mat.copy());
}
} | java | public void set( T a ) {
if( a.getType() == getType() )
mat.set(a.getMatrix());
else {
setMatrix(a.mat.copy());
}
} | [
"public",
"void",
"set",
"(",
"T",
"a",
")",
"{",
"if",
"(",
"a",
".",
"getType",
"(",
")",
"==",
"getType",
"(",
")",
")",
"mat",
".",
"set",
"(",
"a",
".",
"getMatrix",
"(",
")",
")",
";",
"else",
"{",
"setMatrix",
"(",
"a",
".",
"mat",
"... | Sets the elements in this matrix to be equal to the elements in the passed in matrix.
Both matrix must have the same dimension.
@param a The matrix whose value this matrix is being set to. | [
"Sets",
"the",
"elements",
"in",
"this",
"matrix",
"to",
"be",
"equal",
"to",
"the",
"elements",
"in",
"the",
"passed",
"in",
"matrix",
".",
"Both",
"matrix",
"must",
"have",
"the",
"same",
"dimension",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L489-L495 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int row , int col , double value ) {
ops.set(mat, row, col, value);
} | java | public void set( int row , int col , double value ) {
ops.set(mat, row, col, value);
} | [
"public",
"void",
"set",
"(",
"int",
"row",
",",
"int",
"col",
",",
"double",
"value",
")",
"{",
"ops",
".",
"set",
"(",
"mat",
",",
"row",
",",
"col",
",",
"value",
")",
";",
"}"
] | Assigns the element in the Matrix to the specified value. Performs a bounds check to make sure
the requested element is part of the matrix.
@param row The row of the element.
@param col The column of the element.
@param value The element's new value. | [
"Assigns",
"the",
"element",
"in",
"the",
"Matrix",
"to",
"the",
"specified",
"value",
".",
"Performs",
"a",
"bounds",
"check",
"to",
"make",
"sure",
"the",
"requested",
"element",
"is",
"part",
"of",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L615-L617 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int index , double value ) {
if( mat.getType() == MatrixType.DDRM ) {
((DMatrixRMaj) mat).set(index, value);
} else if( mat.getType() == MatrixType.FDRM ) {
((FMatrixRMaj) mat).set(index, (float)value);
} else {
throw new RuntimeException("Not supported yet for this matrix type");
}
} | java | public void set( int index , double value ) {
if( mat.getType() == MatrixType.DDRM ) {
((DMatrixRMaj) mat).set(index, value);
} else if( mat.getType() == MatrixType.FDRM ) {
((FMatrixRMaj) mat).set(index, (float)value);
} else {
throw new RuntimeException("Not supported yet for this matrix type");
}
} | [
"public",
"void",
"set",
"(",
"int",
"index",
",",
"double",
"value",
")",
"{",
"if",
"(",
"mat",
".",
"getType",
"(",
")",
"==",
"MatrixType",
".",
"DDRM",
")",
"{",
"(",
"(",
"DMatrixRMaj",
")",
"mat",
")",
".",
"set",
"(",
"index",
",",
"value... | Assigns an element a value based on its index in the internal array..
@param index The matrix element that is being assigned a value.
@param value The element's new value. | [
"Assigns",
"an",
"element",
"a",
"value",
"based",
"on",
"its",
"index",
"in",
"the",
"internal",
"array",
".."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L625-L633 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.set | public void set( int row , int col , double real , double imaginary ) {
if( imaginary == 0 ) {
set(row,col,real);
} else {
ops.set(mat,row,col, real, imaginary);
}
} | java | public void set( int row , int col , double real , double imaginary ) {
if( imaginary == 0 ) {
set(row,col,real);
} else {
ops.set(mat,row,col, real, imaginary);
}
} | [
"public",
"void",
"set",
"(",
"int",
"row",
",",
"int",
"col",
",",
"double",
"real",
",",
"double",
"imaginary",
")",
"{",
"if",
"(",
"imaginary",
"==",
"0",
")",
"{",
"set",
"(",
"row",
",",
"col",
",",
"real",
")",
";",
"}",
"else",
"{",
"op... | Used to set the complex value of a matrix element.
@param row The row of the element.
@param col The column of the element.
@param real Real component of assigned value
@param imaginary Imaginary component of assigned value | [
"Used",
"to",
"set",
"the",
"complex",
"value",
"of",
"a",
"matrix",
"element",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L642-L648 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.get | public double get( int index ) {
MatrixType type = mat.getType();
if( type.isReal()) {
if (type.getBits() == 64) {
return ((DMatrixRMaj) mat).data[index];
} else {
return ((FMatrixRMaj) mat).data[index];
}
} else {
throw new IllegalArgumentException("Complex matrix. Call get(int,Complex64F) instead");
}
} | java | public double get( int index ) {
MatrixType type = mat.getType();
if( type.isReal()) {
if (type.getBits() == 64) {
return ((DMatrixRMaj) mat).data[index];
} else {
return ((FMatrixRMaj) mat).data[index];
}
} else {
throw new IllegalArgumentException("Complex matrix. Call get(int,Complex64F) instead");
}
} | [
"public",
"double",
"get",
"(",
"int",
"index",
")",
"{",
"MatrixType",
"type",
"=",
"mat",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
".",
"isReal",
"(",
")",
")",
"{",
"if",
"(",
"type",
".",
"getBits",
"(",
")",
"==",
"64",
")",
"{",
... | Returns the value of the matrix at the specified index of the 1D row major array.
@see DMatrixRMaj#get(int)
@param index The element's index whose value is to be returned
@return The value of the specified element. | [
"Returns",
"the",
"value",
"of",
"the",
"matrix",
"at",
"the",
"specified",
"index",
"of",
"the",
"1D",
"row",
"major",
"array",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L702-L714 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.get | public void get( int row , int col , Complex_F64 output ) {
ops.get(mat,row,col,output);
} | java | public void get( int row , int col , Complex_F64 output ) {
ops.get(mat,row,col,output);
} | [
"public",
"void",
"get",
"(",
"int",
"row",
",",
"int",
"col",
",",
"Complex_F64",
"output",
")",
"{",
"ops",
".",
"get",
"(",
"mat",
",",
"row",
",",
"col",
",",
"output",
")",
";",
"}"
] | Used to get the complex value of a matrix element.
@param row The row of the element.
@param col The column of the element.
@param output Storage for the value | [
"Used",
"to",
"get",
"the",
"complex",
"value",
"of",
"a",
"matrix",
"element",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L722-L724 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.copy | public T copy() {
T ret = createLike();
ret.getMatrix().set(this.getMatrix());
return ret;
} | java | public T copy() {
T ret = createLike();
ret.getMatrix().set(this.getMatrix());
return ret;
} | [
"public",
"T",
"copy",
"(",
")",
"{",
"T",
"ret",
"=",
"createLike",
"(",
")",
";",
"ret",
".",
"getMatrix",
"(",
")",
".",
"set",
"(",
"this",
".",
"getMatrix",
"(",
")",
")",
";",
"return",
"ret",
";",
"}"
] | Creates and returns a matrix which is idential to this one.
@return A new identical matrix. | [
"Creates",
"and",
"returns",
"a",
"matrix",
"which",
"is",
"idential",
"to",
"this",
"one",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L761-L765 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.isIdentical | public boolean isIdentical(T a, double tol) {
if( a.getType() != getType() )
return false;
return ops.isIdentical(mat,a.mat,tol);
} | java | public boolean isIdentical(T a, double tol) {
if( a.getType() != getType() )
return false;
return ops.isIdentical(mat,a.mat,tol);
} | [
"public",
"boolean",
"isIdentical",
"(",
"T",
"a",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"a",
".",
"getType",
"(",
")",
"!=",
"getType",
"(",
")",
")",
"return",
"false",
";",
"return",
"ops",
".",
"isIdentical",
"(",
"mat",
",",
"a",
".",
"... | Checks to see if matrix 'a' is the same as this matrix within the specified
tolerance.
@param a The matrix it is being compared against.
@param tol How similar they must be to be equals.
@return If they are equal within tolerance of each other. | [
"Checks",
"to",
"see",
"if",
"matrix",
"a",
"is",
"the",
"same",
"as",
"this",
"matrix",
"within",
"the",
"specified",
"tolerance",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L904-L908 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.isInBounds | public boolean isInBounds(int row, int col) {
return row >= 0 && col >= 0 && row < mat.getNumRows() && col < mat.getNumCols();
} | java | public boolean isInBounds(int row, int col) {
return row >= 0 && col >= 0 && row < mat.getNumRows() && col < mat.getNumCols();
} | [
"public",
"boolean",
"isInBounds",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"return",
"row",
">=",
"0",
"&&",
"col",
">=",
"0",
"&&",
"row",
"<",
"mat",
".",
"getNumRows",
"(",
")",
"&&",
"col",
"<",
"mat",
".",
"getNumCols",
"(",
")",
";"... | Returns true of the specified matrix element is valid element inside this matrix.
@param row Row index.
@param col Column index.
@return true if it is a valid element in the matrix. | [
"Returns",
"true",
"of",
"the",
"specified",
"matrix",
"element",
"is",
"valid",
"element",
"inside",
"this",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L1331-L1333 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.convertToSparse | public void convertToSparse() {
switch ( mat.getType() ) {
case DDRM: {
DMatrixSparseCSC m = new DMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case FDRM: {
FMatrixSparseCSC m = new FMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case DSCC:
case FSCC:
break;
default:
throw new RuntimeException("Conversion not supported!");
}
} | java | public void convertToSparse() {
switch ( mat.getType() ) {
case DDRM: {
DMatrixSparseCSC m = new DMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case FDRM: {
FMatrixSparseCSC m = new FMatrixSparseCSC(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrixRMaj) mat, m,0);
setMatrix(m);
} break;
case DSCC:
case FSCC:
break;
default:
throw new RuntimeException("Conversion not supported!");
}
} | [
"public",
"void",
"convertToSparse",
"(",
")",
"{",
"switch",
"(",
"mat",
".",
"getType",
"(",
")",
")",
"{",
"case",
"DDRM",
":",
"{",
"DMatrixSparseCSC",
"m",
"=",
"new",
"DMatrixSparseCSC",
"(",
"mat",
".",
"getNumRows",
"(",
")",
",",
"mat",
".",
... | Switches from a dense to sparse matrix | [
"Switches",
"from",
"a",
"dense",
"to",
"sparse",
"matrix"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L1501-L1520 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/simple/SimpleBase.java | SimpleBase.convertToDense | public void convertToDense() {
switch ( mat.getType() ) {
case DSCC: {
DMatrix m = new DMatrixRMaj(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrix) mat, m);
setMatrix(m);
} break;
case FSCC: {
FMatrix m = new FMatrixRMaj(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrix) mat, m);
setMatrix(m);
} break;
case DDRM:
case FDRM:
case ZDRM:
case CDRM:
break;
default:
throw new RuntimeException("Not a sparse matrix!");
}
} | java | public void convertToDense() {
switch ( mat.getType() ) {
case DSCC: {
DMatrix m = new DMatrixRMaj(mat.getNumRows(), mat.getNumCols());
ConvertDMatrixStruct.convert((DMatrix) mat, m);
setMatrix(m);
} break;
case FSCC: {
FMatrix m = new FMatrixRMaj(mat.getNumRows(), mat.getNumCols());
ConvertFMatrixStruct.convert((FMatrix) mat, m);
setMatrix(m);
} break;
case DDRM:
case FDRM:
case ZDRM:
case CDRM:
break;
default:
throw new RuntimeException("Not a sparse matrix!");
}
} | [
"public",
"void",
"convertToDense",
"(",
")",
"{",
"switch",
"(",
"mat",
".",
"getType",
"(",
")",
")",
"{",
"case",
"DSCC",
":",
"{",
"DMatrix",
"m",
"=",
"new",
"DMatrixRMaj",
"(",
"mat",
".",
"getNumRows",
"(",
")",
",",
"mat",
".",
"getNumCols",
... | Switches from a sparse to dense matrix | [
"Switches",
"from",
"a",
"sparse",
"to",
"dense",
"matrix"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/simple/SimpleBase.java#L1525-L1545 | train |
lessthanoptimal/ejml | main/ejml-experimental/src/org/ejml/dense/blockd3/BlockD3MatrixOps.java | BlockD3MatrixOps.multBlockAdd | private static void multBlockAdd( double []blockA, double []blockB, double []blockC,
final int m, final int n, final int o,
final int blockLength ) {
// for( int i = 0; i < m; i++ ) {
// for( int j = 0; j < o; j++ ) {
// double val = 0;
// for( int k = 0; k < n; k++ ) {
// val += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
// }
//
// blockC[ i*blockLength + j] += val;
// }
// }
// int rowA = 0;
// for( int i = 0; i < m; i++ , rowA += blockLength) {
// for( int j = 0; j < o; j++ ) {
// double val = 0;
// int indexB = j;
// int indexA = rowA;
// int end = indexA + n;
// for( ; indexA != end; indexA++ , indexB += blockLength ) {
// val += blockA[ indexA ]*blockB[ indexB ];
// }
//
// blockC[ rowA + j] += val;
// }
// }
// for( int k = 0; k < n; k++ ) {
// for( int i = 0; i < m; i++ ) {
// for( int j = 0; j < o; j++ ) {
// blockC[ i*blockLength + j] += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
// }
// }
// }
for( int k = 0; k < n; k++ ) {
int rowB = k*blockLength;
int endB = rowB+o;
for( int i = 0; i < m; i++ ) {
int indexC = i*blockLength;
double valA = blockA[ indexC + k];
int indexB = rowB;
while( indexB != endB ) {
blockC[ indexC++ ] += valA*blockB[ indexB++];
}
}
}
} | java | private static void multBlockAdd( double []blockA, double []blockB, double []blockC,
final int m, final int n, final int o,
final int blockLength ) {
// for( int i = 0; i < m; i++ ) {
// for( int j = 0; j < o; j++ ) {
// double val = 0;
// for( int k = 0; k < n; k++ ) {
// val += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
// }
//
// blockC[ i*blockLength + j] += val;
// }
// }
// int rowA = 0;
// for( int i = 0; i < m; i++ , rowA += blockLength) {
// for( int j = 0; j < o; j++ ) {
// double val = 0;
// int indexB = j;
// int indexA = rowA;
// int end = indexA + n;
// for( ; indexA != end; indexA++ , indexB += blockLength ) {
// val += blockA[ indexA ]*blockB[ indexB ];
// }
//
// blockC[ rowA + j] += val;
// }
// }
// for( int k = 0; k < n; k++ ) {
// for( int i = 0; i < m; i++ ) {
// for( int j = 0; j < o; j++ ) {
// blockC[ i*blockLength + j] += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
// }
// }
// }
for( int k = 0; k < n; k++ ) {
int rowB = k*blockLength;
int endB = rowB+o;
for( int i = 0; i < m; i++ ) {
int indexC = i*blockLength;
double valA = blockA[ indexC + k];
int indexB = rowB;
while( indexB != endB ) {
blockC[ indexC++ ] += valA*blockB[ indexB++];
}
}
}
} | [
"private",
"static",
"void",
"multBlockAdd",
"(",
"double",
"[",
"]",
"blockA",
",",
"double",
"[",
"]",
"blockB",
",",
"double",
"[",
"]",
"blockC",
",",
"final",
"int",
"m",
",",
"final",
"int",
"n",
",",
"final",
"int",
"o",
",",
"final",
"int",
... | Performs a matrix multiplication between inner block matrices.
(m , o) += (m , n) * (n , o) | [
"Performs",
"a",
"matrix",
"multiplication",
"between",
"inner",
"block",
"matrices",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-experimental/src/org/ejml/dense/blockd3/BlockD3MatrixOps.java#L169-L219 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/lu/LUDecompositionBase_DDRM.java | LUDecompositionBase_DDRM._solveVectorInternal | public void _solveVectorInternal( double []vv )
{
// Solve L*Y = B
int ii = 0;
for( int i = 0; i < n; i++ ) {
int ip = indx[i];
double sum = vv[ip];
vv[ip] = vv[i];
if( ii != 0 ) {
// for( int j = ii-1; j < i; j++ )
// sum -= dataLU[i* n +j]*vv[j];
int index = i*n + ii-1;
for( int j = ii-1; j < i; j++ )
sum -= dataLU[index++]*vv[j];
} else if( sum != 0.0 ) {
ii=i+1;
}
vv[i] = sum;
}
// Solve U*X = Y;
TriangularSolver_DDRM.solveU(dataLU,vv,n);
} | java | public void _solveVectorInternal( double []vv )
{
// Solve L*Y = B
int ii = 0;
for( int i = 0; i < n; i++ ) {
int ip = indx[i];
double sum = vv[ip];
vv[ip] = vv[i];
if( ii != 0 ) {
// for( int j = ii-1; j < i; j++ )
// sum -= dataLU[i* n +j]*vv[j];
int index = i*n + ii-1;
for( int j = ii-1; j < i; j++ )
sum -= dataLU[index++]*vv[j];
} else if( sum != 0.0 ) {
ii=i+1;
}
vv[i] = sum;
}
// Solve U*X = Y;
TriangularSolver_DDRM.solveU(dataLU,vv,n);
} | [
"public",
"void",
"_solveVectorInternal",
"(",
"double",
"[",
"]",
"vv",
")",
"{",
"// Solve L*Y = B",
"int",
"ii",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"int",
"ip",
"=",
"indx",
"[",
"i... | a specialized version of solve that avoid additional checks that are not needed. | [
"a",
"specialized",
"version",
"of",
"solve",
"that",
"avoid",
"additional",
"checks",
"that",
"are",
"not",
"needed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/lu/LUDecompositionBase_DDRM.java#L213-L236 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.resize | protected void resize( VariableMatrix mat , int numRows , int numCols ) {
if( mat.isTemp() ) {
mat.matrix.reshape(numRows,numCols);
}
} | java | protected void resize( VariableMatrix mat , int numRows , int numCols ) {
if( mat.isTemp() ) {
mat.matrix.reshape(numRows,numCols);
}
} | [
"protected",
"void",
"resize",
"(",
"VariableMatrix",
"mat",
",",
"int",
"numRows",
",",
"int",
"numCols",
")",
"{",
"if",
"(",
"mat",
".",
"isTemp",
"(",
")",
")",
"{",
"mat",
".",
"matrix",
".",
"reshape",
"(",
"numRows",
",",
"numCols",
")",
";",
... | If the variable is a local temporary variable it will be resized so that the operation can complete. If not
temporary then it will not be reshaped
@param mat Variable containing the matrix
@param numRows Desired number of rows
@param numCols Desired number of columns | [
"If",
"the",
"variable",
"is",
"a",
"local",
"temporary",
"variable",
"it",
"will",
"be",
"resized",
"so",
"that",
"the",
"operation",
"can",
"complete",
".",
"If",
"not",
"temporary",
"then",
"it",
"will",
"not",
"be",
"reshaped"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L61-L65 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.neg | public static Info neg(final Variable A, ManagerTempVariables manager) {
Info ret = new Info();
if( A instanceof VariableInteger ) {
final VariableInteger output = manager.createInteger();
ret.output = output;
ret.op = new Operation("neg-i") {
@Override
public void process() {
output.value = -((VariableInteger)A).value;
}
};
} else if( A instanceof VariableScalar ) {
final VariableDouble output = manager.createDouble();
ret.output = output;
ret.op = new Operation("neg-s") {
@Override
public void process() {
output.value = -((VariableScalar)A).getDouble();
}
};
} else if( A instanceof VariableMatrix ) {
final VariableMatrix output = manager.createMatrix();
ret.output = output;
ret.op = new Operation("neg-m") {
@Override
public void process() {
DMatrixRMaj a = ((VariableMatrix)A).matrix;
output.matrix.reshape(a.numRows, a.numCols);
CommonOps_DDRM.changeSign(a, output.matrix);
}
};
} else {
throw new RuntimeException("Unsupported variable "+A);
}
return ret;
} | java | public static Info neg(final Variable A, ManagerTempVariables manager) {
Info ret = new Info();
if( A instanceof VariableInteger ) {
final VariableInteger output = manager.createInteger();
ret.output = output;
ret.op = new Operation("neg-i") {
@Override
public void process() {
output.value = -((VariableInteger)A).value;
}
};
} else if( A instanceof VariableScalar ) {
final VariableDouble output = manager.createDouble();
ret.output = output;
ret.op = new Operation("neg-s") {
@Override
public void process() {
output.value = -((VariableScalar)A).getDouble();
}
};
} else if( A instanceof VariableMatrix ) {
final VariableMatrix output = manager.createMatrix();
ret.output = output;
ret.op = new Operation("neg-m") {
@Override
public void process() {
DMatrixRMaj a = ((VariableMatrix)A).matrix;
output.matrix.reshape(a.numRows, a.numCols);
CommonOps_DDRM.changeSign(a, output.matrix);
}
};
} else {
throw new RuntimeException("Unsupported variable "+A);
}
return ret;
} | [
"public",
"static",
"Info",
"neg",
"(",
"final",
"Variable",
"A",
",",
"ManagerTempVariables",
"manager",
")",
"{",
"Info",
"ret",
"=",
"new",
"Info",
"(",
")",
";",
"if",
"(",
"A",
"instanceof",
"VariableInteger",
")",
"{",
"final",
"VariableInteger",
"ou... | Returns the negative of the input variable | [
"Returns",
"the",
"negative",
"of",
"the",
"input",
"variable"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L202-L239 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.eye | public static Info eye( final Variable A , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableMatrix ) {
ret.op = new Operation("eye-m") {
@Override
public void process() {
DMatrixRMaj mA = ((VariableMatrix)A).matrix;
output.matrix.reshape(mA.numRows,mA.numCols);
CommonOps_DDRM.setIdentity(output.matrix);
}
};
} else if( A instanceof VariableInteger ) {
ret.op = new Operation("eye-i") {
@Override
public void process() {
int N = ((VariableInteger)A).value;
output.matrix.reshape(N,N);
CommonOps_DDRM.setIdentity(output.matrix);
}
};
} else {
throw new RuntimeException("Unsupported variable type "+A);
}
return ret;
} | java | public static Info eye( final Variable A , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableMatrix ) {
ret.op = new Operation("eye-m") {
@Override
public void process() {
DMatrixRMaj mA = ((VariableMatrix)A).matrix;
output.matrix.reshape(mA.numRows,mA.numCols);
CommonOps_DDRM.setIdentity(output.matrix);
}
};
} else if( A instanceof VariableInteger ) {
ret.op = new Operation("eye-i") {
@Override
public void process() {
int N = ((VariableInteger)A).value;
output.matrix.reshape(N,N);
CommonOps_DDRM.setIdentity(output.matrix);
}
};
} else {
throw new RuntimeException("Unsupported variable type "+A);
}
return ret;
} | [
"public",
"static",
"Info",
"eye",
"(",
"final",
"Variable",
"A",
",",
"ManagerTempVariables",
"manager",
")",
"{",
"Info",
"ret",
"=",
"new",
"Info",
"(",
")",
";",
"final",
"VariableMatrix",
"output",
"=",
"manager",
".",
"createMatrix",
"(",
")",
";",
... | Returns an identity matrix | [
"Returns",
"an",
"identity",
"matrix"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L1260-L1288 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.ones | public static Info ones( final Variable A , final Variable B , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableInteger && B instanceof VariableInteger ) {
ret.op = new Operation("ones-ii") {
@Override
public void process() {
int numRows = ((VariableInteger)A).value;
int numCols = ((VariableInteger)B).value;
output.matrix.reshape(numRows,numCols);
CommonOps_DDRM.fill(output.matrix, 1);
}
};
} else {
throw new RuntimeException("Expected two integers got "+A+" "+B);
}
return ret;
} | java | public static Info ones( final Variable A , final Variable B , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableInteger && B instanceof VariableInteger ) {
ret.op = new Operation("ones-ii") {
@Override
public void process() {
int numRows = ((VariableInteger)A).value;
int numCols = ((VariableInteger)B).value;
output.matrix.reshape(numRows,numCols);
CommonOps_DDRM.fill(output.matrix, 1);
}
};
} else {
throw new RuntimeException("Expected two integers got "+A+" "+B);
}
return ret;
} | [
"public",
"static",
"Info",
"ones",
"(",
"final",
"Variable",
"A",
",",
"final",
"Variable",
"B",
",",
"ManagerTempVariables",
"manager",
")",
"{",
"Info",
"ret",
"=",
"new",
"Info",
"(",
")",
";",
"final",
"VariableMatrix",
"output",
"=",
"manager",
".",
... | Returns a matrix full of ones | [
"Returns",
"a",
"matrix",
"full",
"of",
"ones"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L1349-L1369 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.rng | public static Info rng( final Variable A , ManagerTempVariables manager) {
Info ret = new Info();
if( A instanceof VariableInteger ) {
ret.op = new Operation("rng") {
@Override
public void process() {
int seed = ((VariableInteger)A).value;
manager.getRandom().setSeed(seed);
}
};
} else {
throw new RuntimeException("Expected one integer");
}
return ret;
} | java | public static Info rng( final Variable A , ManagerTempVariables manager) {
Info ret = new Info();
if( A instanceof VariableInteger ) {
ret.op = new Operation("rng") {
@Override
public void process() {
int seed = ((VariableInteger)A).value;
manager.getRandom().setSeed(seed);
}
};
} else {
throw new RuntimeException("Expected one integer");
}
return ret;
} | [
"public",
"static",
"Info",
"rng",
"(",
"final",
"Variable",
"A",
",",
"ManagerTempVariables",
"manager",
")",
"{",
"Info",
"ret",
"=",
"new",
"Info",
"(",
")",
";",
"if",
"(",
"A",
"instanceof",
"VariableInteger",
")",
"{",
"ret",
".",
"op",
"=",
"new... | Sets the seed for random number generator | [
"Sets",
"the",
"seed",
"for",
"random",
"number",
"generator"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L1374-L1391 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.rand | public static Info rand( final Variable A , final Variable B , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableInteger && B instanceof VariableInteger ) {
ret.op = new Operation("rand-ii") {
@Override
public void process() {
int numRows = ((VariableInteger)A).value;
int numCols = ((VariableInteger)B).value;
output.matrix.reshape(numRows,numCols);
RandomMatrices_DDRM.fillUniform(output.matrix, 0,1,manager.getRandom());
}
};
} else {
throw new RuntimeException("Expected two integers got "+A+" "+B);
}
return ret;
} | java | public static Info rand( final Variable A , final Variable B , ManagerTempVariables manager) {
Info ret = new Info();
final VariableMatrix output = manager.createMatrix();
ret.output = output;
if( A instanceof VariableInteger && B instanceof VariableInteger ) {
ret.op = new Operation("rand-ii") {
@Override
public void process() {
int numRows = ((VariableInteger)A).value;
int numCols = ((VariableInteger)B).value;
output.matrix.reshape(numRows,numCols);
RandomMatrices_DDRM.fillUniform(output.matrix, 0,1,manager.getRandom());
}
};
} else {
throw new RuntimeException("Expected two integers got "+A+" "+B);
}
return ret;
} | [
"public",
"static",
"Info",
"rand",
"(",
"final",
"Variable",
"A",
",",
"final",
"Variable",
"B",
",",
"ManagerTempVariables",
"manager",
")",
"{",
"Info",
"ret",
"=",
"new",
"Info",
"(",
")",
";",
"final",
"VariableMatrix",
"output",
"=",
"manager",
".",
... | Uniformly random numbers | [
"Uniformly",
"random",
"numbers"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L1396-L1416 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/Operation.java | Operation.extractSimpleExtents | private static boolean extractSimpleExtents(Variable var, Extents e, boolean row, int length) {
int lower;
int upper;
if( var.getType() == VariableType.INTEGER_SEQUENCE ) {
IntegerSequence sequence = ((VariableIntegerSequence)var).sequence;
if( sequence.getType() == IntegerSequence.Type.FOR ) {
IntegerSequence.For seqFor = (IntegerSequence.For)sequence;
seqFor.initialize(length);
if( seqFor.getStep() == 1 ) {
lower = seqFor.getStart();
upper = seqFor.getEnd();
} else {
return false;
}
} else {
return false;
}
} else if( var.getType() == VariableType.SCALAR ) {
lower = upper = ((VariableInteger)var).value;
} else {
throw new RuntimeException("How did a bad variable get put here?!?!");
}
if( row ) {
e.row0 = lower;
e.row1 = upper;
} else {
e.col0 = lower;
e.col1 = upper;
}
return true;
} | java | private static boolean extractSimpleExtents(Variable var, Extents e, boolean row, int length) {
int lower;
int upper;
if( var.getType() == VariableType.INTEGER_SEQUENCE ) {
IntegerSequence sequence = ((VariableIntegerSequence)var).sequence;
if( sequence.getType() == IntegerSequence.Type.FOR ) {
IntegerSequence.For seqFor = (IntegerSequence.For)sequence;
seqFor.initialize(length);
if( seqFor.getStep() == 1 ) {
lower = seqFor.getStart();
upper = seqFor.getEnd();
} else {
return false;
}
} else {
return false;
}
} else if( var.getType() == VariableType.SCALAR ) {
lower = upper = ((VariableInteger)var).value;
} else {
throw new RuntimeException("How did a bad variable get put here?!?!");
}
if( row ) {
e.row0 = lower;
e.row1 = upper;
} else {
e.col0 = lower;
e.col1 = upper;
}
return true;
} | [
"private",
"static",
"boolean",
"extractSimpleExtents",
"(",
"Variable",
"var",
",",
"Extents",
"e",
",",
"boolean",
"row",
",",
"int",
"length",
")",
"{",
"int",
"lower",
";",
"int",
"upper",
";",
"if",
"(",
"var",
".",
"getType",
"(",
")",
"==",
"Var... | See if a simple sequence can be used to extract the array. A simple extent is a continuous block from
a min to max index
@return true if it is a simple range or false if not | [
"See",
"if",
"a",
"simple",
"sequence",
"can",
"be",
"used",
"to",
"extract",
"the",
"array",
".",
"A",
"simple",
"extent",
"is",
"a",
"continuous",
"block",
"from",
"a",
"min",
"to",
"max",
"index"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/Operation.java#L1686-L1716 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.add | public Token add( Function function ) {
Token t = new Token(function);
push( t );
return t;
} | java | public Token add( Function function ) {
Token t = new Token(function);
push( t );
return t;
} | [
"public",
"Token",
"add",
"(",
"Function",
"function",
")",
"{",
"Token",
"t",
"=",
"new",
"Token",
"(",
"function",
")",
";",
"push",
"(",
"t",
")",
";",
"return",
"t",
";",
"}"
] | Adds a function to the end of the token list
@param function Function which is to be added
@return The new Token created around function | [
"Adds",
"a",
"function",
"to",
"the",
"end",
"of",
"the",
"token",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L57-L61 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.add | public Token add( Variable variable ) {
Token t = new Token(variable);
push( t );
return t;
} | java | public Token add( Variable variable ) {
Token t = new Token(variable);
push( t );
return t;
} | [
"public",
"Token",
"add",
"(",
"Variable",
"variable",
")",
"{",
"Token",
"t",
"=",
"new",
"Token",
"(",
"variable",
")",
";",
"push",
"(",
"t",
")",
";",
"return",
"t",
";",
"}"
] | Adds a variable to the end of the token list
@param variable Variable which is to be added
@return The new Token created around variable | [
"Adds",
"a",
"variable",
"to",
"the",
"end",
"of",
"the",
"token",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L68-L72 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.add | public Token add( Symbol symbol ) {
Token t = new Token(symbol);
push( t );
return t;
} | java | public Token add( Symbol symbol ) {
Token t = new Token(symbol);
push( t );
return t;
} | [
"public",
"Token",
"add",
"(",
"Symbol",
"symbol",
")",
"{",
"Token",
"t",
"=",
"new",
"Token",
"(",
"symbol",
")",
";",
"push",
"(",
"t",
")",
";",
"return",
"t",
";",
"}"
] | Adds a symbol to the end of the token list
@param symbol Symbol which is to be added
@return The new Token created around symbol | [
"Adds",
"a",
"symbol",
"to",
"the",
"end",
"of",
"the",
"token",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L79-L83 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.add | public Token add( String word ) {
Token t = new Token(word);
push( t );
return t;
} | java | public Token add( String word ) {
Token t = new Token(word);
push( t );
return t;
} | [
"public",
"Token",
"add",
"(",
"String",
"word",
")",
"{",
"Token",
"t",
"=",
"new",
"Token",
"(",
"word",
")",
";",
"push",
"(",
"t",
")",
";",
"return",
"t",
";",
"}"
] | Adds a word to the end of the token list
@param word word which is to be added
@return The new Token created around symbol | [
"Adds",
"a",
"word",
"to",
"the",
"end",
"of",
"the",
"token",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L90-L94 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.push | public void push( Token token ) {
size++;
if( first == null ) {
first = token;
last = token;
token.previous = null;
token.next = null;
} else {
last.next = token;
token.previous = last;
token.next = null;
last = token;
}
} | java | public void push( Token token ) {
size++;
if( first == null ) {
first = token;
last = token;
token.previous = null;
token.next = null;
} else {
last.next = token;
token.previous = last;
token.next = null;
last = token;
}
} | [
"public",
"void",
"push",
"(",
"Token",
"token",
")",
"{",
"size",
"++",
";",
"if",
"(",
"first",
"==",
"null",
")",
"{",
"first",
"=",
"token",
";",
"last",
"=",
"token",
";",
"token",
".",
"previous",
"=",
"null",
";",
"token",
".",
"next",
"="... | Adds a new Token to the end of the linked list | [
"Adds",
"a",
"new",
"Token",
"to",
"the",
"end",
"of",
"the",
"linked",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L99-L112 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.insert | public void insert( Token where , Token token ) {
if( where == null ) {
// put at the front of the list
if( size == 0 )
push(token);
else {
first.previous = token;
token.previous = null;
token.next = first;
first = token;
size++;
}
} else if( where == last || null == last ) {
push(token);
} else {
token.next = where.next;
token.previous = where;
where.next.previous = token;
where.next = token;
size++;
}
} | java | public void insert( Token where , Token token ) {
if( where == null ) {
// put at the front of the list
if( size == 0 )
push(token);
else {
first.previous = token;
token.previous = null;
token.next = first;
first = token;
size++;
}
} else if( where == last || null == last ) {
push(token);
} else {
token.next = where.next;
token.previous = where;
where.next.previous = token;
where.next = token;
size++;
}
} | [
"public",
"void",
"insert",
"(",
"Token",
"where",
",",
"Token",
"token",
")",
"{",
"if",
"(",
"where",
"==",
"null",
")",
"{",
"// put at the front of the list",
"if",
"(",
"size",
"==",
"0",
")",
"push",
"(",
"token",
")",
";",
"else",
"{",
"first",
... | Inserts 'token' after 'where'. if where is null then it is inserted to the beginning of the list.
@param where Where 'token' should be inserted after. if null the put at it at the beginning
@param token The token that is to be inserted | [
"Inserts",
"token",
"after",
"where",
".",
"if",
"where",
"is",
"null",
"then",
"it",
"is",
"inserted",
"to",
"the",
"beginning",
"of",
"the",
"list",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L119-L140 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.remove | public void remove( Token token ) {
if( token == first ) {
first = first.next;
}
if( token == last ) {
last = last.previous;
}
if( token.next != null ) {
token.next.previous = token.previous;
}
if( token.previous != null ) {
token.previous.next = token.next;
}
token.next = token.previous = null;
size--;
} | java | public void remove( Token token ) {
if( token == first ) {
first = first.next;
}
if( token == last ) {
last = last.previous;
}
if( token.next != null ) {
token.next.previous = token.previous;
}
if( token.previous != null ) {
token.previous.next = token.next;
}
token.next = token.previous = null;
size--;
} | [
"public",
"void",
"remove",
"(",
"Token",
"token",
")",
"{",
"if",
"(",
"token",
"==",
"first",
")",
"{",
"first",
"=",
"first",
".",
"next",
";",
"}",
"if",
"(",
"token",
"==",
"last",
")",
"{",
"last",
"=",
"last",
".",
"previous",
";",
"}",
... | Removes the token from the list
@param token Token which is to be removed | [
"Removes",
"the",
"token",
"from",
"the",
"list"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L146-L162 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.replace | public void replace( Token original , Token target ) {
if( first == original )
first = target;
if( last == original )
last = target;
target.next = original.next;
target.previous = original.previous;
if( original.next != null )
original.next.previous = target;
if( original.previous != null )
original.previous.next = target;
original.next = original.previous = null;
} | java | public void replace( Token original , Token target ) {
if( first == original )
first = target;
if( last == original )
last = target;
target.next = original.next;
target.previous = original.previous;
if( original.next != null )
original.next.previous = target;
if( original.previous != null )
original.previous.next = target;
original.next = original.previous = null;
} | [
"public",
"void",
"replace",
"(",
"Token",
"original",
",",
"Token",
"target",
")",
"{",
"if",
"(",
"first",
"==",
"original",
")",
"first",
"=",
"target",
";",
"if",
"(",
"last",
"==",
"original",
")",
"last",
"=",
"target",
";",
"target",
".",
"nex... | Removes 'original' and places 'target' at the same location | [
"Removes",
"original",
"and",
"places",
"target",
"at",
"the",
"same",
"location"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L167-L182 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.extractSubList | public TokenList extractSubList( Token begin , Token end ) {
if( begin == end ) {
remove(begin);
return new TokenList(begin,begin);
} else {
if( first == begin ) {
first = end.next;
}
if( last == end ) {
last = begin.previous;
}
if( begin.previous != null ) {
begin.previous.next = end.next;
}
if( end.next != null ) {
end.next.previous = begin.previous;
}
begin.previous = null;
end.next = null;
TokenList ret = new TokenList(begin,end);
size -= ret.size();
return ret;
}
} | java | public TokenList extractSubList( Token begin , Token end ) {
if( begin == end ) {
remove(begin);
return new TokenList(begin,begin);
} else {
if( first == begin ) {
first = end.next;
}
if( last == end ) {
last = begin.previous;
}
if( begin.previous != null ) {
begin.previous.next = end.next;
}
if( end.next != null ) {
end.next.previous = begin.previous;
}
begin.previous = null;
end.next = null;
TokenList ret = new TokenList(begin,end);
size -= ret.size();
return ret;
}
} | [
"public",
"TokenList",
"extractSubList",
"(",
"Token",
"begin",
",",
"Token",
"end",
")",
"{",
"if",
"(",
"begin",
"==",
"end",
")",
"{",
"remove",
"(",
"begin",
")",
";",
"return",
"new",
"TokenList",
"(",
"begin",
",",
"begin",
")",
";",
"}",
"else... | Removes elements from begin to end from the list, inclusive. Returns a new list which
is composed of the removed elements | [
"Removes",
"elements",
"from",
"begin",
"to",
"end",
"from",
"the",
"list",
"inclusive",
".",
"Returns",
"a",
"new",
"list",
"which",
"is",
"composed",
"of",
"the",
"removed",
"elements"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L188-L212 | train |
lessthanoptimal/ejml | main/ejml-simple/src/org/ejml/equation/TokenList.java | TokenList.insertAfter | public void insertAfter(Token before, TokenList list ) {
Token after = before.next;
before.next = list.first;
list.first.previous = before;
if( after == null ) {
last = list.last;
} else {
after.previous = list.last;
list.last.next = after;
}
size += list.size;
} | java | public void insertAfter(Token before, TokenList list ) {
Token after = before.next;
before.next = list.first;
list.first.previous = before;
if( after == null ) {
last = list.last;
} else {
after.previous = list.last;
list.last.next = after;
}
size += list.size;
} | [
"public",
"void",
"insertAfter",
"(",
"Token",
"before",
",",
"TokenList",
"list",
")",
"{",
"Token",
"after",
"=",
"before",
".",
"next",
";",
"before",
".",
"next",
"=",
"list",
".",
"first",
";",
"list",
".",
"first",
".",
"previous",
"=",
"before",... | Inserts the LokenList immediately following the 'before' token | [
"Inserts",
"the",
"LokenList",
"immediately",
"following",
"the",
"before",
"token"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-simple/src/org/ejml/equation/TokenList.java#L217-L229 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CovarianceOps_DDRM.java | CovarianceOps_DDRM.isValid | public static int isValid( DMatrixRMaj cov ) {
if( !MatrixFeatures_DDRM.isDiagonalPositive(cov) )
return 1;
if( !MatrixFeatures_DDRM.isSymmetric(cov,TOL) )
return 2;
if( !MatrixFeatures_DDRM.isPositiveSemidefinite(cov) )
return 3;
return 0;
} | java | public static int isValid( DMatrixRMaj cov ) {
if( !MatrixFeatures_DDRM.isDiagonalPositive(cov) )
return 1;
if( !MatrixFeatures_DDRM.isSymmetric(cov,TOL) )
return 2;
if( !MatrixFeatures_DDRM.isPositiveSemidefinite(cov) )
return 3;
return 0;
} | [
"public",
"static",
"int",
"isValid",
"(",
"DMatrixRMaj",
"cov",
")",
"{",
"if",
"(",
"!",
"MatrixFeatures_DDRM",
".",
"isDiagonalPositive",
"(",
"cov",
")",
")",
"return",
"1",
";",
"if",
"(",
"!",
"MatrixFeatures_DDRM",
".",
"isSymmetric",
"(",
"cov",
",... | Performs a variety of tests to see if the provided matrix is a valid
covariance matrix.
@return 0 = is valid 1 = failed positive diagonal, 2 = failed on symmetry, 2 = failed on positive definite | [
"Performs",
"a",
"variety",
"of",
"tests",
"to",
"see",
"if",
"the",
"provided",
"matrix",
"is",
"a",
"valid",
"covariance",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CovarianceOps_DDRM.java#L57-L68 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CovarianceOps_DDRM.java | CovarianceOps_DDRM.invert | public static boolean invert(final DMatrixRMaj cov , final DMatrixRMaj cov_inv ) {
if( cov.numCols <= 4 ) {
if( cov.numCols != cov.numRows ) {
throw new IllegalArgumentException("Must be a square matrix.");
}
if( cov.numCols >= 2 )
UnrolledInverseFromMinor_DDRM.inv(cov,cov_inv);
else
cov_inv.data[0] = 1.0/cov.data[0];
} else {
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.symmPosDef(cov.numRows);
// wrap it to make sure the covariance is not modified.
solver = new LinearSolverSafe<DMatrixRMaj>(solver);
if( !solver.setA(cov) )
return false;
solver.invert(cov_inv);
}
return true;
} | java | public static boolean invert(final DMatrixRMaj cov , final DMatrixRMaj cov_inv ) {
if( cov.numCols <= 4 ) {
if( cov.numCols != cov.numRows ) {
throw new IllegalArgumentException("Must be a square matrix.");
}
if( cov.numCols >= 2 )
UnrolledInverseFromMinor_DDRM.inv(cov,cov_inv);
else
cov_inv.data[0] = 1.0/cov.data[0];
} else {
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.symmPosDef(cov.numRows);
// wrap it to make sure the covariance is not modified.
solver = new LinearSolverSafe<DMatrixRMaj>(solver);
if( !solver.setA(cov) )
return false;
solver.invert(cov_inv);
}
return true;
} | [
"public",
"static",
"boolean",
"invert",
"(",
"final",
"DMatrixRMaj",
"cov",
",",
"final",
"DMatrixRMaj",
"cov_inv",
")",
"{",
"if",
"(",
"cov",
".",
"numCols",
"<=",
"4",
")",
"{",
"if",
"(",
"cov",
".",
"numCols",
"!=",
"cov",
".",
"numRows",
")",
... | Performs a matrix inversion operations that takes advantage of the special
properties of a covariance matrix.
@param cov A covariance matrix. Not modified.
@param cov_inv The inverse of cov. Modified.
@return true if it could invert the matrix false if it could not. | [
"Performs",
"a",
"matrix",
"inversion",
"operations",
"that",
"takes",
"advantage",
"of",
"the",
"special",
"properties",
"of",
"a",
"covariance",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CovarianceOps_DDRM.java#L89-L109 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/data/BMatrixRMaj.java | BMatrixRMaj.sum | public int sum() {
int total = 0;
int N = getNumElements();
for (int i = 0; i < N; i++) {
if( data[i] )
total += 1;
}
return total;
} | java | public int sum() {
int total = 0;
int N = getNumElements();
for (int i = 0; i < N; i++) {
if( data[i] )
total += 1;
}
return total;
} | [
"public",
"int",
"sum",
"(",
")",
"{",
"int",
"total",
"=",
"0",
";",
"int",
"N",
"=",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
")",... | Returns the total number of elements which are true.
@return number of elements which are set to true | [
"Returns",
"the",
"total",
"number",
"of",
"elements",
"which",
"are",
"true",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/data/BMatrixRMaj.java#L103-L111 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java | BidiagonalDecompositionRow_DDRM.init | protected void init(DMatrixRMaj A ) {
UBV = A;
m = UBV.numRows;
n = UBV.numCols;
min = Math.min(m,n);
int max = Math.max(m,n);
if( b.length < max+1 ) {
b = new double[ max+1 ];
u = new double[ max+1 ];
}
if( gammasU.length < m ) {
gammasU = new double[ m ];
}
if( gammasV.length < n ) {
gammasV = new double[ n ];
}
} | java | protected void init(DMatrixRMaj A ) {
UBV = A;
m = UBV.numRows;
n = UBV.numCols;
min = Math.min(m,n);
int max = Math.max(m,n);
if( b.length < max+1 ) {
b = new double[ max+1 ];
u = new double[ max+1 ];
}
if( gammasU.length < m ) {
gammasU = new double[ m ];
}
if( gammasV.length < n ) {
gammasV = new double[ n ];
}
} | [
"protected",
"void",
"init",
"(",
"DMatrixRMaj",
"A",
")",
"{",
"UBV",
"=",
"A",
";",
"m",
"=",
"UBV",
".",
"numRows",
";",
"n",
"=",
"UBV",
".",
"numCols",
";",
"min",
"=",
"Math",
".",
"min",
"(",
"m",
",",
"n",
")",
";",
"int",
"max",
"=",... | Sets up internal data structures and creates a copy of the input matrix.
@param A The input matrix. Not modified. | [
"Sets",
"up",
"internal",
"data",
"structures",
"and",
"creates",
"a",
"copy",
"of",
"the",
"input",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java#L91-L110 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java | BidiagonalDecompositionRow_DDRM.getU | @Override
public DMatrixRMaj getU(DMatrixRMaj U , boolean transpose , boolean compact ) {
U = handleU(U, transpose, compact,m,n,min);
CommonOps_DDRM.setIdentity(U);
for( int i = 0; i < m; i++ ) u[i] = 0;
for( int j = min-1; j >= 0; j-- ) {
u[j] = 1;
for( int i = j+1; i < m; i++ ) {
u[i] = UBV.get(i,j);
}
if( transpose )
QrHelperFunctions_DDRM.rank1UpdateMultL(U, u, gammasU[j], j, j, m);
else
QrHelperFunctions_DDRM.rank1UpdateMultR(U, u, gammasU[j], j, j, m, this.b);
}
return U;
} | java | @Override
public DMatrixRMaj getU(DMatrixRMaj U , boolean transpose , boolean compact ) {
U = handleU(U, transpose, compact,m,n,min);
CommonOps_DDRM.setIdentity(U);
for( int i = 0; i < m; i++ ) u[i] = 0;
for( int j = min-1; j >= 0; j-- ) {
u[j] = 1;
for( int i = j+1; i < m; i++ ) {
u[i] = UBV.get(i,j);
}
if( transpose )
QrHelperFunctions_DDRM.rank1UpdateMultL(U, u, gammasU[j], j, j, m);
else
QrHelperFunctions_DDRM.rank1UpdateMultR(U, u, gammasU[j], j, j, m, this.b);
}
return U;
} | [
"@",
"Override",
"public",
"DMatrixRMaj",
"getU",
"(",
"DMatrixRMaj",
"U",
",",
"boolean",
"transpose",
",",
"boolean",
"compact",
")",
"{",
"U",
"=",
"handleU",
"(",
"U",
",",
"transpose",
",",
"compact",
",",
"m",
",",
"n",
",",
"min",
")",
";",
"C... | Returns the orthogonal U matrix.
@param U If not null then the results will be stored here. Otherwise a new matrix will be created.
@return The extracted Q matrix. | [
"Returns",
"the",
"orthogonal",
"U",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java#L181-L200 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java | BidiagonalDecompositionRow_DDRM.getV | @Override
public DMatrixRMaj getV(DMatrixRMaj V , boolean transpose , boolean compact ) {
V = handleV(V, transpose, compact,m,n,min);
CommonOps_DDRM.setIdentity(V);
// UBV.print();
// todo the very first multiplication can be avoided by setting to the rank1update output
for( int j = min-1; j >= 0; j-- ) {
u[j+1] = 1;
for( int i = j+2; i < n; i++ ) {
u[i] = UBV.get(j,i);
}
if( transpose )
QrHelperFunctions_DDRM.rank1UpdateMultL(V, u, gammasV[j], j + 1, j + 1, n);
else
QrHelperFunctions_DDRM.rank1UpdateMultR(V, u, gammasV[j], j + 1, j + 1, n, this.b);
}
return V;
} | java | @Override
public DMatrixRMaj getV(DMatrixRMaj V , boolean transpose , boolean compact ) {
V = handleV(V, transpose, compact,m,n,min);
CommonOps_DDRM.setIdentity(V);
// UBV.print();
// todo the very first multiplication can be avoided by setting to the rank1update output
for( int j = min-1; j >= 0; j-- ) {
u[j+1] = 1;
for( int i = j+2; i < n; i++ ) {
u[i] = UBV.get(j,i);
}
if( transpose )
QrHelperFunctions_DDRM.rank1UpdateMultL(V, u, gammasV[j], j + 1, j + 1, n);
else
QrHelperFunctions_DDRM.rank1UpdateMultR(V, u, gammasV[j], j + 1, j + 1, n, this.b);
}
return V;
} | [
"@",
"Override",
"public",
"DMatrixRMaj",
"getV",
"(",
"DMatrixRMaj",
"V",
",",
"boolean",
"transpose",
",",
"boolean",
"compact",
")",
"{",
"V",
"=",
"handleV",
"(",
"V",
",",
"transpose",
",",
"compact",
",",
"m",
",",
"n",
",",
"min",
")",
";",
"C... | Returns the orthogonal V matrix.
@param V If not null then the results will be stored here. Otherwise a new matrix will be created.
@return The extracted Q matrix. | [
"Returns",
"the",
"orthogonal",
"V",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/bidiagonal/BidiagonalDecompositionRow_DDRM.java#L234-L254 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/UtilEjml.java | UtilEjml.safe | public static <S extends Matrix, D extends Matrix> LinearSolver<S,D> safe(LinearSolver<S,D> solver ) {
if( solver.modifiesA() || solver.modifiesB() ) {
if( solver instanceof LinearSolverDense ) {
return new LinearSolverSafe((LinearSolverDense)solver);
} else if( solver instanceof LinearSolverSparse ) {
return new LinearSolverSparseSafe((LinearSolverSparse)solver);
} else {
throw new IllegalArgumentException("Unknown solver type");
}
} else {
return solver;
}
} | java | public static <S extends Matrix, D extends Matrix> LinearSolver<S,D> safe(LinearSolver<S,D> solver ) {
if( solver.modifiesA() || solver.modifiesB() ) {
if( solver instanceof LinearSolverDense ) {
return new LinearSolverSafe((LinearSolverDense)solver);
} else if( solver instanceof LinearSolverSparse ) {
return new LinearSolverSparseSafe((LinearSolverSparse)solver);
} else {
throw new IllegalArgumentException("Unknown solver type");
}
} else {
return solver;
}
} | [
"public",
"static",
"<",
"S",
"extends",
"Matrix",
",",
"D",
"extends",
"Matrix",
">",
"LinearSolver",
"<",
"S",
",",
"D",
">",
"safe",
"(",
"LinearSolver",
"<",
"S",
",",
"D",
">",
"solver",
")",
"{",
"if",
"(",
"solver",
".",
"modifiesA",
"(",
")... | Wraps a linear solver of any type with a safe solver the ensures inputs are not modified | [
"Wraps",
"a",
"linear",
"solver",
"of",
"any",
"type",
"with",
"a",
"safe",
"solver",
"the",
"ensures",
"inputs",
"are",
"not",
"modified"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/UtilEjml.java#L64-L76 | train |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/UtilEjml.java | UtilEjml.fancyStringF | public static String fancyStringF(double value, DecimalFormat format, int length, int significant) {
String formatted = fancyString(value, format, length, significant);
int n = length-formatted.length();
if( n > 0 ) {
StringBuilder builder = new StringBuilder(n);
for (int i = 0; i < n; i++) {
builder.append(' ');
}
return formatted + builder.toString();
} else {
return formatted;
}
} | java | public static String fancyStringF(double value, DecimalFormat format, int length, int significant) {
String formatted = fancyString(value, format, length, significant);
int n = length-formatted.length();
if( n > 0 ) {
StringBuilder builder = new StringBuilder(n);
for (int i = 0; i < n; i++) {
builder.append(' ');
}
return formatted + builder.toString();
} else {
return formatted;
}
} | [
"public",
"static",
"String",
"fancyStringF",
"(",
"double",
"value",
",",
"DecimalFormat",
"format",
",",
"int",
"length",
",",
"int",
"significant",
")",
"{",
"String",
"formatted",
"=",
"fancyString",
"(",
"value",
",",
"format",
",",
"length",
",",
"sign... | Fixed length fancy formatting for doubles. If possible decimal notation is used. If all the significant digits
can't be shown then it will switch to exponential notation. If not all the space is needed then it will
be filled in to ensure it has the specified length.
@param value value being formatted
@param format default format before exponential
@param length Maximum number of characters it can take.
@param significant Number of significant decimal digits to show at a minimum.
@return formatted string | [
"Fixed",
"length",
"fancy",
"formatting",
"for",
"doubles",
".",
"If",
"possible",
"decimal",
"notation",
"is",
"used",
".",
"If",
"all",
"the",
"significant",
"digits",
"can",
"t",
"be",
"shown",
"then",
"it",
"will",
"switch",
"to",
"exponential",
"notatio... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/UtilEjml.java#L336-L350 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.performDynamicStep | private void performDynamicStep() {
// initially look for singular values of zero
if( findingZeros ) {
if( steps > 6 ) {
findingZeros = false;
} else {
double scale = computeBulgeScale();
performImplicitSingleStep(scale,0,false);
}
} else {
// For very large and very small numbers the only way to prevent overflow/underflow
// is to have a common scale between the wilkinson shift and the implicit single step
// What happens if you don't is that when the wilkinson shift returns the value it
// computed it multiplies it by the scale twice, which will cause an overflow
double scale = computeBulgeScale();
// use the wilkinson shift to perform a step
double lambda = selectWilkinsonShift(scale);
performImplicitSingleStep(scale,lambda,false);
}
} | java | private void performDynamicStep() {
// initially look for singular values of zero
if( findingZeros ) {
if( steps > 6 ) {
findingZeros = false;
} else {
double scale = computeBulgeScale();
performImplicitSingleStep(scale,0,false);
}
} else {
// For very large and very small numbers the only way to prevent overflow/underflow
// is to have a common scale between the wilkinson shift and the implicit single step
// What happens if you don't is that when the wilkinson shift returns the value it
// computed it multiplies it by the scale twice, which will cause an overflow
double scale = computeBulgeScale();
// use the wilkinson shift to perform a step
double lambda = selectWilkinsonShift(scale);
performImplicitSingleStep(scale,lambda,false);
}
} | [
"private",
"void",
"performDynamicStep",
"(",
")",
"{",
"// initially look for singular values of zero",
"if",
"(",
"findingZeros",
")",
"{",
"if",
"(",
"steps",
">",
"6",
")",
"{",
"findingZeros",
"=",
"false",
";",
"}",
"else",
"{",
"double",
"scale",
"=",
... | Here the lambda in the implicit step is determined dynamically. At first
it selects zeros to quickly reveal singular values that are zero or close to zero.
Then it computes it using a Wilkinson shift. | [
"Here",
"the",
"lambda",
"in",
"the",
"implicit",
"step",
"is",
"determined",
"dynamically",
".",
"At",
"first",
"it",
"selects",
"zeros",
"to",
"quickly",
"reveal",
"singular",
"values",
"that",
"are",
"zero",
"or",
"close",
"to",
"zero",
".",
"Then",
"it... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L270-L290 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.performScriptedStep | private void performScriptedStep() {
double scale = computeBulgeScale();
if( steps > giveUpOnKnown ) {
// give up on the script
followScript = false;
} else {
// use previous singular value to step
double s = values[x2]/scale;
performImplicitSingleStep(scale,s*s,false);
}
} | java | private void performScriptedStep() {
double scale = computeBulgeScale();
if( steps > giveUpOnKnown ) {
// give up on the script
followScript = false;
} else {
// use previous singular value to step
double s = values[x2]/scale;
performImplicitSingleStep(scale,s*s,false);
}
} | [
"private",
"void",
"performScriptedStep",
"(",
")",
"{",
"double",
"scale",
"=",
"computeBulgeScale",
"(",
")",
";",
"if",
"(",
"steps",
">",
"giveUpOnKnown",
")",
"{",
"// give up on the script",
"followScript",
"=",
"false",
";",
"}",
"else",
"{",
"// use pr... | Shifts are performed based upon singular values computed previously. If it does not converge
using one of those singular values it uses a Wilkinson shift instead. | [
"Shifts",
"are",
"performed",
"based",
"upon",
"singular",
"values",
"computed",
"previously",
".",
"If",
"it",
"does",
"not",
"converge",
"using",
"one",
"of",
"those",
"singular",
"values",
"it",
"uses",
"a",
"Wilkinson",
"shift",
"instead",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L296-L306 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.nextSplit | public boolean nextSplit() {
if( numSplits == 0 )
return false;
x2 = splits[--numSplits];
if( numSplits > 0 )
x1 = splits[numSplits-1]+1;
else
x1 = 0;
return true;
} | java | public boolean nextSplit() {
if( numSplits == 0 )
return false;
x2 = splits[--numSplits];
if( numSplits > 0 )
x1 = splits[numSplits-1]+1;
else
x1 = 0;
return true;
} | [
"public",
"boolean",
"nextSplit",
"(",
")",
"{",
"if",
"(",
"numSplits",
"==",
"0",
")",
"return",
"false",
";",
"x2",
"=",
"splits",
"[",
"--",
"numSplits",
"]",
";",
"if",
"(",
"numSplits",
">",
"0",
")",
"x1",
"=",
"splits",
"[",
"numSplits",
"-... | Tells it to process the submatrix at the next split. Should be called after the
current submatrix has been processed. | [
"Tells",
"it",
"to",
"process",
"the",
"submatrix",
"at",
"the",
"next",
"split",
".",
"Should",
"be",
"called",
"after",
"the",
"current",
"submatrix",
"has",
"been",
"processed",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L337-L347 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.performImplicitSingleStep | public void performImplicitSingleStep(double scale , double lambda , boolean byAngle) {
createBulge(x1,lambda,scale,byAngle);
for( int i = x1; i < x2-1 && bulge != 0.0; i++ ) {
removeBulgeLeft(i,true);
if( bulge == 0 )
break;
removeBulgeRight(i);
}
if( bulge != 0 )
removeBulgeLeft(x2-1,false);
incrementSteps();
} | java | public void performImplicitSingleStep(double scale , double lambda , boolean byAngle) {
createBulge(x1,lambda,scale,byAngle);
for( int i = x1; i < x2-1 && bulge != 0.0; i++ ) {
removeBulgeLeft(i,true);
if( bulge == 0 )
break;
removeBulgeRight(i);
}
if( bulge != 0 )
removeBulgeLeft(x2-1,false);
incrementSteps();
} | [
"public",
"void",
"performImplicitSingleStep",
"(",
"double",
"scale",
",",
"double",
"lambda",
",",
"boolean",
"byAngle",
")",
"{",
"createBulge",
"(",
"x1",
",",
"lambda",
",",
"scale",
",",
"byAngle",
")",
";",
"for",
"(",
"int",
"i",
"=",
"x1",
";",
... | Given the lambda value perform an implicit QR step on the matrix.
B^T*B-lambda*I
@param lambda Stepping factor. | [
"Given",
"the",
"lambda",
"value",
"perform",
"an",
"implicit",
"QR",
"step",
"on",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L356-L370 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.updateRotator | protected void updateRotator(DMatrixRMaj Q , int m, int n, double c, double s) {
int rowA = m*Q.numCols;
int rowB = n*Q.numCols;
// for( int i = 0; i < Q.numCols; i++ ) {
// double a = Q.get(rowA+i);
// double b = Q.get(rowB+i);
// Q.set( rowA+i, c*a + s*b);
// Q.set( rowB+i, -s*a + c*b);
// }
// System.out.println("------ AFter Update Rotator "+m+" "+n);
// Q.print();
// System.out.println();
int endA = rowA + Q.numCols;
for( ; rowA != endA; rowA++ , rowB++ ) {
double a = Q.get(rowA);
double b = Q.get(rowB);
Q.set(rowA, c*a + s*b);
Q.set(rowB, -s*a + c*b);
}
} | java | protected void updateRotator(DMatrixRMaj Q , int m, int n, double c, double s) {
int rowA = m*Q.numCols;
int rowB = n*Q.numCols;
// for( int i = 0; i < Q.numCols; i++ ) {
// double a = Q.get(rowA+i);
// double b = Q.get(rowB+i);
// Q.set( rowA+i, c*a + s*b);
// Q.set( rowB+i, -s*a + c*b);
// }
// System.out.println("------ AFter Update Rotator "+m+" "+n);
// Q.print();
// System.out.println();
int endA = rowA + Q.numCols;
for( ; rowA != endA; rowA++ , rowB++ ) {
double a = Q.get(rowA);
double b = Q.get(rowB);
Q.set(rowA, c*a + s*b);
Q.set(rowB, -s*a + c*b);
}
} | [
"protected",
"void",
"updateRotator",
"(",
"DMatrixRMaj",
"Q",
",",
"int",
"m",
",",
"int",
"n",
",",
"double",
"c",
",",
"double",
"s",
")",
"{",
"int",
"rowA",
"=",
"m",
"*",
"Q",
".",
"numCols",
";",
"int",
"rowB",
"=",
"n",
"*",
"Q",
".",
"... | Multiplied a transpose orthogonal matrix Q by the specified rotator. This is used
to update the U and V matrices. Updating the transpose of the matrix is faster
since it only modifies the rows.
@param Q Orthogonal matrix
@param m Coordinate of rotator.
@param n Coordinate of rotator.
@param c cosine of rotator.
@param s sine of rotator. | [
"Multiplied",
"a",
"transpose",
"orthogonal",
"matrix",
"Q",
"by",
"the",
"specified",
"rotator",
".",
"This",
"is",
"used",
"to",
"update",
"the",
"U",
"and",
"V",
"matrices",
".",
"Updating",
"the",
"transpose",
"of",
"the",
"matrix",
"is",
"faster",
"si... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L384-L404 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.checkForAndHandleZeros | protected boolean checkForAndHandleZeros() {
// check for zeros along off diagonal
for( int i = x2-1; i >= x1; i-- ) {
if( isOffZero(i) ) {
// System.out.println("steps at split = "+steps);
resetSteps();
splits[numSplits++] = i;
x1 = i+1;
return true;
}
}
// check for zeros along diagonal
for( int i = x2-1; i >= x1; i-- ) {
if( isDiagonalZero(i)) {
// System.out.println("steps at split = "+steps);
pushRight(i);
resetSteps();
splits[numSplits++] = i;
x1 = i+1;
return true;
}
}
return false;
} | java | protected boolean checkForAndHandleZeros() {
// check for zeros along off diagonal
for( int i = x2-1; i >= x1; i-- ) {
if( isOffZero(i) ) {
// System.out.println("steps at split = "+steps);
resetSteps();
splits[numSplits++] = i;
x1 = i+1;
return true;
}
}
// check for zeros along diagonal
for( int i = x2-1; i >= x1; i-- ) {
if( isDiagonalZero(i)) {
// System.out.println("steps at split = "+steps);
pushRight(i);
resetSteps();
splits[numSplits++] = i;
x1 = i+1;
return true;
}
}
return false;
} | [
"protected",
"boolean",
"checkForAndHandleZeros",
"(",
")",
"{",
"// check for zeros along off diagonal",
"for",
"(",
"int",
"i",
"=",
"x2",
"-",
"1",
";",
"i",
">=",
"x1",
";",
"i",
"--",
")",
"{",
"if",
"(",
"isOffZero",
"(",
"i",
")",
")",
"{",
"// ... | Checks to see if either the diagonal element or off diagonal element is zero. If one is
then it performs a split or pushes it off the matrix.
@return True if there was a zero. | [
"Checks",
"to",
"see",
"if",
"either",
"the",
"diagonal",
"element",
"or",
"off",
"diagonal",
"element",
"is",
"zero",
".",
"If",
"one",
"is",
"then",
"it",
"performs",
"a",
"split",
"or",
"pushes",
"it",
"off",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L643-L667 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.pushRight | private void pushRight( int row ) {
if( isOffZero(row))
return;
// B = createB();
// B.print();
rotatorPushRight(row);
int end = N-2-row;
for( int i = 0; i < end && bulge != 0; i++ ) {
rotatorPushRight2(row,i+2);
}
// }
} | java | private void pushRight( int row ) {
if( isOffZero(row))
return;
// B = createB();
// B.print();
rotatorPushRight(row);
int end = N-2-row;
for( int i = 0; i < end && bulge != 0; i++ ) {
rotatorPushRight2(row,i+2);
}
// }
} | [
"private",
"void",
"pushRight",
"(",
"int",
"row",
")",
"{",
"if",
"(",
"isOffZero",
"(",
"row",
")",
")",
"return",
";",
"// B = createB();",
"// B.print();",
"rotatorPushRight",
"(",
"row",
")",
";",
"int",
"end",
"=",
"N",
"-",
"2",
"-",
... | If there is a zero on the diagonal element, the off diagonal element needs pushed
off so that all the algorithms assumptions are two and so that it can split the matrix. | [
"If",
"there",
"is",
"a",
"zero",
"on",
"the",
"diagonal",
"element",
"the",
"off",
"diagonal",
"element",
"needs",
"pushed",
"off",
"so",
"that",
"all",
"the",
"algorithms",
"assumptions",
"are",
"two",
"and",
"so",
"that",
"it",
"can",
"split",
"the",
... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L673-L685 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.rotatorPushRight | private void rotatorPushRight( int m )
{
double b11 = off[m];
double b21 = diag[m+1];
computeRotator(b21,-b11);
// apply rotator on the right
off[m] = 0;
diag[m+1] = b21*c-b11*s;
if( m+2 < N) {
double b22 = off[m+1];
off[m+1] = b22*c;
bulge = b22*s;
} else {
bulge = 0;
}
// SimpleMatrix Q = createQ(m,m+1, c, s, true);
// B=Q.mult(B);
//
// B.print();
// printMatrix();
// System.out.println(" bulge = "+bulge);
// System.out.println();
if( Ut != null ) {
updateRotator(Ut,m,m+1,c,s);
// SimpleMatrix.wrap(Ut).mult(B).mult(SimpleMatrix.wrap(Vt).transpose()).print();
// printMatrix();
// System.out.println("bulge = "+bulge);
// System.out.println();
}
} | java | private void rotatorPushRight( int m )
{
double b11 = off[m];
double b21 = diag[m+1];
computeRotator(b21,-b11);
// apply rotator on the right
off[m] = 0;
diag[m+1] = b21*c-b11*s;
if( m+2 < N) {
double b22 = off[m+1];
off[m+1] = b22*c;
bulge = b22*s;
} else {
bulge = 0;
}
// SimpleMatrix Q = createQ(m,m+1, c, s, true);
// B=Q.mult(B);
//
// B.print();
// printMatrix();
// System.out.println(" bulge = "+bulge);
// System.out.println();
if( Ut != null ) {
updateRotator(Ut,m,m+1,c,s);
// SimpleMatrix.wrap(Ut).mult(B).mult(SimpleMatrix.wrap(Vt).transpose()).print();
// printMatrix();
// System.out.println("bulge = "+bulge);
// System.out.println();
}
} | [
"private",
"void",
"rotatorPushRight",
"(",
"int",
"m",
")",
"{",
"double",
"b11",
"=",
"off",
"[",
"m",
"]",
";",
"double",
"b21",
"=",
"diag",
"[",
"m",
"+",
"1",
"]",
";",
"computeRotator",
"(",
"b21",
",",
"-",
"b11",
")",
";",
"// apply rotato... | Start pushing the element off to the right. | [
"Start",
"pushing",
"the",
"element",
"off",
"to",
"the",
"right",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L690-L725 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.rotatorPushRight2 | private void rotatorPushRight2( int m , int offset)
{
double b11 = bulge;
double b12 = diag[m+offset];
computeRotator(b12,-b11);
diag[m+offset] = b12*c-b11*s;
if( m+offset<N-1) {
double b22 = off[m+offset];
off[m+offset] = b22*c;
bulge = b22*s;
}
// SimpleMatrix Q = createQ(m,m+offset, c, s, true);
// B=Q.mult(B);
//
// B.print();
// printMatrix();
// System.out.println(" bulge = "+bulge);
// System.out.println();
if( Ut != null ) {
updateRotator(Ut,m,m+offset,c,s);
// SimpleMatrix.wrap(Ut).mult(B).mult(SimpleMatrix.wrap(Vt).transpose()).print();
// printMatrix();
// System.out.println("bulge = "+bulge);
// System.out.println();
}
} | java | private void rotatorPushRight2( int m , int offset)
{
double b11 = bulge;
double b12 = diag[m+offset];
computeRotator(b12,-b11);
diag[m+offset] = b12*c-b11*s;
if( m+offset<N-1) {
double b22 = off[m+offset];
off[m+offset] = b22*c;
bulge = b22*s;
}
// SimpleMatrix Q = createQ(m,m+offset, c, s, true);
// B=Q.mult(B);
//
// B.print();
// printMatrix();
// System.out.println(" bulge = "+bulge);
// System.out.println();
if( Ut != null ) {
updateRotator(Ut,m,m+offset,c,s);
// SimpleMatrix.wrap(Ut).mult(B).mult(SimpleMatrix.wrap(Vt).transpose()).print();
// printMatrix();
// System.out.println("bulge = "+bulge);
// System.out.println();
}
} | [
"private",
"void",
"rotatorPushRight2",
"(",
"int",
"m",
",",
"int",
"offset",
")",
"{",
"double",
"b11",
"=",
"bulge",
";",
"double",
"b12",
"=",
"diag",
"[",
"m",
"+",
"offset",
"]",
";",
"computeRotator",
"(",
"b12",
",",
"-",
"b11",
")",
";",
"... | Used to finish up pushing the bulge off the matrix. | [
"Used",
"to",
"finish",
"up",
"pushing",
"the",
"bulge",
"off",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L730-L761 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java | SvdImplicitQrAlgorithm_DDRM.exceptionShift | public void exceptionShift() {
numExceptional++;
double mag = 0.05 * numExceptional;
if (mag > 1.0) mag = 1.0;
double angle = 2.0 * UtilEjml.PI * (rand.nextDouble() - 0.5) * mag;
performImplicitSingleStep(0, angle, true);
// allow more convergence time
nextExceptional = steps + exceptionalThresh; // (numExceptional+1)*
} | java | public void exceptionShift() {
numExceptional++;
double mag = 0.05 * numExceptional;
if (mag > 1.0) mag = 1.0;
double angle = 2.0 * UtilEjml.PI * (rand.nextDouble() - 0.5) * mag;
performImplicitSingleStep(0, angle, true);
// allow more convergence time
nextExceptional = steps + exceptionalThresh; // (numExceptional+1)*
} | [
"public",
"void",
"exceptionShift",
"(",
")",
"{",
"numExceptional",
"++",
";",
"double",
"mag",
"=",
"0.05",
"*",
"numExceptional",
";",
"if",
"(",
"mag",
">",
"1.0",
")",
"mag",
"=",
"1.0",
";",
"double",
"angle",
"=",
"2.0",
"*",
"UtilEjml",
".",
... | It is possible for the QR algorithm to get stuck in a loop because of symmetries. This happens
more often with larger matrices. By taking a random step it can break the symmetry and finish. | [
"It",
"is",
"possible",
"for",
"the",
"QR",
"algorithm",
"to",
"get",
"stuck",
"in",
"a",
"loop",
"because",
"of",
"symmetries",
".",
"This",
"happens",
"more",
"often",
"with",
"larger",
"matrices",
".",
"By",
"taking",
"a",
"random",
"step",
"it",
"can... | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/implicitqr/SvdImplicitQrAlgorithm_DDRM.java#L767-L777 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_DDRM.java | SvdImplicitQrDecompose_DDRM.computeUWV | private boolean computeUWV() {
bidiag.getDiagonal(diag,off);
qralg.setMatrix(numRowsT,numColsT,diag,off);
// long pointA = System.currentTimeMillis();
// compute U and V matrices
if( computeU )
Ut = bidiag.getU(Ut,true,compact);
if( computeV )
Vt = bidiag.getV(Vt,true,compact);
qralg.setFastValues(false);
if( computeU )
qralg.setUt(Ut);
else
qralg.setUt(null);
if( computeV )
qralg.setVt(Vt);
else
qralg.setVt(null);
// long pointB = System.currentTimeMillis();
boolean ret = !qralg.process();
// long pointC = System.currentTimeMillis();
// System.out.println(" compute UV "+(pointB-pointA)+" QR = "+(pointC-pointB));
return ret;
} | java | private boolean computeUWV() {
bidiag.getDiagonal(diag,off);
qralg.setMatrix(numRowsT,numColsT,diag,off);
// long pointA = System.currentTimeMillis();
// compute U and V matrices
if( computeU )
Ut = bidiag.getU(Ut,true,compact);
if( computeV )
Vt = bidiag.getV(Vt,true,compact);
qralg.setFastValues(false);
if( computeU )
qralg.setUt(Ut);
else
qralg.setUt(null);
if( computeV )
qralg.setVt(Vt);
else
qralg.setVt(null);
// long pointB = System.currentTimeMillis();
boolean ret = !qralg.process();
// long pointC = System.currentTimeMillis();
// System.out.println(" compute UV "+(pointB-pointA)+" QR = "+(pointC-pointB));
return ret;
} | [
"private",
"boolean",
"computeUWV",
"(",
")",
"{",
"bidiag",
".",
"getDiagonal",
"(",
"diag",
",",
"off",
")",
";",
"qralg",
".",
"setMatrix",
"(",
"numRowsT",
",",
"numColsT",
",",
"diag",
",",
"off",
")",
";",
"// long pointA = System.currentTimeMilli... | Compute singular values and U and V at the same time | [
"Compute",
"singular",
"values",
"and",
"U",
"and",
"V",
"at",
"the",
"same",
"time"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_DDRM.java#L232-L261 | train |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_DDRM.java | SvdImplicitQrDecompose_DDRM.makeSingularPositive | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = qralg.getSingularValue(i);
if( val < 0 ) {
singularValues[i] = 0.0 - val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.set(j, 0.0 - Ut.get(j));
}
}
} else {
singularValues[i] = val;
}
}
} | java | private void makeSingularPositive() {
numSingular = qralg.getNumberOfSingularValues();
singularValues = qralg.getSingularValues();
for( int i = 0; i < numSingular; i++ ) {
double val = qralg.getSingularValue(i);
if( val < 0 ) {
singularValues[i] = 0.0 - val;
if( computeU ) {
// compute the results of multiplying it by an element of -1 at this location in
// a diagonal matrix.
int start = i* Ut.numCols;
int stop = start+ Ut.numCols;
for( int j = start; j < stop; j++ ) {
Ut.set(j, 0.0 - Ut.get(j));
}
}
} else {
singularValues[i] = val;
}
}
} | [
"private",
"void",
"makeSingularPositive",
"(",
")",
"{",
"numSingular",
"=",
"qralg",
".",
"getNumberOfSingularValues",
"(",
")",
";",
"singularValues",
"=",
"qralg",
".",
"getSingularValues",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<"... | With the QR algorithm it is possible for the found singular values to be negative. This
makes them all positive by multiplying it by a diagonal matrix that has | [
"With",
"the",
"QR",
"algorithm",
"it",
"is",
"possible",
"for",
"the",
"found",
"singular",
"values",
"to",
"be",
"negative",
".",
"This",
"makes",
"them",
"all",
"positive",
"by",
"multiplying",
"it",
"by",
"a",
"diagonal",
"matrix",
"that",
"has"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/decomposition/svd/SvdImplicitQrDecompose_DDRM.java#L306-L330 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.checkDuplicateElements | public static boolean checkDuplicateElements(DMatrixSparseCSC A ) {
A = A.copy(); // create a copy so that it doesn't modify A
A.sortIndices(null);
return !checkSortedFlag(A);
} | java | public static boolean checkDuplicateElements(DMatrixSparseCSC A ) {
A = A.copy(); // create a copy so that it doesn't modify A
A.sortIndices(null);
return !checkSortedFlag(A);
} | [
"public",
"static",
"boolean",
"checkDuplicateElements",
"(",
"DMatrixSparseCSC",
"A",
")",
"{",
"A",
"=",
"A",
".",
"copy",
"(",
")",
";",
"// create a copy so that it doesn't modify A",
"A",
".",
"sortIndices",
"(",
"null",
")",
";",
"return",
"!",
"checkSorte... | Checks for duplicate elements. A is sorted
@param A Matrix to be tested.
@return true if duplicates or false if false duplicates | [
"Checks",
"for",
"duplicate",
"elements",
".",
"A",
"is",
"sorted"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L105-L109 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.changeSign | public static void changeSign(DMatrixSparseCSC A , DMatrixSparseCSC B ) {
if( A != B ) {
B.copyStructure(A);
}
for (int i = 0; i < A.nz_length; i++) {
B.nz_values[i] = -A.nz_values[i];
}
} | java | public static void changeSign(DMatrixSparseCSC A , DMatrixSparseCSC B ) {
if( A != B ) {
B.copyStructure(A);
}
for (int i = 0; i < A.nz_length; i++) {
B.nz_values[i] = -A.nz_values[i];
}
} | [
"public",
"static",
"void",
"changeSign",
"(",
"DMatrixSparseCSC",
"A",
",",
"DMatrixSparseCSC",
"B",
")",
"{",
"if",
"(",
"A",
"!=",
"B",
")",
"{",
"B",
".",
"copyStructure",
"(",
"A",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"... | B = -A. Changes the sign of elements in A and stores it in B. A and B can be the same instance.
@param A (Input) Matrix. Not modified.
@param B (Output) Matrix. Modified. | [
"B",
"=",
"-",
"A",
".",
"Changes",
"the",
"sign",
"of",
"elements",
"in",
"A",
"and",
"stores",
"it",
"in",
"B",
".",
"A",
"and",
"B",
"can",
"be",
"the",
"same",
"instance",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L442-L450 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.elementMin | public static double elementMin( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
// if every element is assigned a value then the first element can be a minimum.
// Otherwise zero needs to be considered
double min = A.isFull() ? A.nz_values[0] : 0;
for(int i = 0; i < A.nz_length; i++ ) {
double val = A.nz_values[i];
if( val < min ) {
min = val;
}
}
return min;
} | java | public static double elementMin( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
// if every element is assigned a value then the first element can be a minimum.
// Otherwise zero needs to be considered
double min = A.isFull() ? A.nz_values[0] : 0;
for(int i = 0; i < A.nz_length; i++ ) {
double val = A.nz_values[i];
if( val < min ) {
min = val;
}
}
return min;
} | [
"public",
"static",
"double",
"elementMin",
"(",
"DMatrixSparseCSC",
"A",
")",
"{",
"if",
"(",
"A",
".",
"nz_length",
"==",
"0",
")",
"return",
"0",
";",
"// if every element is assigned a value then the first element can be a minimum.",
"// Otherwise zero needs to be consi... | Returns the value of the element with the minimum value
@param A (Input) Matrix. Not modified.
@return scalar | [
"Returns",
"the",
"value",
"of",
"the",
"element",
"with",
"the",
"minimum",
"value"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L497-L512 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.elementMax | public static double elementMax( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
// if every element is assigned a value then the first element can be a max.
// Otherwise zero needs to be considered
double max = A.isFull() ? A.nz_values[0] : 0;
for(int i = 0; i < A.nz_length; i++ ) {
double val = A.nz_values[i];
if( val > max ) {
max = val;
}
}
return max;
} | java | public static double elementMax( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
// if every element is assigned a value then the first element can be a max.
// Otherwise zero needs to be considered
double max = A.isFull() ? A.nz_values[0] : 0;
for(int i = 0; i < A.nz_length; i++ ) {
double val = A.nz_values[i];
if( val > max ) {
max = val;
}
}
return max;
} | [
"public",
"static",
"double",
"elementMax",
"(",
"DMatrixSparseCSC",
"A",
")",
"{",
"if",
"(",
"A",
".",
"nz_length",
"==",
"0",
")",
"return",
"0",
";",
"// if every element is assigned a value then the first element can be a max.",
"// Otherwise zero needs to be considere... | Returns the value of the element with the largest value
@param A (Input) Matrix. Not modified.
@return scalar | [
"Returns",
"the",
"value",
"of",
"the",
"element",
"with",
"the",
"largest",
"value"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L519-L534 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.elementSum | public static double elementSum( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
double sum = 0;
for(int i = 0; i < A.nz_length; i++ ) {
sum += A.nz_values[i];
}
return sum;
} | java | public static double elementSum( DMatrixSparseCSC A ) {
if( A.nz_length == 0)
return 0;
double sum = 0;
for(int i = 0; i < A.nz_length; i++ ) {
sum += A.nz_values[i];
}
return sum;
} | [
"public",
"static",
"double",
"elementSum",
"(",
"DMatrixSparseCSC",
"A",
")",
"{",
"if",
"(",
"A",
".",
"nz_length",
"==",
"0",
")",
"return",
"0",
";",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
... | Sum of all elements
@param A (Input) Matrix. Not modified.
@return scalar | [
"Sum",
"of",
"all",
"elements"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L542-L552 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.columnMaxAbs | public static void columnMaxAbs( DMatrixSparseCSC A , double []values ) {
if( values.length < A.numCols )
throw new IllegalArgumentException("Array is too small. "+values.length+" < "+A.numCols);
for (int i = 0; i < A.numCols; i++) {
int idx0 = A.col_idx[i];
int idx1 = A.col_idx[i+1];
double maxabs = 0;
for (int j = idx0; j < idx1; j++) {
double v = Math.abs(A.nz_values[j]);
if( v > maxabs )
maxabs = v;
}
values[i] = maxabs;
}
} | java | public static void columnMaxAbs( DMatrixSparseCSC A , double []values ) {
if( values.length < A.numCols )
throw new IllegalArgumentException("Array is too small. "+values.length+" < "+A.numCols);
for (int i = 0; i < A.numCols; i++) {
int idx0 = A.col_idx[i];
int idx1 = A.col_idx[i+1];
double maxabs = 0;
for (int j = idx0; j < idx1; j++) {
double v = Math.abs(A.nz_values[j]);
if( v > maxabs )
maxabs = v;
}
values[i] = maxabs;
}
} | [
"public",
"static",
"void",
"columnMaxAbs",
"(",
"DMatrixSparseCSC",
"A",
",",
"double",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"values",
".",
"length",
"<",
"A",
".",
"numCols",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Array is too small. \"... | Finds the maximum abs in each column of A and stores it into values
@param A (Input) Matrix
@param values (Output) storage for column max abs | [
"Finds",
"the",
"maximum",
"abs",
"in",
"each",
"column",
"of",
"A",
"and",
"stores",
"it",
"into",
"values"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L579-L595 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.diag | public static DMatrixSparseCSC diag(double... values ) {
int N = values.length;
return diag(new DMatrixSparseCSC(N,N,N),values,0,N);
} | java | public static DMatrixSparseCSC diag(double... values ) {
int N = values.length;
return diag(new DMatrixSparseCSC(N,N,N),values,0,N);
} | [
"public",
"static",
"DMatrixSparseCSC",
"diag",
"(",
"double",
"...",
"values",
")",
"{",
"int",
"N",
"=",
"values",
".",
"length",
";",
"return",
"diag",
"(",
"new",
"DMatrixSparseCSC",
"(",
"N",
",",
"N",
",",
"N",
")",
",",
"values",
",",
"0",
","... | Returns a diagonal matrix with the specified diagonal elements.
@param values values of diagonal elements
@return A diagonal matrix | [
"Returns",
"a",
"diagonal",
"matrix",
"with",
"the",
"specified",
"diagonal",
"elements",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L708-L711 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.permutationVector | public static void permutationVector( DMatrixSparseCSC P , int[] vector) {
if( P.numCols != P.numRows ) {
throw new MatrixDimensionException("Expected a square matrix");
} else if( P.nz_length != P.numCols ) {
throw new IllegalArgumentException("Expected N non-zero elements in permutation matrix");
} else if( vector.length < P.numCols ) {
throw new IllegalArgumentException("vector is too short");
}
int M = P.numCols;
for (int i = 0; i < M; i++) {
if( P.col_idx[i+1] != i+1 )
throw new IllegalArgumentException("Unexpected number of elements in a column");
vector[P.nz_rows[i]] = i;
}
} | java | public static void permutationVector( DMatrixSparseCSC P , int[] vector) {
if( P.numCols != P.numRows ) {
throw new MatrixDimensionException("Expected a square matrix");
} else if( P.nz_length != P.numCols ) {
throw new IllegalArgumentException("Expected N non-zero elements in permutation matrix");
} else if( vector.length < P.numCols ) {
throw new IllegalArgumentException("vector is too short");
}
int M = P.numCols;
for (int i = 0; i < M; i++) {
if( P.col_idx[i+1] != i+1 )
throw new IllegalArgumentException("Unexpected number of elements in a column");
vector[P.nz_rows[i]] = i;
}
} | [
"public",
"static",
"void",
"permutationVector",
"(",
"DMatrixSparseCSC",
"P",
",",
"int",
"[",
"]",
"vector",
")",
"{",
"if",
"(",
"P",
".",
"numCols",
"!=",
"P",
".",
"numRows",
")",
"{",
"throw",
"new",
"MatrixDimensionException",
"(",
"\"Expected a squar... | Converts the permutation matrix into a vector
@param P (Input) Permutation matrix
@param vector (Output) Permutation vector | [
"Converts",
"the",
"permutation",
"matrix",
"into",
"a",
"vector"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L842-L859 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.permutationInverse | public static void permutationInverse( int []original , int []inverse , int length ) {
for (int i = 0; i < length; i++) {
inverse[original[i]] = i;
}
} | java | public static void permutationInverse( int []original , int []inverse , int length ) {
for (int i = 0; i < length; i++) {
inverse[original[i]] = i;
}
} | [
"public",
"static",
"void",
"permutationInverse",
"(",
"int",
"[",
"]",
"original",
",",
"int",
"[",
"]",
"inverse",
",",
"int",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"inverse",
"... | Computes the inverse permutation vector
@param original Original permutation vector
@param inverse It's inverse | [
"Computes",
"the",
"inverse",
"permutation",
"vector"
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L867-L871 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.zero | public static void zero( DMatrixSparseCSC A , int row0, int row1, int col0, int col1 ) {
for (int col = col1-1; col >= col0; col--) {
int numRemoved = 0;
int idx0 = A.col_idx[col], idx1 = A.col_idx[col+1];
for (int i = idx0; i < idx1; i++) {
int row = A.nz_rows[i];
// if sorted a faster technique could be used
if( row >= row0 && row < row1 ) {
numRemoved++;
} else if( numRemoved > 0 ){
A.nz_rows[i-numRemoved]=row;
A.nz_values[i-numRemoved]=A.nz_values[i];
}
}
if( numRemoved > 0 ) {
// this could be done more intelligently. Each time a column is adjusted all the columns are adjusted
// after it. Maybe accumulate the changes in each column and do it in one pass? Need an array to store
// those results though
for (int i = idx1; i < A.nz_length; i++) {
A.nz_rows[i - numRemoved] = A.nz_rows[i];
A.nz_values[i - numRemoved] = A.nz_values[i];
}
A.nz_length -= numRemoved;
for (int i = col+1; i <= A.numCols; i++) {
A.col_idx[i] -= numRemoved;
}
}
}
} | java | public static void zero( DMatrixSparseCSC A , int row0, int row1, int col0, int col1 ) {
for (int col = col1-1; col >= col0; col--) {
int numRemoved = 0;
int idx0 = A.col_idx[col], idx1 = A.col_idx[col+1];
for (int i = idx0; i < idx1; i++) {
int row = A.nz_rows[i];
// if sorted a faster technique could be used
if( row >= row0 && row < row1 ) {
numRemoved++;
} else if( numRemoved > 0 ){
A.nz_rows[i-numRemoved]=row;
A.nz_values[i-numRemoved]=A.nz_values[i];
}
}
if( numRemoved > 0 ) {
// this could be done more intelligently. Each time a column is adjusted all the columns are adjusted
// after it. Maybe accumulate the changes in each column and do it in one pass? Need an array to store
// those results though
for (int i = idx1; i < A.nz_length; i++) {
A.nz_rows[i - numRemoved] = A.nz_rows[i];
A.nz_values[i - numRemoved] = A.nz_values[i];
}
A.nz_length -= numRemoved;
for (int i = col+1; i <= A.numCols; i++) {
A.col_idx[i] -= numRemoved;
}
}
}
} | [
"public",
"static",
"void",
"zero",
"(",
"DMatrixSparseCSC",
"A",
",",
"int",
"row0",
",",
"int",
"row1",
",",
"int",
"col0",
",",
"int",
"col1",
")",
"{",
"for",
"(",
"int",
"col",
"=",
"col1",
"-",
"1",
";",
"col",
">=",
"col0",
";",
"col",
"--... | Zeros an inner rectangle inside the matrix.
@param A Matrix that is to be modified.
@param row0 Start row.
@param row1 Stop row+1.
@param col0 Start column.
@param col1 Stop column+1. | [
"Zeros",
"an",
"inner",
"rectangle",
"inside",
"the",
"matrix",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L1529-L1562 | train |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.removeZeros | public static void removeZeros( DMatrixSparseCSC input , DMatrixSparseCSC output , double tol ) {
ImplCommonOps_DSCC.removeZeros(input,output,tol);
} | java | public static void removeZeros( DMatrixSparseCSC input , DMatrixSparseCSC output , double tol ) {
ImplCommonOps_DSCC.removeZeros(input,output,tol);
} | [
"public",
"static",
"void",
"removeZeros",
"(",
"DMatrixSparseCSC",
"input",
",",
"DMatrixSparseCSC",
"output",
",",
"double",
"tol",
")",
"{",
"ImplCommonOps_DSCC",
".",
"removeZeros",
"(",
"input",
",",
"output",
",",
"tol",
")",
";",
"}"
] | Copies all elements from input into output which are > tol.
@param input (Input) input matrix. Not modified.
@param output (Output) Output matrix. Modified and shaped to match input.
@param tol Tolerance for defining zero | [
"Copies",
"all",
"elements",
"from",
"input",
"into",
"output",
"which",
"are",
">",
";",
"tol",
"."
] | 1444680cc487af5e866730e62f48f5f9636850d9 | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L1761-L1763 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.