Ejemplo n.º 1
0
  /** Multiply arguments element by element. Returns result. */
  public Object mul(Object param1, Object param2) throws ParseException {

    if (param1 instanceof MatrixValueI && param2 instanceof MatrixValueI) {
      return mul((MatrixValueI) param1, (MatrixValueI) param2);
    } else if (param1 instanceof MatrixValueI) {
      MatrixValueI l = (MatrixValueI) param1;
      MatrixValueI res = Tensor.getInstance(l.getDim());
      for (int i = 0; i < res.getNumEles(); ++i) res.setEle(i, super.mul(l.getEle(i), param2));
      return res;
    } else if (param2 instanceof MatrixValueI) {
      MatrixValueI r = (MatrixValueI) param2;
      MatrixValueI res = Tensor.getInstance(r.getDim());
      for (int i = 0; i < res.getNumEles(); ++i) res.setEle(i, super.mul(param1, r.getEle(i)));
      return res;
    }
    return super.mul(param1, param2);
  }
Ejemplo n.º 2
0
 public Object mul(MatrixValueI param1, MatrixValueI param2) throws ParseException {
   Dimensions dims = this.calcDim(new Dimensions[] {param1.getDim(), param2.getDim()});
   MatrixValueI res = Tensor.getInstance(dims);
   return this.calcValue(res, new MatrixValueI[] {param1, param2});
 }