ADMB Documentation  11.1.2403
 All Classes Files Functions Variables Typedefs Friends Defines
dmat4.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dmat4.cpp 1712 2014-02-28 23:52:33Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017  struct dvec_ptr_ptr
00018  {
00019    void ** m;
00020  };
00021 
00026 dmatrix& dmatrix::operator=(const dmatrix& m1)
00027  {
00028    if (allocated(*this))
00029    {
00030      if (rowmin() != m1.rowmin() || rowmax() != m1.rowmax() ||
00031        colmin() != m1.colmin() || colmax() != m1.colmax() )
00032      {
00033        cerr << " Incompatible array bounds in "
00034        "dmatrix& operator = (const dmatrix&)\n";
00035        ad_exit(21);
00036      }
00037 
00038      if (m != m1.m)            // check for condition that both matrices
00039      {                         // point to the same object
00040        for (int i=rowmin();i<=rowmax();i++)
00041        {
00042          *(m+i) = m1[i];
00043        }
00044      }
00045    }
00046    else
00047    {
00048      index_min=m1.index_min;
00049      index_max=m1.index_max;
00050      shape=m1.shape;
00051      if (shape)
00052      {
00053        (shape->ncopies)++;
00054      }
00055      m = m1.m;
00056    }
00057    return(*this);
00058  }
00059 
00064 dmatrix& dmatrix::operator+=(const dmatrix& m1)
00065  {
00066    if (rowmin() != m1.rowmin() || rowmax() != m1.rowmax() )
00067    {
00068      cerr << " Incompatible array bounds in "
00069      "dmatrix& operator += (const dmatrix&)\n";
00070      ad_exit(21);
00071    }
00072 
00073    for (int i=rowmin();i<=rowmax();i++)
00074    {
00075      elem(i) += m1.elem(i);
00076    }
00077    return(*this);
00078  }
00079 
00084 dmatrix& dmatrix::operator-=(const dmatrix& m1)
00085  {
00086    if (rowmin() != m1.rowmin() || rowmax() != m1.rowmax() )
00087    {
00088      cerr << " Incompatible array bounds in "
00089      "dmatrix& operator -= (const dmatrix&)\n";
00090      ad_exit(21);
00091    }
00092 
00093    for (int i=rowmin();i<=rowmax();i++)
00094    {
00095      elem(i) -= m1.elem(i);
00096    }
00097    return(*this);
00098  }