#include <boost/la/all.hpp>
namespace
boost
{
namespace
la
{
//*** Type traits ***
template <class T>
struct
is_matrix
{
static bool const value=/*unspecified*/;
};
template <class M>
struct
matrix_traits
{
/*main template members unspecified*/
};
/*
User-defined (partial) specializations:
template <>
struct
matrix_traits< Matrix >
{
static int const rows = /*user-defined*/;
static int const cols = /*user-defined*/;
typedef /*user-defined*/ scalar_type;
template <int R,int C> static inline scalar_type r( Matrix const & m );
template <int R,int C> static inline scalar_type & w( Matrix & m );
static inline scalar_type ir( int r, int c, Matrix const & m );
static inline scalar_type & iw( int r, int c, Matrix & m );
};
*/
template <class T>
struct
is_vector
{
static bool const value=/*unspecified*/;
};
template <class V>
struct
vector_traits
{
/*main template members unspecified*/
};
/*
User-defined (partial) specializations:
template <>
struct
vector_traits< Vector >
{
static int const dim = /*user-defined*/;
typedef /*user-defined*/ scalar_type;
template <int I> static inline scalar_type r( Vector const & v );
template <int I> static inline scalar_type & w( Vector & v );
static inline scalar_type ir( int i, Vector const & v );
static inline scalar_type & iw( int i, Vector & v );
};
*/
template <class Scalar>
struct
scalar_traits
{
static Scalar zero() { return Scalar(0); }
static Scalar one() { return Scalar(1); }
};
//*** Binary matrix,scalar operations ***
//Only enabled if: is_matrix<A>::value
template <class A>
typename deduce_matrix<A>::type
operator*( A const & a, matrix_traits<A>::scalar_type s );
//Only enabled if: is_matrix<A>::value
template <class A>
typename deduce_matrix<A>::type
operator/( A const & a, matrix_traits<A>::scalar_type s );
//Only enabled if: is_matrix<A>::value
template <class A>
A &
operator*=( A & a, matrix_traits<A>::scalar_type s );
//Only enabled if: is_matrix<A>::value
template <class A>
A &
operator/=( A & a, matrix_traits<A>::scalar_type s );
//*** Binary vector,scalar operations ***
//Only enabled if: is_vector<A>::value
template <class A>
typename deduce_vector<A>::type
operator*( A const & a, vector_traits<A>::scalar_type s );
//Only enabled if: is_vector<A>::value
template <class A>
typename deduce_vector<A>::type
operator/( A const & a, vector_traits<A>::scalar_type s );
//Only enabled if: is_vector<A>::value
template <class A>
A &
operator*=( A & a, vector_traits<A>::scalar_type s );
//Only enabled if: is_vector<A>::value
template <class A>
A &
operator/=( A & a, vector_traits<A>::scalar_type s );
//*** Binary matrix,matrix operations ***
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::cols==matrix_traits<B>::rows
template <class A,class B>
typename deduce_matrix2<A,B,matrix_traits<A>::rows,matrix_traits<B>::cols>::type
operator*( A const & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<A>::cols &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
A &
operator*=( A & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
typename deduce_matrix2<A,B,matrix_traits<A>::rows,matrix_traits<A>::cols>::type
operator+( A const & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
typename deduce_matrix2<A,B,matrix_traits<A>::rows,matrix_traits<A>::cols>::type
operator-( A const & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
A &
operator+=( A & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
A &
operator-=( A & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
bool
operator==( A const & a, B const & b );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
bool
operator!=( A const & a, B const & b );
//*** Binary vector,vector operations ***
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
typename deduce_scalar<A,B>::type
dot( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==3 && vector_traits<B>::dim==3
template <class A,class B>
typename deduce_vector2<A,B,3>::type
cross( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
typename deduce_vector2<A,B,vector_traits<A>::dim>::type
operator+( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
typename deduce_vector2<A,B,vector_traits<A>::dim>::type
operator-( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
A &
operator+=( A & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
A &
operator-=( A & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
bool
operator==( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
bool
operator!=( A const & a, B const & b );
//*** Binary vector/matrix operations ***
//Only enabled if:
// is_matrix<A>::value && is_vector<B>::value &&
// matrix_traits<A>::cols==vector_traits<B>::dim
template <class A,class B>
typename deduce_vector2<A,B,matrix_traits<A>::rows>::type
operator*( A const & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_matrix<B>::value &&
// vector_traits<A>::dim==matrix_traits<B>::rows
template <class A,class B>
typename deduce_vector2<A,B,matrix_traits<B>::cols>::type
operator*( A const & a, B const & b );
//*** Unary matrix operations ***
//Only enabled if: is_matrix<A>::value
template <class A>
typename deduce_matrix<A>::type
operator-( A const & a );
//Only enabled if:
// is_matrix<A>::value && matrix_traits<A>::rows==matrix_traits<A>::cols
template <class A>
matrix_traits<A>::scalar_type
determinant( A const & a );
//Only enabled if:
// is_matrix<A>::value &&
// matrix_traits<A>::rows==matrix_traits<A>::cols
template <class A>
typename deduce_matrix<A>::type
inverse( A const & a, matrix_traits<A>::scalar_type det );
template <class A>
typename deduce_matrix<A>::type
inverse( A const & a );
//*** Unary vector operations ***
//Only enabled if: is_vector<A>::value
template <class A>
typename deduce_vector<A>::type
operator-( A const & a );
//Only enabled if:
// is_vector<A>::value
template <class A>
typename vector_traits<A>::scalar_type
magnitude( A const & a );
//Only enabled if:
// is_vector<A>::value
template <class A>
typename vector_traits<A>::scalar_type
magnitude2( A const & a );
//*** Conversion functions ***
//Only enabled if:
// is_matrix<R>::value && is_matrix<A>::value &&
// matrix_traits<R>::rows==matrix_traits<A>::rows &&
// matrix_traits<R>::cols==matrix_traits<A>::cols
template <class R,class A>
R
make( A const & a );
//Only enabled if:
// is_vector<R>::value && is_vector<A>::value &&
// vector_traits<R>::dim==vector_traits<A>::dim
template <class R,class A>
R
make( A const & a );
//Only enabled if:
// is_matrix<A>::value && is_matrix<B>::value &&
// matrix_traits<A>::rows==matrix_traits<B>::rows &&
// matrix_traits<A>::cols==matrix_traits<B>::cols
template <class A,class B>
A &
assign( A & a, B const & b );
//Only enabled if:
// is_vector<A>::value && is_vector<B>::value &&
// vector_traits<A>::dim==vector_traits<B>::dim
template <class A,class B>
A &
assign( A & a, B const & b );
//*** Creating matrix objects ***
template <class T,int R,int C>
-unspecified-return-type-
zero_matrix();
template <class S,int D>
-unspecified-return-type- identity_matrix();
template <int Dim,class T>
-unspecified-return-type-
rotx_matrix( T angle );
template <int Dim,class T>
-unspecified-return-type-
roty_matrix( T angle );
template <int Dim,class T>
-unspecified-return-type-
rotz_matrix( T angle );
//*** Creating vector objects ***
template <class T,int S>
-unspecified-return-type-
zero_vector();
//*** View proxies of matrix type ***
-unspecified-return-type- row_matrix();
-unspecified-return-type- col_matrix();
-unspecified-return-type- diag_matrix();
-unspecified-return-type- trans_matrix();
-unspecified-return-type- transpose();
template <int R>
-unspecified-return-type- delr();
template <int C>
-unspecified-return-type- delc();
template <int R,int C>
-unspecified-return-type- delrc();
//Only enabled if: is_matrix<A>::value
template <class Scalar,class A>
-unspecified-return_type- scalar_cast( A const & a );
//Only enabled if: is_matrix<A>::value
template <class A>
-unspecified-return-type- mref( A & a );
//*** View proxies of vector type ***
template <int R>
-unspecified-return-type- row();
template <int C>
-unspecified-return-type- col();
-unspecified-return-type- diag();
//Only enabled if: is_vector<A>::value
template <class Scalar,class A>
-unspecified-return_type- scalar_cast( A const & a );
//Only enabled if: is_vector<A>::value
template <class A>
-unspecified-return-type- vref( A & a );
//*** Accessing matrix elements ***
template <int R,int C>
-unspecified-return-type- A();
-unspecified-return-type- A00();
-unspecified-return-type- A01();
...
-unspecified-return-type- A09();
-unspecified-return-type- A10();
...
...
-unspecified-return-type- A99();
//*** Accessing vector elements, swizzling ***
template <int I>
-unspecified-return-type- A();
-unspecified-return-type- A0();
-unspecified-return-type- A1();
...
-unspecified-return-type- A9();
-unspecified-return-type- X();
-unspecified-return-type- Y();
-unspecified-return-type- Z();
-unspecified-return-type- W();
struct _x_;
struct _y_;
struct _z_;
struct _w_;
struct _0_;
struct _1_;
template <int I1,int I2,...int IN>
-unspecified-return-type- sw();
template <class A1,class A2,...class AN>
-unspecified-return-type- sw();
//2D view proxies:
-unspecified-return-type- XX();
-unspecified-return-type- XY();
-unspecified-return-type- XZ();
-unspecified-return-type- XW();
-unspecified-return-type- X0();
-unspecified-return-type- X1();
-unspecified-return-type- YX();
-unspecified-return-type- YY();
-unspecified-return-type- YZ();
-unspecified-return-type- YW();
-unspecified-return-type- Y0();
-unspecified-return-type- Y1();
-unspecified-return-type- ZX();
-unspecified-return-type- ZY();
-unspecified-return-type- ZZ();
-unspecified-return-type- ZW();
-unspecified-return-type- Z0();
-unspecified-return-type- Z1();
-unspecified-return-type- WX();
-unspecified-return-type- WY();
-unspecified-return-type- WZ();
-unspecified-return-type- WW();
-unspecified-return-type- W0();
-unspecified-return-type- W1();
//3D view proxies:
-unspecified-return-type- XXX();
...
-unspecified-return-type- XXW();
-unspecified-return-type- XX0();
-unspecified-return-type- XX1();
-unspecified-return-type- XYX();
...
-unspecified-return-type- XY1();
...
-unspecified-return-type- WW1();
//4D view proxies:
-unspecified-return-type- XXXX();
...
-unspecified-return-type- XXXW();
-unspecified-return-type- XXX0();
-unspecified-return-type- XXX1();
-unspecified-return-type- XXYX();
...
-unspecified-return-type- XXY1();
...
-unspecified-return-type- WWW1();
//*** Matrix and vector types ***
template <class T,int Rows,int Cols>
struct
mat
{
T a[Rows][Cols];
template <class R>
operator R() const
{
R r;
assign(r,*this);
return r;
}
};
template <class Matrix>
struct matrix_traits;
template <class T,int Rows,int Cols>
struct
matrix_traits< mat<T,Rows,Cols> >
{
typedef T scalar_type;
static int const rows=Rows;
static int const cols=Cols;
template <int Row,int Col>
static
scalar_type
r( mat<T,Rows,Cols> const & x )
{
return x.a[Row][Col];
}
template <int Row,int Col>
static
scalar_type &
w( mat<T,Rows,Cols> & x )
{
return x.a[Row][Col];
}
static
scalar_type
ir( int row, int col, mat<T,Rows,Cols> const & x )
{
return x.a[row][col];
}
static
scalar_type &
iw( int row, int col, mat<T,Rows,Cols> & x )
{
return x.a[row][col];
}
};
template <class T,int Dim>
struct
vec
{
T a[Dim];
template <class R>
operator R() const
{
R r;
assign(r,*this);
return r;
}
};
template <class Vector>
struct vector_traits;
template <class T,int Dim>
struct
vector_traits< vec<T,Dim> >
{
typedef T scalar_type;
static int const dim=Dim;
template <int I>
static
scalar_type
r( vec<T,Dim> const & x )
{
return x.a[I];
}
template <int I>
static
scalar_type &
w( vec<T,Dim> & x )
{
return x.a[I];
}
static
scalar_type
ir( int i, vec<T,Dim> const & x )
{
return x.a[i];
}
static
scalar_type &
iw( int i, vec<T,Dim> & x )
{
return x.a[i];
}
};
//*** Generic programming utilities ***
template <
class Matrix,
int Rows=matrix_traits<Matrix>::rows,
int Cols=matrix_traits<Matrix>::cols,
class Scalar=typename matrix_traits<Matrix>::scalar_type>
struct
deduce_matrix
{
typedef /*unspecified*/ type;
};
template <class A,class B,int Rows,int Cols>
struct
deduce_matrix2
{
typedef /*unspecified*/ type;
};
template <
class Vector,
int Dim=vector_traits<Vector>::dim,
class Scalar=typename vector_traits<Vector>::scalar_type>
struct
deduce_vector
{
typedef /*unspecified*/ type;
};
template <class A,class B,int Dim>
struct
deduce_vector2
{
typedef /*unspecified*/ type;
};
template <class A,class B>
struct
deduce_scalar
{
typedef typename impl<A,B>::type type;
};
template <class T>
struct
scalar
{
typedef /*unspecified*/ type;
};
//*** Exception types ***
struct
error:
virtual boost::exception,
virtual std::exception
{
};
struct zero_determinant_error: virtual error { };
} //namespace la
} //namespace boost
//*** Configuration macros ***
#ifndef BOOST_LA_FORCE_INLINE
#define BOOST_LA_FORCE_INLINE /*platform-specific*/
#endif
#ifndef BOOST_LA_INLINE
#define BOOST_LA_INLINE inline
#endif
#ifndef BOOST_LA_INLINE_TRIVIAL
#define BOOST_LA_INLINE_TRIVIAL BOOST_LA_FORCE_INLINE
#endif
#ifndef BOOST_LA_INLINE_CRITICAL
#define BOOST_LA_INLINE_CRITICAL BOOST_LA_FORCE_INLINE
#endif
#ifndef BOOST_LA_INLINE_OPERATIONS
#define BOOST_LA_INLINE_OPERATIONS BOOST_LA_INLINE
#endif
#ifndef BOOST_LA_INLINE_RECURSION
#define BOOST_LA_INLINE_RECURSION BOOST_LA_INLINE_OPERATIONS
#endif