ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
lmat_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 lmatrix::lmatrix(const lmatrix_position& pos)
00018  {
00019    int nrl=pos.row_min;
00020    int nrh=pos.row_max;
00021    ivector& ncl=(ivector&) pos.lb;
00022    ivector& nch=(ivector&) pos.ub;
00023    if (nrl !=ncl.indexmin() || nrh !=ncl.indexmax() ||
00024      nrl !=nch.indexmin() || nrh !=nch.indexmax())
00025    {
00026      cerr << "Incompatible array bounds in "
00027      " lmatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)\n";
00028      ad_exit(1);
00029    }
00030 
00031    if ( (shape = new mat_shape(nrl,nrh,ncl[nrl],nch[nrl]))== 0)
00032    {
00033      cerr << " Error allocating memory in lmatrix contructor\n";
00034      ad_exit(21);
00035    }
00036 
00037    size_t rs=rowsize();
00038    if ( (m = new lvector [rs]) == 0)
00039    {
00040      cerr << " Error allocating memory in lmatrix contructor\n";
00041      ad_exit(21);
00042    }
00043 
00044    #ifdef DIAG
00045      cerr << "Created a lmatrix with adress "<< farptr_tolong(m)<<"\n";
00046    #endif
00047 
00048    m -= rowmin();
00049 
00050    for (int i=rowmin(); i<=rowmax(); i++)
00051    {
00052      m[i].allocate(ncl[i],nch[i]);
00053    }
00054  }