Exemple #1
0
        public void Mult(double b)
        {
            var res = new NNArray(this.Length);

            for (int i = 0; i < this.Length; i++)
            {
                this.Values[i] *= b;
            }
        }
Exemple #2
0
        public static NNArray operator *(NNArray a, double b)
        {
            var res = new NNArray(a.Length);

            for (int i = 0; i < a.Length; i++)
            {
                res[i] = a[i] * b;
            }
            return(res);
        }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="b"></param>
 /// <param name="res">   an array to store the result</param>
 public void Add(NNArray b, NNArray res)
 {
     if (this.Length != b.Length || this.Length != res.Length)
     {
         throw new ArgumentException("NNArrays do not have same length");
     }
     for (int i = 0; i < this.Length; i++)
     {
         this.Values[i] += b[i];
     }
 }
Exemple #4
0
        public void Subst(NNArray b)
        {
            if (this.Length != b.Length)
            {
                throw new ArgumentException("NNArrays do not have same length");
            }
            var res = new NNArray(this.Length);

            for (int i = 0; i < this.Length; i++)
            {
                this.Values[i] -= b[i];
            }
        }
Exemple #5
0
        public static NNArray operator +(NNArray a, NNArray b)
        {
            if (a.Length != b.Length)
            {
                throw new ArgumentException("NNArrays do not have same length");
            }
            var res = new NNArray(a.Length);

            for (int i = 0; i < a.Length; i++)
            {
                res[i] = a[i] + b[i];
            }
            return(res);
        }
Exemple #6
0
 /// <summary>Linear algebraic matrix multiplication, A * B</summary>
 /// <param name="B">   an array</param>
 /// <param name="X">   an array to store the result</param>
 /// <returns>     Matrix product, A * B
 /// </returns>
 /// <exception cref="System.ArgumentException">  Matrix inner dimensions must agree.
 /// </exception>
 public virtual void Multiply(NNArray B, NNArray X)
 {
     if (B.Length != n || X.Length != m)
     {
         throw new System.ArgumentException("GeneralMatrix inner dimensions must agree.");
     }
     for (int j = 0; j < m; j++)
     {
         double val = 0;
         for (int i = 0; i < n; i++)
         {
             val += this[i, j] * B[i];
         }
         X.Values[j] = val;
     }
 }
Exemple #7
0
        /// <summary>Linear algebraic matrix multiplication, A * B</summary>
        /// <param name="B">   an array
        /// </param>
        /// <returns>     Matrix product, A * B
        /// </returns>
        /// <exception cref="System.ArgumentException">  Matrix inner dimensions must agree.
        /// </exception>
        public virtual NNArray Multiply(NNArray B)
        {
            if (B.Length != n)
            {
                throw new System.ArgumentException("GeneralMatrix inner dimensions must agree.");
            }
            NNArray X = new NNArray(this.NbCols);

            for (int j = 0; j < m; j++)
            {
                double val = 0;
                for (int i = 0; i < n; i++)
                {
                    val += this[i, j] * B[i];
                }
                X.Values[j] = val;
            }
            return(X);
        }