ADMB Documentation  11.1.1916
 All Classes Files Functions Variables Typedefs Friends Defines
sdmat.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: sdmat.cpp 1681 2014-02-25 23:11:58Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00017 sdmatrix::sdmatrix(int irh)
00018 {
00019   allocate(irh);
00020 }
00021 
00026 sdmatrix::sdmatrix()
00027 {
00028    //unsigned nrl = 0;
00029    //unsigned nrh = 0;
00030    shape=NULL;
00031    m=NULL;
00032 }
00033 
00038 void sdmatrix::allocate(int irh)
00039 {
00040    unsigned nrl = 1;
00041    //unsigned nrh = irh;
00042    index_min=nrl;
00043    index_max=nrl;
00044 
00045    #ifdef DIAG
00046      myheapcheck("Entering sdmatrix(nrh)" );
00047    #endif
00048 
00049    #ifdef DIAG
00050      cerr << "created a ncopies with address "<< farptr_tolong(ncopies)<<"\n";
00051    #endif
00052    m = new dvector [rowsize()];
00053 
00054    #ifdef DIAG
00055      cerr << "Created a sdmatrix with adress "<< farptr_tolong(m)<<"\n";
00056    #endif
00057 
00058    shape= new mat_shapex(m);
00059    m -= rowmin();
00060 
00061    for (int i=rowmin(); i<=rowmax(); i++)
00062    {
00063      m[i].allocate(1, i);
00064      #ifdef DIAG
00065        cerr << "Created a dvector with address "<< farptr_tolong(*(m+i))<<"\n";
00066      #endif
00067    }
00068    #ifdef DIAG
00069      myheapcheck("Leaving sdmatrix(nrh)" );
00070    #endif
00071 }
00072 
00076 sdmatrix::~sdmatrix()
00077 {
00078   #ifdef DIAG
00079      myheapcheck("Entering ~sdmatrix() ");
00080   #endif
00081   deallocate();
00082 }
00083 
00088 void sdmatrix::deallocate()
00089 {
00090   dmatrix::deallocate();
00091 }