Exemple #1
0
        public static VectorStorage <T> VectorStorage <T>(VectorStorageType type, IEnumerable <T> data)
            where T : struct, IEquatable <T>, IFormattable
        {
            switch (type)
            {
            case VectorStorageType.DenseVector:
                return(DenseVectorStorage <T> .OfEnumerable(data));

            case VectorStorageType.SparseVector:
                return(SparseVectorStorage <T> .OfEnumerable(data));

            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var serializationModel = serializer.Deserialize <VectorSerializationModel>(reader);

            if (serializationModel.IsDense)
            {
                var storage = DenseVectorStorage <double> .OfEnumerable(
                    serializationModel.Storage
                    );

                var vector = new DenseVector(storage);
                return(vector);
            }
            else
            {
                var storage = SparseVectorStorage <double> .OfEnumerable(
                    serializationModel.Storage
                    );

                var vector = new SparseVector(storage);
                return(vector);
            }
        }
 /// <summary>
 /// Create a new dense vector as a copy of the given enumerable.
 /// This new vector will be independent from the enumerable.
 /// A new memory block will be allocated for storing the vector.
 /// </summary>
 public static DenseVector OfEnumerable(IEnumerable <Complex32> enumerable)
 {
     return(new DenseVector(DenseVectorStorage <Complex32> .OfEnumerable(enumerable)));
 }
Exemple #4
0
 /// <summary>
 /// Create a new dense vector as a copy of the given enumerable.
 /// This new vector will be independent from the enumerable.
 /// A new memory block will be allocated for storing the vector.
 /// </summary>
 public static DenseVector OfEnumerable(IEnumerable <float> enumerable)
 {
     return(new DenseVector(DenseVectorStorage <float> .OfEnumerable(enumerable)));
 }
Exemple #5
0
 /// <summary>
 /// Create a new dense vector as a copy of the given enumerable.
 /// This new vector will be independent from the enumerable.
 /// A new memory block will be allocated for storing the vector.
 /// </summary>
 public static DenseVector OfEnumerable(IEnumerable<double> enumerable)
 {
     return new DenseVector(DenseVectorStorage<double>.OfEnumerable(enumerable));
 }
 public DenseVector(IEnumerable <double> other)
     : this(DenseVectorStorage <double> .OfEnumerable(other))
 {
 }
Exemple #7
0
 public DenseVector(IEnumerable <float> other)
     : this(DenseVectorStorage <float> .OfEnumerable(other))
 {
 }
 public DenseVector(IEnumerable <Complex32> other)
     : this(DenseVectorStorage <Complex32> .OfEnumerable(other))
 {
 }