MATRIX Statement
- MATRIX M_name pattern_definitions ;
The MATRIX statement defines a matrix H and the vector g
which can be given in the MINQUAD or MAXQUAD statement.
The matrix H and vector g are initialized to zero, so that only
the nonzero elements are given.
The five different
forms of the MATRIX statement are illustrated with the following example,
![H = [ 100 & 10 & 1 & 0 \ 10 & 100 & 10 & 1 \ 1 & 10 & 100 & 10 \ 0 & 1 & 10 & 100 \ ]
g = [ 1 \ 2 \ 3 \ 4 \ ] c = 0.](images/nlpeq56.gif)
Each MATRIX statement first names the matrix or vector
and then lists its elements.
If more than one MATRIX statement is given for the same
matrix, then later definitions override the earlier ones.
The rows and columns in matrix H and vector g correspond
to the order of decision variables in the DECVAR statement.
- Full Matrix Definition:
The MATRIX statement consists of H_name or
g_name followed by an equal sign and all
(nonredundant) numerical values of the matrix H or
vector g. Assuming symmetry, only the elements of the
lower triangular part of the matrix H must be listed.
This specification should be used mainly for small
problems with almost dense H matrices.
MATRIX H= 100
10 100
1 10 100
0 1 10 100;
MATRIX G= 1 2 3 4;
- Band-diagonal Matrix Definition:
This form of pattern definition is useful if the H
matrix has (almost) constant band-diagonal structure.
The MATRIX statement consists of H_name followed by
empty brackets [,], an equal sign, and a list of k+1 numbers
are assigned to the diagonal elements and the following k
numbers are assigned to the adjacent k subdiagonals.
MATRIX H[,]= 100 10 1;
MATRIX G= 1 2 3 4;
- Sparse Matrix Definitions:
In each of the following three
specification types the H_name or g_name
is followed by a list of pattern definitions separated
by commas. Each pattern definition consists of
a location specification in brackets on the left side
of an equal sign that is followed by a list of k+1 numbers.
- (Sub)Diagonalwise:
This form of pattern definition is useful if the H matrix
contains nonzero elements along diagonals or subdiagonals.
The starting location is specified by an index pair in
brackets [i,j]. The k+1 numbers at the right-hand
side are assigned to the elements [i,j], ... ,[i+k,j+k]
in a diagonal direction of the H matrix.
The special case k=0 can be used to assign values
to single nonzero element locations in H.
MATRIX H [1,1]= 4 * 100,
[2,1]= 3 * 10,
[3,1]= 2 * 1;
MATRIX G [1,1]= 1 2 3 4;
- Columnwise Starting in Diagonal:
This form of pattern definition is useful if the H matrix
contains nonzero elements columnwise starting in the diagonal.
The starting location is specified by only one index j in
brackets [,j]. The k+1 numbers at the right-hand
side are assigned to the elements [j,j], ... ,[min(j+k,n),j].
MATRIX H [,1]= 100 10 1,
[,2]= 100 10 1,
[,3]= 100 10,
[,4]= 100;
MATRIX G [,1]= 1 2 3 4;
- Rowwise Starting in First Column:
This form of pattern definition is useful if the H matrix
contains nonzero elements rowwise ending in the diagonal.
The starting location is specified by only one index i in
brackets [i,]. The k+1 numbers at the right-hand
side are assigned to the elements [i,1], ... ,[i,min(k+1,i)].
MATRIX H [1,]= 100,
[2,]= 10 100,
[3,]= 1 10 100,
[4,]= 0 1 10 100;
MATRIX G [1,]= 1 2 3 4;
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.