Examples of AVector


Examples of mikera.vectorz.AVector

    if (rc == 1) return getRowView(0);
   
    int cc= columnCount();
    if (cc==1) return getColumn(0);

    AVector v = getRowView(0);
    for (int i = 1; i < rc; i++) {
      v = Vectorz.join(v, getRowView(i));
    }
    return v;
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  @Override
  public AVector getRowView(int row) {
    int blockIndex=getRowBlockIndex(row);
    int blockPos=getBlockRowStart(blockIndex);
    int n=columnBlockCount();
    AVector v=Vector0.INSTANCE;
    for (int i=0; i<n; i++) {
      v=v.join(getBlock(blockIndex,i).getRowView(row-blockPos));
    }
    return v;
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  @Override
  public AVector getColumnView(int col) {
    int blockIndex=getColumnBlockIndex(col);
    int blockPos=getBlockColumnStart(blockIndex);
    int n=rowBlockCount();
    AVector v=Vector0.INSTANCE;
    for (int i=0; i<n; i++) {
      v=v.join(getBlock(i,blockIndex).getColumnView(col-blockPos));
    }
    return v;
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  public static SparseColumnMatrix create(AMatrix source) {
    int cc=source.columnCount();
    int rc=source.rowCount();
    AVector[] data = new AVector[cc];
    for (int i=0; i<cc; i++) {
      AVector col = source.getColumn(i);
      if (!col.isZero())
          data[i] = Vectorz.createSparse(col);
    }
    return new SparseColumnMatrix(data,rc,cc);
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  }

  @Override
  public void set(int i, int j, double value) {
    checkIndex(i,j);
    AVector v = unsafeGetVec(j);
    if (v==null) {
      if (value == 0.0)
                return;
      v = Vectorz.createSparseMutable(rows);
    } else if (v.isFullyMutable()) {
      v.set(i,value);
      return;
    } else {
      v = v.sparseClone();     
    }
    unsafeSetVec(j, v);
    v.set(i, value);
  }
View Full Code Here

Examples of mikera.vectorz.AVector

    return getColumn(column).unsafeGet(row);
  }

  @Override
  public void unsafeSet(int row, int column, double value) {
    AVector v=getColumn(column);
    if (v.isFullyMutable()) {
      v.unsafeSet(row,value);
    } else {
      v=v.mutable();
      replaceColumn(column,v);
      v.unsafeSet(row,value);
    }
  }
View Full Code Here

Examples of mikera.vectorz.AVector

    }
  }
 
  @Override
  public void addAt(int i, int j, double d) {
    AVector v=getColumn(j);
    if (v.isFullyMutable()) {
      v.addAt(i, d);
    } else {
      v=v.mutable();
      v.addAt(i, d);
      replaceColumn(j,v);
    }
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  }
 
  @Override
  public void addToArray(double[] targetData, int offset) {
        for (int i = 0; i < cols; ++i) {
      AVector v = unsafeGetVec(i);
      if (v != null) v.addToArray(targetData, offset+i, cols);
    }
  }
View Full Code Here

Examples of mikera.vectorz.AVector

      if (v != null) v.addToArray(targetData, offset+i, cols);
    }
  }
 
  private AVector ensureMutableColumn(int i) {
    AVector v = unsafeGetVec(i);
    if (v == null) {
      AVector nv=SparseIndexedVector.createLength(rows);
            unsafeSetVec(i, nv);
      return nv;
    }
    if (v.isFullyMutable()) return v;
    AVector mv=v.mutable();
    unsafeSetVec(i, mv);
    return mv;
  }
View Full Code Here

Examples of mikera.vectorz.AVector

  }
 
  @Override
  public AVector getColumn(int i) {
    if ((i<0)||(i>=cols)) throw new IndexOutOfBoundsException(ErrorMessages.invalidSlice(this, 1, i));
    AVector v = unsafeGetVec(i);
    if (v==null) return emptyColumn;
    return v;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.