use of gov.sandia.n2a.linear.MatrixDense in project n2a by frothga.
the class Scalar method subtract.
public Type subtract(Type that) throws EvaluationException {
if (that instanceof Scalar)
return new Scalar(value - ((Scalar) that).value);
if (that instanceof Matrix) {
Matrix B = (Matrix) that;
int w = B.columns();
int h = B.rows();
MatrixDense result = new MatrixDense(h, w);
for (int c = 0; c < w; c++) {
for (int r = 0; r < h; r++) {
result.set(r, c, value - B.get(r, c));
}
}
return result;
}
throw new EvaluationException("type mismatch");
}
use of gov.sandia.n2a.linear.MatrixDense in project n2a by frothga.
the class Scalar method max.
public Type max(Type that) {
if (that instanceof Scalar)
return new Scalar(Math.max(value, ((Scalar) that).value));
if (that instanceof Matrix) {
Matrix B = (Matrix) that;
int w = B.columns();
int h = B.rows();
MatrixDense result = new MatrixDense(h, w);
for (int c = 0; c < w; c++) {
for (int r = 0; r < h; r++) {
result.set(r, c, Math.max(value, B.get(r, c)));
}
}
return result;
}
throw new EvaluationException("type mismatch");
}
use of gov.sandia.n2a.linear.MatrixDense in project n2a by frothga.
the class Scalar method GT.
public Type GT(Type that) throws EvaluationException {
if (that instanceof Scalar)
return new Scalar((value > ((Scalar) that).value) ? 1 : 0);
if (that instanceof Matrix) {
Matrix B = (Matrix) that;
int w = B.columns();
int h = B.rows();
MatrixDense result = new MatrixDense(h, w);
for (int c = 0; c < w; c++) {
for (int r = 0; r < h; r++) {
result.set(r, c, (value > B.get(r, c)) ? 1 : 0);
}
}
return result;
}
throw new EvaluationException("type mismatch");
}
use of gov.sandia.n2a.linear.MatrixDense in project n2a by frothga.
the class Scalar method power.
public Type power(Type that) throws EvaluationException {
if (that instanceof Scalar)
return new Scalar(Math.pow(value, ((Scalar) that).value));
if (that instanceof Matrix) {
Matrix B = (Matrix) that;
int w = B.columns();
int h = B.rows();
MatrixDense result = new MatrixDense(h, w);
for (int c = 0; c < w; c++) {
for (int r = 0; r < h; r++) {
result.set(r, c, Math.pow(value, B.get(r, c)));
}
}
return result;
}
throw new EvaluationException("type mismatch");
}
use of gov.sandia.n2a.linear.MatrixDense in project n2a by frothga.
the class Scalar method LE.
public Type LE(Type that) throws EvaluationException {
if (that instanceof Scalar)
return new Scalar((value <= ((Scalar) that).value) ? 1 : 0);
if (that instanceof Matrix) {
Matrix B = (Matrix) that;
int w = B.columns();
int h = B.rows();
MatrixDense result = new MatrixDense(h, w);
for (int c = 0; c < w; c++) {
for (int r = 0; r < h; r++) {
result.set(r, c, (value <= B.get(r, c)) ? 1 : 0);
}
}
return result;
}
throw new EvaluationException("type mismatch");
}
Aggregations