ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
sdmat.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 sdmatrix::sdmatrix(int irh)
00018 {
00019   allocate(irh);
00020 }
00021 
00023 sdmatrix::sdmatrix()
00024 {
00025    //unsigned nrl = 0;
00026    //unsigned nrh = 0;
00027    shape=NULL;
00028    m=NULL;
00029 }
00030 
00035 void sdmatrix::allocate(int irh)
00036 {
00037    int nrl = 1;
00038    //unsigned nrh = irh;
00039    index_min=nrl;
00040    index_max=nrl;
00041 
00042    #ifdef DIAG
00043      myheapcheck("Entering sdmatrix(nrh)" );
00044    #endif
00045 
00046    #ifdef DIAG
00047      cerr << "created a ncopies with address "<< farptr_tolong(ncopies)<<"\n";
00048    #endif
00049    m = new dvector [rowsize()];
00050 
00051    #ifdef DIAG
00052      cerr << "Created a sdmatrix with adress "<< farptr_tolong(m)<<"\n";
00053    #endif
00054 
00055    shape= new mat_shapex(m);
00056    m -= rowmin();
00057 
00058    for (int i=rowmin(); i<=rowmax(); i++)
00059    {
00060      m[i].allocate(1, i);
00061      #ifdef DIAG
00062        cerr << "Created a dvector with address "<< farptr_tolong(*(m+i))<<"\n";
00063      #endif
00064    }
00065    #ifdef DIAG
00066      myheapcheck("Leaving sdmatrix(nrh)" );
00067    #endif
00068 }
00069 
00073 sdmatrix::~sdmatrix()
00074 {
00075   #ifdef DIAG
00076      myheapcheck("Entering ~sdmatrix() ");
00077   #endif
00078   deallocate();
00079 }
00080 
00085 void sdmatrix::deallocate()
00086 {
00087   dmatrix::deallocate();
00088 }