Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DenseVectorPackF"/> class.
        /// </summary>
        /// <param name="other">The <see cref="DenseVectorPackF"/> to copy the data from.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="other"/> is <b>null</b>.
        /// </exception>
        public DenseVectorPackF(DenseVectorPackF other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            this.Count  = other.Count;
            this.Length = other.Length;
            this.X      = other.X;
        }
Exemple #2
0
        /// <summary>
        /// Packs a collection of dense vectors.
        /// </summary>
        /// <param name="vectors">The dense vectors to pack.</param>
        /// <returns>
        /// The <see cref="DenseVectorPackF"/> object that contains packed dense vectors.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="vectors"/> is <b>null</b>.
        /// </exception>
        public static DenseVectorPackF Pack(IList <IDenseVector <float> > vectors)
        {
            if (vectors == null)
            {
                throw new ArgumentNullException(nameof(vectors));
            }

            if (vectors.Count == 0)
            {
                return(new DenseVectorPackF());
            }

            DenseVectorPackF result = new DenseVectorPackF(vectors.Count, vectors[0].Length);

            float[] x = result.X;
            for (int i = 0, ii = result.Count, len = result.Length, off = 0; i < ii; i++, off += len)
            {
                Vectors.Copy(len, vectors[i].X, vectors[i].Offset, x, off);
            }

            return(result);
        }