Пример #1
0
 /// <summary>
 /// Create a new float matrix with the specified number of rows and columns initialised to zero
 /// </summary>
 /// <param name="rowCount">Number of rows</param>
 /// <param name="columnCount">Number of columns</param>
 public static FloatMatrix Create(int rowCount, int columnCount)
 {
     return(new FloatMatrix
     {
         Row = Enumerable.Range(0, rowCount).Select(i => FloatVector.Create(columnCount)).ToArray()
     });
 }
Пример #2
0
        /// <summary>
        /// Creates a float matrix from a binary reader
        /// </summary>
        /// <param name="reader">The binary reader</param>
        public static FloatMatrix ReadFrom(BinaryReader reader)
        {
            var len = reader.ReadInt32();
            var ret = new FloatVector[len];

            for (var i = 0; i < len; i++)
            {
                ret[i] = FloatVector.ReadFrom(reader);
            }
            return(Create(ret));
        }
Пример #3
0
        /// <summary>
        /// Tests if the vectors are the same
        /// </summary>
        /// <param name="vector">The vector to compare</param>
        /// <param name="comparer">Optional IEqualityComparer to use</param>
        /// <returns></returns>
        public bool IsEqualTo(FloatVector vector, IEqualityComparer <float> comparer = null)
        {
            if (vector == null || Size != vector.Size)
            {
                return(false);
            }

            comparer = comparer ?? BoundMath.GetEqualityComparer() ?? EqualityComparer <float> .Default;
            for (int i = 0, len = Size; i < len; i++)
            {
                if (!comparer.Equals(Data[i], vector.Data[i]))
                {
                    return(false);
                }
            }
            return(true);
        }