gpt4 book ai didi

mikera.vectorz.impl.ZeroVector.create()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:13:32 26 4
gpt4 key购买 nike

本文整理了Java中mikera.vectorz.impl.ZeroVector.create()方法的一些代码示例,展示了ZeroVector.create()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeroVector.create()方法的具体详情如下:
包路径:mikera.vectorz.impl.ZeroVector
类名称:ZeroVector
方法名:create

ZeroVector.create介绍

[英]Create a ZeroVector with the specified number of dimensions
[中]创建具有指定维数的零向量

代码示例

代码示例来源:origin: net.mikera/vectorz

/**
 * Returns an immutable vector of zeros
 * @param dimensions
 * @return
 */
public static AVector immutableZeroVector(int dimensions) {
  return ZeroVector.create(dimensions);
}

代码示例来源:origin: mikera/vectorz

/**
 * Returns an immutable vector of zeros
 * @param dimensions
 * @return
 */
public static AVector immutableZeroVector(int dimensions) {
  return ZeroVector.create(dimensions);
}

代码示例来源:origin: mikera/vectorz

/**
 * Creates an immutable zero vector of the specified length.
 * @param l
 * @return
 */
public static AVector createZeroVector(long l) {
  if (l==0) return Vector0.INSTANCE;
  if (l>=Integer.MAX_VALUE) throw new IllegalArgumentException("Requested zero vector length too large: "+l);
  return ZeroVector.create((int)l);
}

代码示例来源:origin: net.mikera/vectorz

/**
 * Creates an immutable zero vector of the specified length.
 * @param l
 * @return
 */
public static AVector createZeroVector(long l) {
  if (l==0) return Vector0.INSTANCE;
  if (l>=Integer.MAX_VALUE) throw new IllegalArgumentException("Requested zero vector length too large: "+l);
  return ZeroVector.create((int)l);
}

代码示例来源:origin: mikera/vectorz

/**
 * Create an immutable vector containing a single repeated value. Guaranteed to be O(1).
 * 
 * @param length
 * @param value
 * @return
 */
public static AVector createRepeatedElement(int length,double value) {
  if (length==0) return Vector0.INSTANCE;
  if (value==0.0) return ZeroVector.create(length);
  return RepeatedElementVector.create(length, value);
}

代码示例来源:origin: mikera/vectorz

@Override
public AVector subVector(int offset, int length) {
  int len = checkRange(offset, length);
  if (length == 0) return Vector0.INSTANCE;
  if (length == len) return this;
  return ZeroVector.create(length);
}

代码示例来源:origin: net.mikera/vectorz

/**
 * Create an immutable vector containing a single repeated value. Guaranteed to be O(1).
 * 
 * @param length
 * @param value
 * @return
 */
public static AVector createRepeatedElement(int length,double value) {
  if (length==0) return Vector0.INSTANCE;
  if (value==0.0) return ZeroVector.create(length);
  return RepeatedElementVector.create(length, value);
}

代码示例来源:origin: net.mikera/vectorz

@Override
public AVector subVector(int offset, int length) {
  int len = checkRange(offset, length);
  if (length == 0) return Vector0.INSTANCE;
  if (length == len) return this;
  return ZeroVector.create(length);
}

代码示例来源:origin: mikera/vectorz

@Override
public AVector subVector(int offset, int length) {
  int len=checkRange(offset,length);
  if (length==0) return Vector0.INSTANCE;
  if (length==len) return this;
  if ((offset>index)||((offset+length)<=index)) {
    return ZeroVector.create(length);
  }
  return SingleElementVector.create(value, index-offset, length);
}

代码示例来源:origin: net.mikera/vectorz

/**
 * Creates a ZeroVector with the same number of elements as the given array.
 * 
 * @param arraySize
 * @return
 */
public static ZeroVector create(INDArray array) {
  int n = Vectorz.safeLongToInt(array.elementCount());
  return ZeroVector.create(n);
}

