public void DenseVectorStorageBuilderMethods_ZeroLength_DoNotThrowException() { Assert.DoesNotThrow(() => new DenseVectorStorage <double>(0)); Assert.DoesNotThrow(() => new DenseVectorStorage <double>(0, Array.Empty <double>())); Assert.DoesNotThrow(() => DenseVectorStorage <double> .OfValue(0, 42)); Assert.DoesNotThrow(() => DenseVectorStorage <double> .OfInit(0, index => 42)); }
/// <summary> /// Create a new dense vector and initialize each value using the provided value. /// </summary> public static DenseVector Create(int length, Complex32 value) { if (value == Complex32.Zero) { return(new DenseVector(length)); } return(new DenseVector(DenseVectorStorage <Complex32> .OfInit(length, i => value))); }
/// <summary> /// Create a new dense vector and initialize each value using the provided value. /// </summary> public static DenseVector Create(int length, float value) { if (value == 0f) { return(new DenseVector(length)); } return(new DenseVector(DenseVectorStorage <float> .OfInit(length, i => value))); }
/// <summary> /// Create a new dense vector and initialize each value using the provided value. /// </summary> public static DenseVector Create(int length, double value) { if (value == 0d) { return(new DenseVector(length)); } return(new DenseVector(DenseVectorStorage <double> .OfInit(length, i => value))); }
/// <summary> /// Create a new dense vector with values sampled from the provided random distribution. /// </summary> public static DenseVector CreateRandom(int length, IContinuousDistribution distribution) { return(new DenseVector(DenseVectorStorage <Complex32> .OfInit(length, i => new Complex32((float)distribution.Sample(), (float)distribution.Sample())))); }
/// <summary> /// Create a new dense vector and initialize each value using the provided init function. /// </summary> public static DenseVector Create(int length, Func <int, Complex32> init) { return(new DenseVector(DenseVectorStorage <Complex32> .OfInit(length, init))); }
/// <summary> /// Create a new dense vector and initialize each value using the provided init function. /// </summary> public static DenseVector Create(int length, Func <int, float> init) { return(new DenseVector(DenseVectorStorage <float> .OfInit(length, init))); }
/// <summary> /// Create a new dense vector and initialize each value using the provided init function. /// </summary> public static DenseVector Create(int length, Func<int, double> init) { return new DenseVector(DenseVectorStorage<double>.OfInit(length, init)); }
public DenseVector(int length, double value) : this(DenseVectorStorage <double> .OfInit(length, i => value)) { }
/// <summary> /// Create a new dense vector with values sampled from the provided random distribution. /// </summary> public static DenseVector CreateRandom(int length, IContinuousDistribution distribution) { return(new DenseVector(DenseVectorStorage <double> .OfInit(length, i => distribution.Sample()))); }
public void DenseVectorStorageOfInit_NegativeLength_ThrowsArgumentException() { Assert.That(() => DenseVectorStorage <double> .OfInit(-1, index => 42), Throws.TypeOf <ArgumentOutOfRangeException>() .With.Message.Contains("Value must not be negative (zero is ok).")); }
public DenseVector(int length, float value) : this(DenseVectorStorage <float> .OfInit(length, i => value)) { }
public DenseVector(int length, Complex32 value) : this(DenseVectorStorage <Complex32> .OfInit(length, i => value)) { }
/// <summary> /// Create a new dense vector and initialize each value using the provided init function. /// </summary> public Vector <T> Dense(int length, Func <int, T> init) { return(Dense(DenseVectorStorage <T> .OfInit(length, init))); }