Пример #1
0
        /// <summary>
        /// Returns a deep-copy clone of the vector.
        /// </summary>
        /// <returns>A deep-copy clone of the vector.</returns>
        public Vector <T> Clone()
        {
            var result = Build.SameAs(this);

            Storage.CopyToUnchecked(result.Storage, skipClearing: true);
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Returns a deep-copy clone of the vector.
        /// </summary>
        /// <returns>A deep-copy clone of the vector.</returns>
        public Vector <T> Clone()
        {
            var result = Build.SameAs(this);

            Storage.CopyToUnchecked(result.Storage, ExistingData.AssumeZeros);
            return(result);
        }
Пример #3
0
        /// <summary>
        /// Create a new vector with a type that can represent and is closest to both provided samples and the dimensions of example.
        /// </summary>
        public static Vector <T> SameAs <T>(Vector <T> example, Vector <T> otherExample)
            where T : struct, IEquatable <T>, IFormattable
        {
            VectorBuilder <T> v_builder = BuilderInstance <T> .Vector;

            return(v_builder.SameAs(example, otherExample));
        }
Пример #4
0
        /// <summary>
        /// Create a new vector with a type that can represent and is closest to both provided samples.
        /// </summary>
        public static Vector <T> SameAs <T>(Matrix <T> matrix, Vector <T> vector, int length)
            where T : struct, IEquatable <T>, IFormattable
        {
            VectorBuilder <T> v_builder = BuilderInstance <T> .Vector;

            return(v_builder.SameAs(matrix, vector, length));
        }
Пример #5
0
        /// <summary>
        /// Create a new vector with the same kind of the provided example.
        /// </summary>
        public static Vector <T> SameAs <T, TU>(Matrix <TU> example, int length)
            where T : struct, IEquatable <T>, IFormattable
            where TU : struct, IEquatable <TU>, IFormattable
        {
            VectorBuilder <T> v_builder = BuilderInstance <T> .Vector;

            return(v_builder.SameAs(example, length));
        }
Пример #6
0
        /// <summary>
        /// Applies a function to each value of this vector and returns the results as a new vector.
        /// The index of each value (zero-based) is passed as first argument to the function.
        /// If forceMapZero is not set to true, zero values may or may not be skipped depending
        /// on the actual data storage implementation (relevant mostly for sparse vectors).
        /// </summary>
        public Vector <TU> MapIndexed <TU>(Func <int, T, TU> f, Zeros zeros = Zeros.AllowSkip)
            where TU : struct, IEquatable <TU>, IFormattable
        {
            VectorBuilder <TU> v_builder = BuilderInstance <TU> .Vector;
            var result = v_builder.SameAs(this);

            Storage.MapIndexedToUnchecked(result.Storage, f, zeros, ExistingData.AssumeZeros);
            return(result);
        }