Example: Matrix and PrintMatrix
The 1 norm of a matrix is found using a method from the Matrix class. The matrix is printed using the PrintMatrix class.
using System;
using Imsl.Math;
public class MatrixEx1
{
public static void Main(String[] args)
{
double nrm1;
double[,] a = {
{0.0, 1.0, 2.0, 3.0},
{4.0, 5.0, 6.0, 7.0},
{8.0, 9.0, 8.0, 1.0},
{6.0, 3.0, 4.0, 3.0}
};
// Get the 1 norm of matrix a
nrm1 = Matrix.OneNorm(a);
// Construct a PrintMatrix object with a title
PrintMatrix p = new PrintMatrix("A Simple Matrix");
// Print the matrix and its 1 norm
p.Print(a);
Console.Out.WriteLine("The 1 norm of the matrix is " + nrm1);
}
}
Output
A Simple Matrix
0 1 2 3
0 0 1 2 3
1 4 5 6 7
2 8 9 8 1
3 6 3 4 3
The 1 norm of the matrix is 20
Link to C# source.