ReadOnlyDoubleMatrixDivision Operator (Double, ReadOnlyDoubleMatrix) |
Namespace: Novacta.Analytics
Exception | Condition |
---|---|
ArgumentNullException | right is null. |
Let and
be the right
number of rows and columns, respectively, and let its generic entry given by
The method returns a matrix having
the same dimensions of right, whose generic
entry is:
In the following example, a scalar is divided by a matrix.
using System; namespace Novacta.Analytics.CodeExamples { public class DivisionExample2 { public void Main() { // Create the left operand. double left = 10.0; Console.WriteLine("left ="); Console.WriteLine(left); Console.WriteLine(); // Create the right operand. var data = new double[6] { 0, 20, 40, 10, 30, 50, }; var right = DoubleMatrix.Dense(2, 3, data, StorageOrder.RowMajor); Console.WriteLine("right ="); Console.WriteLine(right); // Divide left by right. var result = left / right; Console.WriteLine(); Console.WriteLine("left / right ="); Console.WriteLine(result); // In .NET languages that do not support overloaded operators, // you can use the alternative methods named Divide. result = DoubleMatrix.Divide(left, right); Console.WriteLine(); Console.WriteLine("DoubleMatrix.Divide(left, right) returns"); Console.WriteLine(); Console.WriteLine(result); // Both operators and alternative methods are overloaded to // support read-only matrix arguments. // Compute the division using a read-only wrapper of right. ReadOnlyDoubleMatrix readOnlyRight = right.AsReadOnly(); result = left / readOnlyRight; Console.WriteLine(); Console.WriteLine("left / readOnlyRight ="); Console.WriteLine(result); } } } // Executing method Main() produces the following output: // // left = // 10 // // right = // 0 20 40 // 10 30 50 // // // // left / right = // Infinity 0.5 0.25 // 1 0.333333333 0.2 // // // // DoubleMatrix.Divide(left, right) returns // // Infinity 0.5 0.25 // 1 0.333333333 0.2 // // // // left / readOnlyRight = // Infinity 0.5 0.25 // 1 0.333333333 0.2 //