ADMB Documentation  11.1.2246
 All Classes Files Functions Variables Typedefs Friends Defines
imat5.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: imat5.cpp 1713 2014-03-01 00:26:20Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017 imatrix& imatrix::operator=(const imatrix& m1)
00018  {
00019    if (allocated(*this))
00020    {
00021      if (rowmin() != m1.rowmin() || rowmax() != m1.rowmax() ||
00022        colmin() != m1.colmin() || colmax() != m1.colmax() )
00023      {
00024        cerr << rowmin() << endl;
00025        cerr << rowmax() << endl;
00026        cerr << m1.rowmin() << endl;
00027        cerr << m1.rowmax() << endl;
00028        cerr << colmin() << endl;
00029        cerr << colmax() << endl;
00030        cerr << m1.colmin() << endl;
00031        cerr << m1.colmax() << endl;
00032        cerr << " Incompatible array bounds in "
00033        "imatrix& operator=(const imatrix&)\n";
00034        ad_exit(21);
00035      }
00036 
00037      if (m != m1.m)            // check for condition that both matrices
00038      {                         // point to the same object
00039        for (int i=rowmin();i<=rowmax();i++)
00040        {
00041          *(m+i) = m1[i];
00042        }
00043      }
00044    }
00045    else
00046    {
00047      index_min=m1.index_min;
00048      index_max=m1.index_max;
00049      shape=m1.shape;
00050      if (shape)
00051      {
00052        (shape->ncopies)++;
00053      }
00054      m = m1.m;
00055    }
00056    return(*this);
00057  }
00058 
00063  imatrix& imatrix::operator= (const int n)
00064  {
00065    int mmin=indexmin();
00066    int mmax=indexmax();
00067    for (int i=mmin;i<=mmax;i++)
00068    {
00069      (*this)(i) = n;
00070    }
00071    return(*this);
00072  }