VEC_$PREMULTN Domain/OS VEC_$PREMULTN
NAME
vec_$premultn - multiply a single-precision vector by a matrix
SYNOPSIS (C)
#include <apollo/base.h>
#include <apollo/vec.h>
void vec_$premultn(
float *start_vec,
float *matrix,
long int &m,
long int &n,
float *result_vec)
SYNOPSIS (Pascal)
%include '/sys/ins/base.ins.pas';
%include '/sys/ins/vec.ins.pas';
procedure vec_$premultn(
in start_vec: univ vec_$real_vector;
in matrix: univ vec_$real_matrix;
in m: integer32;
in n: integer32;
out result_vec: univ vec_$real_vector);
SYNOPSIS (FORTRAN)
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/vec.ins.ftn'
integer*4 m, n
parameter (m = 3, n = 4)
real start_vec(m), matrix(m, n), result_vec(n)
call vec_$premultn(start_vec, matrix, m, n, result_vec)
DESCRIPTION
Vec_$premultn multiplies the m-element vector start_vec by the variably
dimenstioned matrix matrix, and supplies the resulting n-element vector
in result_vec.
In C, vec_$premultn applies the nxm matrix matrix as a left transform to
the m-element column vector start_vec, and supplies the transformed n-
element result in result_vec:
for (i = 0; i < n; ++i) {
result_vec[i] = 0.0;
for (j = 0; i < m; ++i)
result_vec[i] += start_vec[j]
* matrix[i][j];
}
In Pascal, vec_$premultn applies the nxm matrix matrix as a left
transform to the m-element column vector start_vec, and supplies the
transformed n-element result in result_vec:
for i := 1 to n do
begin
result_vec[i] := 0.0;
for j := 1 to m do
result_vec[i] = result_vec[i]
+ start_vec[j]
* matrix[i,j];
end
In FORTRAN, vec_$premultn applies the mxn matrix matrix as a right
transform to the m-element row vector start_vec, and supplies the
transformed n-element result in result_vec:
do 10 i = 1, n
result_vec(i) = 0.0
do 10 j = 1, m
result_vec(i) = result_vec(i)
& + start_vec(j)
& * matrix(j,i)
10 continue
start_vec
An m-element vector to multiply by matrix.
matrix
A matrix to multiply start_vec by.
m The number of elements in start_vec.
n The number of elements in result_vec.
result_vec
An n-element vector that is the product of matrix and start_vec.
NOTES
Vec_$postmultn transforms single-precision vectors from the other side.
SEE ALSO
vec_$dpremultn, vec_$ipremultn, vec_$ipremultn16.