代码示例来源:origin: mikera/vectorz

/**
 * Creates a ZeroVector with the same number of elements as the given array.
 * 
 * @param arraySize
 * @return
 */
public static ZeroVector create(INDArray array) {
  int n = Vectorz.safeLongToInt(array.elementCount());
  return ZeroVector.create(n);
}

代码示例来源:origin: net.mikera/vectorz

@Override
public AVector subVector(int offset, int length) {
  int len=checkRange(offset,length);
  if (length==0) return Vector0.INSTANCE;
  if (length==len) return this;
  if ((offset>index)||((offset+length)<=index)) {
    return ZeroVector.create(length);
  }
  return SingleElementVector.create(value, index-offset, length);
}

代码示例来源:origin: net.mikera/vectorz

@Override
public AVector innerProduct(AMatrix m) {
  checkLength(m.rowCount());
  return ZeroVector.create(m.columnCount());
}

代码示例来源:origin: mikera/vectorz

@Override
public AVector innerProduct(AMatrix m) {
  checkLength(m.rowCount());
  return ZeroVector.create(m.columnCount());
}

代码示例来源:origin: net.mikera/vectorz

private ZeroArray(int[] shape)  {
  super(shape);
  int dims=this.dimensionality();
  switch(dims) {
    case 1: sliceValue= ImmutableScalar.ZERO; break;
    case 2: sliceValue= ZeroVector.create(shape[1]); break;
    case 3: sliceValue= ZeroMatrix.create(shape[1],shape[2]); break;
    default: sliceValue= ZeroArray.wrap(IntArrays.removeIndex(shape, 0)); break;
  }
}

代码示例来源:origin: mikera/vectorz

private ZeroArray(int[] shape)  {
  super(shape);
  int dims=this.dimensionality();
  switch(dims) {
    case 1: sliceValue= ImmutableScalar.ZERO; break;
    case 2: sliceValue= ZeroVector.create(shape[1]); break;
    case 3: sliceValue= ZeroMatrix.create(shape[1],shape[2]); break;
    default: sliceValue= ZeroArray.wrap(IntArrays.removeIndex(shape, 0)); break;
  }
}

代码示例来源:origin: net.mikera/vectorz

@Override
public AVector subVector(int start, int length) {
  int len=checkRange(start,length);
  if (length==len) return this;
  if (length==0) return Vector0.INSTANCE;
      
  int end=start+length;
  if ((start<=axis())&&(end>axis())) {
    return AxisVector.create(axis()-start,length);
  } else {
    return ZeroVector.create(length);
  }
}

代码示例来源:origin: mikera/vectorz

@Override
public AVector subVector(int start, int length) {
  int len=checkRange(start,length);
  if (length==len) return this;
  if (length==0) return Vector0.INSTANCE;
      
  int end=start+length;
  if ((start<=axis())&&(end>axis())) {
    return AxisVector.create(axis()-start,length);
  } else {
    return ZeroVector.create(length);
  }
}

代码示例来源:origin: mikera/vectorz

@Test public void testMultiJoining() {
    AVector v=Vector0.INSTANCE;
    
    // initial join should replace Vector0
    v=v.join(AxisVector.create(1, 3));
    assertEquals(AxisVector.class,v.getClass());
    
    // second join should create JoinedVector
    v=v.join(Vector.of(1,2,3));
    assertEquals(JoinedVector.class,v.getClass());
    
    // third join should promote to JoinedMultiVector
    v=v.join(ZeroVector.create(3));
    assertEquals(JoinedMultiVector.class,v.getClass());
  }
}

代码示例来源:origin: mikera/vectorz

@Test public void g_JoinedMultiVector() {	
  doGenericTests(JoinedMultiVector.create(Vector4.of(1,2,3,4),Vector.of(10,20,30,40,50)));
  doGenericTests(JoinedMultiVector.create(Vectorz.createRange(3),ZeroVector.create(2)));
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com