rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWConvertGenMat< From, To > Struct Template Reference
[Math Collections]

Converts between RWGenMat types with different datatypes. More...

#include <rw/math/genmat.h>

List of all members.

Public Member Functions

 RWConvertGenMat (const RWGenMat< From > &v)
 operator RWGenMat< To > () const

Detailed Description

template<class From, class To>
struct RWConvertGenMat< From, To >

Class RWConvertGenMat<From,To> converts between RWGenMat types with different datatypes. It assumes that there is a conversion operator from From to To.

Synopsis

 template <class From, class To>
 class RWConvertGenMat;

Examples

 #include <rw/math/genmat.h>
 
 int main()
 {
        // create a 2x2 matrix
    RWGenMat<int> d("2x2[1 2 3 4]");
 
        // convert int matrix d to DComplex
        // matrix c with imag part 0
    RWGenMat<DComplex> c = RWConvertGenMat<int,DComplex>(d);
 
        // convert int matrix d to a double
        // matrix and then call sin
    RWGenMat<double> s = RWConvertGenMat<int,double>(d);
    s = sin(s);
 }

Constructor & Destructor Documentation

template<class From, class To>
RWConvertGenMat< From, To >::RWConvertGenMat ( const RWGenMat< From > &  v  )  [inline]

Constructs a new matrix of type RWGenMat<To> that can be used anywhere as a type RWGenMat<To> . Note that a temporary matrix is created every time this constructor is invoked, but the conversion operator below can be used repeatedly without creating additional temporary matrices.


Member Function Documentation

template<class From, class To>
RWConvertGenMat< From, To >::operator RWGenMat< To > (  )  const [inline]

Automatic conversion operator that enables class RWConvertGenMat<From,To> to be used as an RWGenMat<To> . While the actual conversion takes place in the constructor, this operator provides a reference to that converted matrix.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.