ADMB Documentation  11.1.2397
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_ma2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_ma2.cpp 1919 2014-04-22 22:02:01Z johnoel $
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    kkludge_object kk;
00029    dvar_matrix tmp(m1.rowmin(),m1.rowmax(),kk);
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    kkludge_object kk;
00054    dvar_matrix tmp(m1.rowmin(),m1.rowmax(),kk);
00055    //dvar_matrix tmp;
00056    //tmp.allocate(m1);
00057 
00058    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00059    {
00060      tmp(i)=m1(i)+m2(i);
00061    }
00062    RETURN_ARRAYS_DECREMENT();
00063    return(tmp);
00064  }
00065 
00070 dvar_matrix operator+(const dmatrix& m1, const dvar_matrix& m2)
00071  {
00072    RETURN_ARRAYS_INCREMENT();
00073 
00074    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00075    {
00076      cerr << " Incompatible array bounds in "
00077      "dvar_matrix operator+(const dmatrix& x, const dvar_matrix& m)\n";
00078      ad_exit(21);
00079    }
00080    kkludge_object kk;
00081    dvar_matrix tmp(m1.rowmin(),m1.rowmax(),kk);
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  }