Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatrixByRow"/> class.
 /// </summary>
 /// <param name="matrix">The matrix to represent.</param>
 public MatrixByRow(TensorNode matrix)
 {
     Height = matrix.GetDimensionSize(2);
     Width  = matrix.GetDimensionSize(1);
     _rows  = new MatrixRow[Height];
     for (int i = 0; i < Height; i++)
     {
         _rows[i] = new MatrixRow(matrix, i);
     }
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatrixRow"/> class.
        /// </summary>
        /// <param name="matrix">The matrix it's a row off.</param>
        /// <param name="row">The row of the matrix represented.</param>
        public MatrixRow(TensorNode matrix, int row)
        {
            int width = matrix.GetDimensionSize(1);

            _values = new ExpNode[width];
            for (int i = 0; i < width; i++)
            {
                _values[i] = matrix.GetChildD(row, i);
            }
        }
Exemple #3
0
        /// <summary>
        /// Checks if two <see cref="TensorNode"/>s can matrix multiply.
        /// </summary>
        /// <param name="node">The first <see cref="TensorNode"/>.</param>
        /// <param name="other">The second <see cref="TensorNode"/>.</param>
        /// <returns>True if the Tensors can multiply as matricies.</returns>
        public static bool CanMatrixMultiply(this TensorNode node, TensorNode other)
        {
            // Ensure both TensorNodes are matricies
            if (node.TensorType != TensorType.Matrix)
            {
                return(false);
            }
            if (other.TensorType != TensorType.Matrix)
            {
                return(false);
            }

            // Ensure node's last dimension is the size of other's first dimension
            return(node.GetDimensionSize(2) == other.GetDimensionSize(1));
        }