- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.7.1/Ipopt/contrib/MatlabInterface-Old/src/arrayofmatrices.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_ARRAYOFMATRICES
    00010 #define INCLUDE_ARRAYOFMATRICES
    00011
    00012 #include "array.h"
    00013 #include "matlabmatrix.h"
    00014 #include "mex.h"
    00015
    00016 // Class ArrayOfMatrices.
    00017 // -----------------------------------------------------------------
    00018 class ArrayOfMatrices : public Array<Matrix*> {
    00019 public:
    00020
    00021   // This version of the constructor behaves just like its parent.
    00022   explicit ArrayOfMatrices (int length)
    00023     : Array<Matrix*>(length) { };
    00024
    00025   // This constructor creates an array of matrices from a Matlab
    00026   // array. It accepts either a matrix in double precision, or a cell
    00027   // array with entries that are matrices.
    00028   explicit ArrayOfMatrices (const mxArray* ptr);
    00029
    00030   // This constructor creates an array of matrices from a collection
    00031   // of Matlab arrays. The Matlab arrays must be matrices.
    00032   ArrayOfMatrices (const mxArray* ptrs[], int numptrs);
    00033
    00034   // This constructor creates an array of matrices and the
    00035   // associated Matlab structures. The Matlab structures are
    00036   // matrices. The second input argument acts as a template for the
    00037   // creation of the matrices, but the data from "model" is not
    00038   // actually copied into the new ArrayOfMatrices object. It is up
    00039   // to the user to make sure that the array of mxArray pointers has
    00040   // enough room for the pointers to the Matlab arrays.
    00041   ArrayOfMatrices (mxArray* ptrs[], const ArrayOfMatrices& model);
    00042
    00043   // This constructor creates an array of matrices using the second
    00044   // input argument as a model. The input argument "data" contains
    00045   // the element data. Note that the information is NOT copied from
    00046   // the model!
    00047   ArrayOfMatrices (double* data, const ArrayOfMatrices& model);
    00048
    00049   // The copy constructor makes a shallow copy of the source object.
    00050   ArrayOfMatrices (const ArrayOfMatrices& source);
    00051
    00052   // The destructor.
    00053   ~ArrayOfMatrices();
    00054
    00055   // Copy assignment operator that observes the same behaviour as
    00056   // the Array copy assignment operator.
    00057   ArrayOfMatrices& operator= (const ArrayOfMatrices& source);
    00058
    00059   // Copy the data from the location in memory pointed to by "source"
    00060   // to the matrices in the given order. It is assumed that the input
    00061   // points to a valid source of data.
    00062   void inject (const double* source);
    00063
    00064   // Copy the elements from all the matrices to the location in
    00065   // memory pointed to by "dest". It is assumed that sufficient
    00066   // memory is allocated for the destination.
    00067   void copyto (double* dest) const;
    00068
    00069   // Returns true if the two objects have the exact same dimensions.
    00070   bool operator== (const ArrayOfMatrices& a) const;
    00071   bool operator!= (const ArrayOfMatrices& a) const
    00072   { return !(*this == a); };
    00073
    00074   // Return the total number of elements in all the matrices.
    00075   int numelems() const;
    00076
    00077 protected:
    00078   static int getnummatlabmatrices (const mxArray* ptr);
    00079 };
    00080
    00081 #endif