ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_m21.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 dvar_matrix operator-(const dvar_matrix& m1, const dmatrix& m2 )
00018  {
00019    RETURN_ARRAYS_INCREMENT();
00020 
00021    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00022    {
00023      cerr << " Incompatible array bounds in "
00024      "dvar_matrix operator+(const dvar_matrix& x, const dmatrix& m)\n";
00025      ad_exit(21);
00026    }
00027 
00028    dvar_matrix tmp;
00029    tmp.allocate(m1.indexmin(),m1.indexmax());
00030 
00031    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00032    {
00033      tmp[i]=m1[i]-m2[i];
00034    }
00035    RETURN_ARRAYS_DECREMENT();
00036    return(tmp);
00037  }
00038 
00043  dvar_matrix operator-(const dvar_matrix& m1, const dvar_matrix& m2)
00044  {
00045    RETURN_ARRAYS_INCREMENT();
00046 
00047    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00048    {
00049      cerr << " Incompatible array bounds in "
00050      "dvar_matrix operator+(const dvar_matrix& x, const dvar_matrix& m)\n";
00051      ad_exit(21);
00052    }
00053 
00054    dvar_matrix tmp;
00055    tmp.allocate(m1.indexmin(),m1.indexmax());
00056 
00057    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00058    {
00059      tmp[i]=m1[i]-m2[i];
00060    }
00061    RETURN_ARRAYS_DECREMENT();
00062    return(tmp);
00063  }
00064 
00069  dvar_matrix operator-(const dmatrix& m1, const dvar_matrix& m2)
00070  {
00071    RETURN_ARRAYS_INCREMENT();
00072 
00073    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00074    {
00075      cerr << " Incompatible array bounds in "
00076      "dvar_matrix operator+(const dmatrix& x, const dvar_matrix& m)\n";
00077      ad_exit(21);
00078    }
00079 
00080    dvar_matrix tmp;
00081    tmp.allocate(m2.indexmin(),m2.indexmax());
00082 
00083    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00084    {
00085      tmp[i]=m1[i]-m2[i];
00086    }
00087    RETURN_ARRAYS_DECREMENT();
00088    return(tmp);
00089  }