Package mikera.arrayz

Examples of mikera.arrayz.INDArray


import mikera.vectorz.util.Errors;

public class ErrorThrow {

  public static void main(String[] args) throws Throwable {
    INDArray a=IdentityMatrix.create(10);
    throw Errors.immutable(a);
  }
View Full Code Here


    return reorder(0,order);
 
 
  @Override
  public AMatrix reorder(int dim, int[] order) {
    INDArray o=super.reorder(dim,order);
    if (o instanceof AMatrix) return (AMatrix)o;
    return Matrixx.toMatrix(o);
 
View Full Code Here

   
    int[] off=new int[2];
    int[] shp=getShapeClone();
   
    shp[dimension]=shift;
    INDArray right=subArray(off,shp);
    shp[dimension]=n-shift;
    off[dimension]=shift;
    INDArray left=subArray(off,shp);
    return left.join(right,dimension);
  }
View Full Code Here

    } else {
      if (rowCount()!=targetShape[tdims-2]||(columnCount()!=targetShape[tdims-1])) {
        throw new IllegalArgumentException(ErrorMessages.incompatibleBroadcast(this, targetShape));       
      }
      int n=targetShape[0];
      INDArray s=broadcast(Arrays.copyOfRange(targetShape, 1, tdims));
      return SliceArray.repeat(s,n);
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public INDArray broadcastCloneLike(INDArray target) {
    INDArray r=this;
    if (target.dimensionality()>2) r=r.broadcastLike(target);
    return r.clone();
  }
View Full Code Here

  @Override
  public final INDArray addCopy(INDArray a) {
    if (a instanceof AMatrix) {
      return addCopy((AMatrix)a);
    } else {
      INDArray r=this.broadcastCloneLike(a);
      r.add(a);
      return r;
    }
  }
View Full Code Here

import mikera.arrayz.INDArray;

public class TestingUtils {

  public static INDArray createRandomLike(INDArray a, long seed) {
    INDArray r=Arrayz.newArray(a.getShape());
    Arrayz.fillNormal(r, seed);
    return r;
  }
View Full Code Here

 
  @Test
  public void testBroadCast() {
    Vector2 v=Vector2.of(1,2);
   
    INDArray a=v.broadcast(1,3,2);
    assertEquals(v,a.slice(0).slice(1));
  }
View Full Code Here

    } else if (a.dimensionality()<=2) {
      return innerProduct(Arrayz.create(a));
    }
    int len=checkLength(a.sliceCount());
    List<INDArray> al=a.getSliceViews();
    INDArray result=Arrayz.newArray(al.get(0).getShape());
    for (int i=0; i<len; i++) {
      // TODO: make faster with addMultiple?
      result.add(al.get(i).innerProduct(get(i)));
    }
    return result;
  }
View Full Code Here

      for (int i=0; i<n; i++) {vs[i]=this;}
      return Matrixx.createFromVectors(vs);
    } else {
      int n=targetShape[0];
      if (len!=targetShape[tdims-1]) throw new IllegalArgumentException(ErrorMessages.incompatibleBroadcast(this, targetShape));
      INDArray s=broadcast(Arrays.copyOfRange(targetShape, 1, tdims));
      return SliceArray.repeat(s,n);
    }
  }
View Full Code Here

TOP

Related Classes of mikera.arrayz.INDArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.