Software
Services
News
Company Info
APTL
SCTL
Documentation
Download
Performance
Opstone Benchmarks
 Matrix/Vector Example SCTL Code
The following is a simple example of a 3x3 matrix multiplied by a 3-component vector:
#include <iostream>
#include <SCTL/Math/Vector.h>
#include <SCTL/Math/Matrix.h>

int main( int argc, char** argv )
{
  SCTL::Matrix<fp64_t,3,3> mat;
  mat.MakeIdentity();
  mat[1][2] = -3.5;
  
  SCTL::Vector<fp64_t,3> vec1( 1.0, -2.5, 1.5 );
  
  SCTL::Vector<fp64_t,3> vec2 = mat*vec1;
  std::cout << vec2[0] << " " << vec2[1] << " " << vec2[2] << std::endl;
  
  return( 0 );
}
NOTES:

- Matrix format is row-major. For example, 'matrix[1][2]' returns the reference to the element stored at row #1, column #2 (indexing from zero).
- Both 'Vector<T,N>' and 'Matrix<T,M,N>' use stack-based memory and are intended for small sizes (< 8 elements per dimension). For larger vectors and matricies, use the 'StaticVector<T>' and 'StaticMatrix<T>' classes, respectively, as these use dynamic memory allocation.
top of page
   Info Copyright ©2004 Blue Sail Software. All rights reserved. Legal