ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
dmat16.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 dmatrix  operator-(const dmatrix& m1, const dmatrix& m2)
00018  {
00019    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00020    {
00021      cerr << " Incompatible array bounds in "
00022      "dmatrix  operator - (const dmatrix& x, const dmatrix& m)\n";
00023      ad_exit(21);
00024    }
00025 
00026    dmatrix tmp;
00027    tmp.allocate(m1.rowmin(),m1.rowmax());
00028 
00029    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00030    {
00031      tmp.elem(i)=m1.elem(i)-m2.elem(i);
00032    }
00033    return(tmp);
00034  }
00035 
00040 dmatrix operator+(const dmatrix& m1, const dmatrix& m2)
00041  {
00042    if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
00043    {
00044      cerr << " Incompatible array bounds in "
00045      "dmatrix  operator + (const dmatrix& x, const dmatrix& m)\n";
00046      ad_exit(21);
00047    }
00048 
00049    dmatrix tmp;
00050    tmp.allocate(m1.rowmin(),m1.rowmax());
00051 
00052    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00053    {
00054      tmp.elem(i)=m1.elem(i)+m2.elem(i);
00055    }
00056    return(tmp);
00057  }
00058 
00063 dmatrix operator+(const double d, const dmatrix& m2)
00064  {
00065    dmatrix tmp;
00066    tmp.allocate(m2.rowmin(),m2.rowmax());
00067    for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
00068    {
00069      tmp.elem(i)=d+m2.elem(i);
00070    }
00071    return(tmp);
00072  }
00073 
00078 dmatrix operator-(const double d, const dmatrix& m2)
00079  {
00080    dmatrix tmp;
00081    tmp.allocate(m2.rowmin(),m2.rowmax());
00082    for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
00083    {
00084      tmp.elem(i)=d-m2.elem(i);
00085    }
00086    return(tmp);
00087  }
00088 
00093 dmatrix operator*(const double d, const dmatrix& m2)
00094  {
00095    dmatrix tmp;
00096    tmp.allocate(m2.rowmin(),m2.rowmax());
00097    for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
00098    {
00099      tmp.elem(i)=d*m2.elem(i);
00100    }
00101    return(tmp);
00102  }
00103 
00108 dmatrix operator+(const dmatrix& m1, const double d)
00109  {
00110    dmatrix tmp;
00111    tmp.allocate(m1.rowmin(),m1.rowmax());
00112    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00113    {
00114      tmp.elem(i)=m1.elem(i)+d;
00115    }
00116    return(tmp);
00117  }
00118 
00123 dmatrix operator-(const dmatrix& m1, const double d)
00124  {
00125    dmatrix tmp;
00126    tmp.allocate(m1.rowmin(),m1.rowmax());
00127    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00128    {
00129      tmp.elem(i)=m1.elem(i)-d;
00130    }
00131    return(tmp);
00132  }
00133 
00138 dmatrix operator*(const dmatrix& m1, const double d)
00139  {
00140    dmatrix tmp;
00141    tmp.allocate(m1.rowmin(),m1.rowmax());
00142    for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
00143    {
00144      tmp.elem(i)=m1.elem(i)*d;
00145    }
00146    return(tmp);
00147  }