multmat.sml
################################################################
# MultiplyMatrix (matrixOut, matrixLeft, matrixRight)
################################################################
# start of program
clear();
class MATRIX h1, h2, h3;
h1 = CreateMatrix(2,2); # create three matrices
h2 = CreateMatrix(2,2);
h3 = CreateMatrix(2,2);
# create a matrix to test
# result should be | 1 2 |
# | 3 4 |
SetMatrixItem( h1, 0, 0, 1.0 );
SetMatrixItem( h1, 0, 1, 2.0 );
SetMatrixItem( h1, 1, 0, 3.0 );
SetMatrixItem( h1, 1, 1, 4.0 );
# print the resulting matrix
printf( "Origional Matrix\n" );
PrintMatrixToConsole( h1 );
# create an identity matrix
# result should be | 1 0 |
# | 0 1 |
SetMatrixItem( h2, 0, 0, 1.0 );
SetMatrixItem( h2, 0, 1, 0.0 );
SetMatrixItem( h2, 1, 0, 0.0 );
SetMatrixItem( h2, 1, 1, 1.0 );
# print the resulting matrix
printf( "Identity Matrix\n" );
PrintMatrixToConsole( h2 );
# now multiply h1 by the h2 (identity matrix)
# result in h3
MultiplyMatrix( h3, h2, h1 );
# print the result - should be same as origional
printf( "Matrix after multiplication by indentity\n" );
PrintMatrixToConsole( h3 );
# destroy the matrices
DestroyMatrix(h1);
DestroyMatrix(h2);
DestroyMatrix(h3);
©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010 USA
Business & Sales: (402)477-9554 Support: (402)477-9562 Fax: (402)477-9559
Business info@microimages.com
Support support@microimages.com
Web webmaster@microimages.com
|