Returns / sets the real or imaginary parts of matrix elements to / from an array.
MatrixObject.AsArrayR = ValArray ValArray = MatrixObject.AsArrayR MatrixObject.AsArrayI = ValArray ValArray = MatrixObject.AsArrayI
Read / write. The value is an array of type Double containing real or imaginary parts of matrix elements.
The AsArrayR, AsArrayI properties can be used to quickly assign real and imaginary parts of complex matrix elements of an array, and vice versa. This is faster and simpler than explicitly setting each element. AsArrayR addresses the real parts while AsArrayI addresses the imaginary parts.
When using AsArrayR or AsArrayI property from within Visual Basic, declare the arrays your are going to use as dynamic arrays:
'Correct
Dim ValArray() as Double
ReDim ValArray(5,5)
'Incorrect
Dim ValArray(5,5) as Double
Error 1304 is returned if ValArray parameter is not zero based or it is of incorrect type.
Error 1301 or 1302 is returned if array size is bigger than MaxSize property.
The following code example demonstrates the use of the AsArrayR Property.
Private Sub MatrixAsArray()
Dim A As Matrix
Dim B() as Double
Set A = New Matrix
A.Size 3,3
A(0, 0) = 1: A(0, 1) = 2: A(0, 2) = 1
A(1, 0) = 2: A(1, 1) = 3: A(1, 2) = 4
A(2, 0) = 3: A(2, 1) = 2: A(2, 2) = 1
B = A.AsArrayR
'Array B now contains all elements of Matrix A
'We change some values of array B
B(0, 0) = 5: B(2, 0) = 7: B(1, 1) = 10
'and then assign the whole array to the matrix
A.AsArrayR = B
End Sub
AsArray Property | MaxSize Property
Applies To: CMatrix