- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.7.1/Ipopt/contrib/MatlabInterface-Old/src/matlabscalar.h

Go to the documentation of this file.

    00001 // Copyright (C) 2007 Peter Carbonetto. All Rights Reserved.
    00002 // This code is published under the Common Public License.
    00003 //
    00004 // Author: Peter Carbonetto
    00005 //         Dept. of Computer Science
    00006 //         University of British Columbia
    00007 //         May 19, 2007
    00008
    00009 #ifndef INCLUDE_MATLABSCALAR
    00010 #define INCLUDE_MATLABSCALAR
    00011
    00012 #include "mex.h"
    00013
    00014 // Class MatlabScalar
    00015 // -----------------------------------------------------------------
    00016 // The main appeal of this class is that one can create a scalar
    00017 // object that accesses a MATLAB array.
    00018 //
    00019 // Note that the copy assignment operator is not valid for this class
    00020 // because we cannot reassign a reference.
    00021 class MatlabScalar {
    00022 public:
    00023
    00024   // This constructor accepts as input a pointer to a Matlab array
    00025   // which must be a scalar in double precision.
    00026   explicit MatlabScalar (const mxArray* ptr);
    00027
    00028   // This constructor creates a new Matlab array which is a scalar
    00029   // in double precision.
    00030   MatlabScalar (mxArray*& ptr, double value);
    00031
    00032   // The copy constructor.
    00033   MatlabScalar (MatlabScalar& source);
    00034
    00035   // The destructor.
    00036   ~MatlabScalar() { };
    00037
    00038   // Access the value of the scalar.
    00039   operator const double () const { return x; };
    00040
    00041   // Assign the value of the scalar.
    00042   MatlabScalar& operator= (double value);
    00043
    00044 protected:
    00045   double& x;
    00046
    00047   // The copy assignment operator is kept protected because it is
    00048   // invalid.
    00049   MatlabScalar& operator= (const MatlabScalar& source) { return *this; };
    00050 };
    00051
    00052 #endif