?? symmetricmatrices.vb
字號:
' The SymmetricMatrix class resides in the Extreme.Mathematics.LinearAlgebra
' namespace.
Imports Extreme.Mathematics.LinearAlgebra
Namespace Extreme.Mathematics.QuickStart.VB
' Illustrates the use of the SymmetricMatrix class in the
' Extreme.Mathematics.LinearAlgebra namespace of the Extreme Optimization
' Mathematics Library for .NET.
Module SymmetricMatrices
Sub Main()
' Symmetric matrices are matrices whose elements
' are symmetrical around the main diagonal.
' Symmetric matrices are always square, and are
' equal to their own transpose.
'
' Constructing symmetric matrices
'
' Constructing symmetric matrices is similar to
' constructing general matrices. See the
' BasicMatrices QuickStart samples for a more
' complete discussion.
' Symmetric matrices are always square. You don't
' have to specify both the number of rows and the
' number of columns.
'
' The following creates a 5x5 symmetric matrix:
Dim s1 As SymmetricMatrix = New SymmetricMatrix(5)
' Symmetric matrices access and modify only the
' elements on and either above or below the
' main diagonal. When initializing a
' symmetric matrix in a constructor, you must
' specify a triangleMode parameter that specifies
' whether to use the upper or lower triangle:
Dim components As Double() = New Double() _
{11, 12, 13, 14, 15, _
21, 22, 23, 24, 25, _
31, 32, 33, 34, 35, _
41, 42, 43, 44, 45, _
51, 52, 53, 54, 55}
Dim s2 As SymmetricMatrix = New SymmetricMatrix( _
5, components, MatrixTriangleMode.Upper)
Console.WriteLine("s2 = {0:F0}", s2)
' You can also create a symmetric matrix by
' multiplying any matrix by its transpose:
Dim m As GeneralMatrix = New GeneralMatrix(3, 4, New Double() _
{1, 2, 3, _
2, 3, 4, _
3, 4, 5, _
4, 5, 6})
Console.WriteLine("m = {0:F0}", m)
' This calculates transpose(m) times m:
Dim s3 As SymmetricMatrix = _
SymmetricMatrix.FromOuterProduct(m)
Console.WriteLine("s3 = {0:F0}", s3)
' An optional 'side' parameter lets you specify
' whether the left or right operand of the
' multiplication is the transposed matrix.
' This calculates m times transpose(m):
Dim s4 As SymmetricMatrix = _
SymmetricMatrix.FromOuterProduct(m, _
MatrixOperationSide.Right)
Console.WriteLine("s4 = {0:F0}", s4)
'
' SymmetricMatrix properties
'
' Symmetric matrices don't have any specific
' properties.
'
' You can get and set matrix elements:
s1(1, 3) = 55
Console.WriteLine("s1(1, 3) = {0}", s1(1, 3))
' And the change will automatically be reflected
' in the symmetric element:
Console.WriteLine("s1(3, 1) = {0}", s1(3, 1))
'
' Row and column views
'
' The GetRow and GetColumn methods are
' available.
Dim row As Vector = s2.GetRow(1)
Console.WriteLine("row 1 of s2 = {0}", row)
Dim column As Vector = s2.GetColumn(1, 2, 3)
Console.WriteLine("2nd column of s2 from row 3 to ")
Console.WriteLine(" row 4 = {0}", column)
Console.Write("Press Enter key to exit...")
Console.ReadLine()
End Sub
End Module
End Namespace
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -