SourceForge Logo Tiny Vector Matrix library using Expression Templates Sourceforge Project Page

FAQ

Contents:
  1. How is tvmet licensed?
  2. Can I use it in commercial software products?
  3. Debugging the code
  4. Optimizing the code
  5. ambiguous overload for ... Compiler Error
  6. conversion from ... to non-scalar type ... Compiler Error
  7. could not convert `tvmetoperatorXX(...)' to `bool' ... Compiler Error
  8. no match for ?= operator
  9. storage size of `ERROR_CommaInitializerList_is_too_long' isn't known
  10. no match for `...' operator
  11. no match for `tvmetMatrix<double, R, C>& * tvmet::Vector<double, Sz>&' operator
  12. Using with Linux Real-time Extensions crashes in kernel mode
  13. Failed regression tests

Certain items on this page are also covered by the Usage and Some Notes ... pages!

How is tvmet licensed?

tvmet comes with completely free source code. tvmet is available under the terms of the GNU Lesser General Public License (LGPL).

I have amended the LGPL to explicitly allow statically linking tvmet (or any modified version of tvmet) to your software. The LGPL is not clear on this and I definitely want to allow it.

See also:
License

Can I use it in commercial software products?

Yes, you can. The LGPL allows you to do this, and you do not need to release the source code to your software. You do need to release the source code for any modifications you make to tvmet itself. (We would hope you would send any improvements like these back to us anyways.)

Debugging the code

Not all faults can be caught at compile time. Therefore, there is a need for runtime debugging by defining TVMET_DEBUG (e.g. index operators of Vector::operator(i) and Matrix::operator(i,j)). On defined TVMET_DEBUG a bounds checking is involved. Runtime errors are handled throwing an assertion failure using std::assert(). TVMET_DEBUG is not enabled by defining DEBUG. This behavior differs from release less than 0.6.0

If you don't get the expected result on certain operations you can try the Expression printing feature to check that the expression is being evaluated as you expect.

Optimizing the code

Starting after tvmet 1.5.0 there is a new define TVMET_OPTIMIZE.

If this is defined tvmet uses some compiler specific keywords. Mainly, this declares the functions using gcc's __attribute__((always_inline)). This allows the compiler to produce high efficient code even on less optimization levels, like gcc's -O2 or even -O! This is known to work with gcc v3.3.3 (and higher). Using icc's v8 gnuc compatibility mode this may work, I've read that it's using as an hint, this means you can have static inline functions inside left so you can't get the full power of this feature for circumstances.

ambiguous overload for ... Compiler Error

When using gcc-2.96 you can get a compiler error like:

   ambiguous overload for ...
   /usr/include/g++-3/stl_relops.h:42: candidates are: bool operator>
   ...

I haven't any solution for this--even if I don't use it in the tvmet library. A simple define __SGI_STL_INTERNAL_RELOPS in the config header doesn't solve the problem. The easiest way (brute force method) is to comment out all operators in stl_reops.h. (The better way is to use the gcc-3.0.x and later, see Compiler Support.)

conversion from ... to non-scalar type ... Compiler Error

You get a compiler error like:

   conversion from `tvmet::XprVector< ... >, Sz>' to non-scalar type
    `tvmet::Vector<T, Sz>' requested

Please read about Construction and Initializing. You probably ignored or forgot the rules of using expression templates.

could not convert `tvmet::operatorXX(...)' to `bool' ... Compiler Error

You get a compiler error like:

   could not convert `tvmet::operator==( ... , ... )' to `bool'

In the example above, you did try (or hoped) to use a global operator== which doesn't return a bool. Please read Compare Vectors and Matrices.

no match for ?= operator

You get a compiler error like:

   no match for `tvmet::Vector<...>& /= tvmet::Vector<...>&' operator

For element-wise operations, you need to use the element_wise namespace (found within tvmet). As the name suggests, all these operators are performed in an element wise fashion. (e.g. division of two vectors--not allowed from a mathematical perspective--element by element.) The following code snippet shows how to use it:

   using namespace tvmet;
   Vector<double,3> v1, v2;

   v1 = 1,2,3;
   v2 = v1;

   cout << v1 << endl;
   {
     using namespace tvmet::element_wise;
     v1 /= v2;
   }
   cout << v1 << endl;

See also:
... on operators and namespace element_wise

... about aliasing

storage size of `ERROR_CommaInitializerList_is_too_long' isn't known

You get a compiler error like:

   In member function `tvmet::CommaInitializer<Obj, LEN>::Initializer<T, (N + 1)> ....
   storage size of `ERROR_CommaInitializerList_is_too_long' isn't known

You have caused a forced compile time error. tvmet prevents you from overwriting foreign memory! In other words, your comma separated initializer list is too long, e.g. you wrote something like:

   using namespace tvmet;
   Vector<double,3>   v0;

   v0 = 1,2,3,4,5,6,7,8,9;

You just tried to fill a Vector of length 3 with 9 values, which would normally result in values being written off the end of the vector. tvmet prevents this with the compile time error you just saw.

no match for `...' operator

You get a compiler error like:

   no match for `tvmet::Matrix<T, Sz, Sz>& * tvmet::XprVector<tvmet::MatrixColVectorReference<T, Sz, Sz>, Sz>' operator
   include/tvmet/xpr/VectorOperators.h:123: candidates are:
   // a lot of candidates....

Perhaps you wrote code like:

   Matrix<float,3,3>             eigenvecs;
   Matrix<float,3,3>             M;
   ...

   Vector<float,3> ev0( M * col(eigenvecs, 0) );

Using tvmet prior to release 1.2.0 in this case: Obviously an operator is missing... but which one? Well, all arithmetic operators have a functional equivalent, in this case, prod(). Rewriting the code above using the function syntax will give you a more descriptive error message:

   no matching function for call to
   `prod(tvmet::Matrix<float, 3, 3>&, tvmet::XprVector<tvmet::MatrixColVectorReference<float, 3, 3>, 3>)'

This says, I forgot to write a function with the appropriate operator. In this case, please give me a hint by writing a short example, used compiler and tvmet release.

See also:
no match for `tvmetMatrix<double, R, C>& * tvmet::Vector<double, Sz>&' operator.

no match for `tvmet::Matrix<double, R, C>& * tvmet::Vector<double, Sz>&' operator

You get a compiler error like:

   no match for `tvmet::Matrix<double, 4, 4>& * tvmet::Vector<double, 3>&' operator
   candidates are: T tvmet::operator*(const T&, ...) ...

This is a feature of tvmet. The compiler detects a mathematical problem: You tried call an operator between tvmet objects which had incompatible dimensions. For example, you attempted to multiply a matrix of dimension 4x4 with a vector of size 3 - this isn't mathematically feasible.

Using with Linux Real-time Extensions crashes in kernel mode

Normally there should not be a problem on using tvmet inside Linux kernel space as a C++ kernel module. Unfortunately, code working in normal environment (e.g. Linux user space) crashes the Linux box by using linux real-time extensions, definitely on RTAI.

I haven't found the reason yet, my knowledge of assembler and debugging is too limited.

Failed regression tests

Well, this is a strange world. It can happen that some (especially the tan) regression test can fail. This is not a problem with the tvmet library. After some hours I reduce the problem to:

   cout << (std::tan(1.0) - std::tan(1.0)) << endl;

got 6.17995e-17 on my Linux Mandrake 8.2/9.1 box. It makes no difference if I take the tan function from namespace std or from the global namespace. This is especially a problem for g++ v3.2 and prior. The Intel compiler v7.0 isn't affected.

Especially on VC++ 7.1 you will get 2 failed tests for complex Matrix and Vector. The error is about 8.88178e-016 and 1.77636e-015.


Author: