ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
imat_a.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
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(const imatrix_position& pos)
00018  {
00019    int nrl=pos.row_min;
00020    int nrh=pos.row_max;
00021    index_min=nrl;
00022    index_max=nrh;
00023    const ivector& ncl=pos.lb;
00024    const ivector& nch=pos.ub;
00025    if (nrl !=ncl.indexmin() || nrh !=ncl.indexmax() ||
00026      nrl !=nch.indexmin() || nrh !=nch.indexmax())
00027    {
00028      cerr << "Incompatible array bounds in "
00029      "imatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)\n";
00030      ad_exit(1);
00031    }
00032 
00033    int rs=rowsize();
00034 
00035    if ( (m = new ivector [rs]) == 0)
00036    {
00037      cerr << " Error allocating memory in imatrix contructor\n";
00038      ad_exit(21);
00039    }
00040 
00041    if ( (shape = new mat_shapex(m))== 0)
00042    {
00043      cerr << " Error allocating memory in imatrix contructor\n";
00044      ad_exit(21);
00045    }
00046 
00047    #ifdef DIAG
00048      cerr << "Created a imatrix with adress "<< farptr_tolong(m)<<"\n";
00049    #endif
00050 
00051    m -= rowmin();
00052 
00053    for (int i=rowmin(); i<=rowmax(); i++)
00054    {
00055      m[i].allocate(ncl[i],nch[i]);
00056    }
00057  }