World of Rigid Bodies (WoRB)
|
Represents a MATLAB scalar double value. More...
#include <mexWoRB.h>
Public Member Functions | |
Scalar (const mxArray *arg, const char *argDesc) | |
Constructs the instance from the given MATLAB array of doubles. | |
Scalar (const mxArray *obj, mwIndex index, const char *fieldName) | |
Constructs the instance from the given MATLAB structure field. | |
operator double () const | |
operator int () const | |
operator unsigned () const | |
operator double & () | |
mxArray * | toMxArray () |
Converts the instance to MATLAB real scalar. | |
Private Member Functions | |
void | Initialize (const mxArray *arg, const char *argDesc, bool defaultValue=false) |
Initializes the instance from a MATLAB array of doubles. | |
Private Attributes | |
double | value |
Mex::Scalar::Scalar | ( | const mxArray * | arg, |
const char * | argDesc | ||
) | [inline] |
Constructs the instance from the given MATLAB array of doubles.
Definition at line 333 of file mexWoRB.h.
References Initialize().
{ Initialize( arg, argDesc ); }
Mex::Scalar::Scalar | ( | const mxArray * | obj, |
mwIndex | index, | ||
const char * | fieldName | ||
) | [inline] |
Constructs the instance from the given MATLAB structure field.
Definition at line 340 of file mexWoRB.h.
References Initialize().
{ Initialize( mxGetField( obj, index, fieldName ), fieldName ); }
void Mex::Scalar::Initialize | ( | const mxArray * | arg, |
const char * | argDesc, | ||
bool | defaultValue = false |
||
) | [inline, private] |
Initializes the instance from a MATLAB array of doubles.
Definition at line 304 of file mexWoRB.h.
References WoRB::SevereError(), and value.
Referenced by Scalar().
{ if ( arg == NULL ) { value = defaultValue; return; } // Parse value from different argument types // int ndim = mxGetNumberOfDimensions( arg ); mwSize len = mxGetNumberOfElements( arg ); if ( mxIsDouble( arg ) && ! mxIsComplex( arg ) && len >= 1 ) { double* data = mxGetPr( arg ); value = data != NULL ? data[0] : 0.0; return; } // If we couldn't parse real value, return an error WoRB::SevereError( "WoRB:parseDouble:invarg", "'%s' must be a real number.", argDesc ); }
Mex::Scalar::operator double | ( | ) | const [inline] |
Mex::Scalar::operator double & | ( | ) | [inline] |
Mex::Scalar::operator int | ( | ) | const [inline] |
Mex::Scalar::operator unsigned | ( | ) | const [inline] |
mxArray* Mex::Scalar::toMxArray | ( | ) | [inline] |
double Mex::Scalar::value [private] |
Definition at line 300 of file mexWoRB.h.
Referenced by Initialize(), operator double(), operator double &(), operator int(), operator unsigned(), and toMxArray().