ADMB Documentation  11.1.1927
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_m37.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_m37.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00017  dvar_matrix::dvar_matrix(const ad_integer& nrl,const ad_integer& nrh,
00018    const index_type& ncl,const index_type& nch)
00019  {
00020    allocate(nrl,nrh,ncl,nch);
00021    #ifdef SAFE_ARRAYS
00022      initialize();
00023    #endif
00024  }
00025 
00030  void dvar_matrix::allocate(const ad_integer& nrl,const ad_integer& nrh,
00031    const index_type& ncl,const index_type& nch)
00032  {
00033    if (nrl>nrh)
00034      allocate();
00035    else
00036    {
00037      //if (nrl !=ncl.indexmin() || nrh !=ncl.indexmax() ||
00038      //  nrl !=nch.indexmin() || nrh !=nch.indexmax())
00039      if ( (ncl.isinteger() && (nrl !=ncl.indexmin() || nrh !=ncl.indexmax())) ||
00040        (nch.isinteger() && (nrl !=nch.indexmin() || nrh !=nch.indexmax())))
00041      {
00042        cerr << "Incompatible array bounds in dvar_matrix(int nrl,int nrh,"
00043         "const ivector& ncl, const ivector& nch)" << endl;
00044        ad_exit(1);
00045      }
00046      index_min=int(nrl);
00047      index_max=int(nrh);
00048 
00049      int rs=rowsize();
00050      if ( (m = new dvar_vector [rs]) == 0)
00051      {
00052        cerr << " Error allocating memory in dmatrix contructor" << endl;
00053        ad_exit(21);
00054      }
00055      if ( (shape = new mat_shapex(m))== 0)
00056      {
00057        cerr << " Error allocating memory in dvar_matrix contructor" << endl;
00058        ad_exit(21);
00059      }
00060      m -= int(nrl);
00061      for (int i=nrl; i<=nrh; i++)
00062      {
00063        m[i].allocate(ncl[i],nch[i]);
00064      }
00065    }
00066  }