Exemplo n.º 1
0
 @Override
 public CalcObject divide(CalcObject b) {
   if (b.getType() == CType.INTEGER) {
     IntObject bInt = (IntObject) b;
     return new MatrixObject(matrix.times(1.0 / ((double) bInt.getValue())));
   } else if (b.getType() == CType.MATRIX) {
     MatrixObject bMatrix = (MatrixObject) b;
     throw new UnsupportedOperationException("Have not implemented / for matricies yet");
   } else {
     throw new IllegalArgumentException("Bad object type: " + b.getType());
   }
 }
Exemplo n.º 2
0
 @Override
 public CalcObject add(CalcObject b) {
   if (b.getType() == CType.INTEGER) {
     IntObject bInt = (IntObject) b;
     return scalarAdd(bInt.getValue());
   } else if (b.getType() == CType.MATRIX) {
     MatrixObject bMatrix = (MatrixObject) b;
     return new MatrixObject(this.matrix.plus(bMatrix.matrix));
   } else {
     throw new IllegalArgumentException("Bad object type: " + b.getType());
   }
 }
Exemplo n.º 3
0
 @Override
 public CalcObject multiply(CalcObject b) {
   if (b.getType() == CType.INTEGER) {
     IntObject bInt = (IntObject) b;
     return new MatrixObject(matrix.times(bInt.getValue()));
   } else if (b.getType() == CType.MATRIX) {
     MatrixObject bMatrix = (MatrixObject) b;
     return new MatrixObject(matrix.times(bMatrix.matrix));
   } else {
     throw new IllegalArgumentException("Bad object type: " + b.getType());
   }
 }
Exemplo n.º 4
0
 public MatrixObject(IntObject i) {
   super(CType.MATRIX);
   matrix = new Matrix(1, 1, (double) i.getValue());
 }