RM Procedure

Reads data into a one- or two-dimensional matrix.

Usage

RM, a[, rows, columns]

Input Parameters

rows—(optional) Number of rows in the matrix.

columns—(optional) Number of columns in the matrix.

Output Parameters

a—Named variable into which the data is stored.

Keywords

Complex—If present and nonzero, creates a single-precision complex matrix.

Dcomplex—If present and nonzero, creates a double-precision complex matrix.

Double—If present and nonzero, creates a double-precision matrix.

Description

Procedure RM is used to read data into matrices according to the PV-WAVE matrix-storage scheme. If rows and columns are not specified, RM attempts to use the current definition of a to determine the number of rows and columns of a. If rows and columns are not specified and a is undefined or a scalar, an error is issued.

Upon invoking RM, the user is prompted with the row number for which input is expected. The prompt for the next row to be filled does not appear until the current row is filled. If the amount of data input for a particular row is larger than the defined number of columns of a, then the extra trailing input is ignored, and the prompt for the next row is given.

The matrix-printing procedures PM or PMF must be used to correctly print a matrix read in with RM.

Example 1: Reading a Simple Matrix

This example reads a 2-by-3 matrix and prints the results using the matrix-printing procedure PM.

; Read a 2-by-3 matrix.
RM, a, 2, 3
11 22 33
40 50 60
; Output the matrix.
PM, a
; PV-WAVE prints:
;  11.0000       22.0000       33.0000
;  40.0000       50.0000       60.0000

Example 2: Reading a Complex Matrix

In this example, a complex matrix is read. Notice that the elements input as integers are promoted to type complex with the value of the imaginary part set to zero.

; Read the matrix; note that keyword Complex is set.
RM, a, 3, 2, /Complex
(1, 5)  (1, 1)
(1, 0)  (-1, 0)
(10.0, 0)  (0, -10)
; Print the result.
PM, a

Example 3: Reading a Matrix to be Used with LUSOL

In this example, a 3-by-3 matrix and a 3-by-1 matrix are read. These matrices are then used in a call to the PV‑WAVE IMSL Mathematics Toolkit function LUSOL.

; Read the coefficient matrix.
RM, a, 3, 3
1 3 3
1 3 4
1 4 3
; Read the right-hand side.
RM, b, 3, 1
1
4
-1
; Initialize the IMSL Mathematics toolkit
math_init
; Call LUSOL to compute the solution.
x = LUSOL(b, a)
; Output the results.
PM, x
; PV-WAVE prints:
;   -2.00000
;   -2.00000
;    3.00000
PM, a#x - b
; PV-WAVE prints:
;  0.000000
;  0.000000
;  0.000000

See Also

PMPMFRMF

See the PV‑WAVE Programmer’s Guide for more information.