ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_m30.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 // file fvar.cpp
00012 // constructors, destructors and misc functions involving class dvariable
00013 
00014 #include "fvar.hpp"
00015 
00016 #ifdef __TURBOC__
00017   #pragma hdrstop
00018   #include <iostream.h>
00019 #endif
00020 
00021 #ifdef __ZTC__
00022   #include <iostream.hpp>
00023 #endif
00024 
00025 
00026 #include <stdio.h>
00027 #ifndef __SUN__
00028 #endif
00029 #include <math.h>
00030 
00035 dvar_matrix operator/(const dvar_matrix& m, const double e)
00036 {
00037   dvar_matrix tmp;
00038   tmp.allocate(m.indexmin(),m.indexmax());
00039   for (int i=m.rowmin();i<=m.rowmax();i++)
00040   {
00041     tmp(i)=m(i)/e;
00042   }
00043   return tmp;
00044 }
00045 
00050 dvar_matrix operator/(const dvar_matrix& m, const prevariable& e)
00051 {
00052   dvar_matrix tmp;
00053   tmp.allocate(m.indexmin(),m.indexmax());
00054   for (int i=m.rowmin();i<=m.rowmax();i++)
00055   {
00056     tmp(i)=m(i)/e;
00057   }
00058   return tmp;
00059 }
00060 
00065 dvar_matrix operator/(const dmatrix& m, const prevariable& e)
00066 {
00067   dvar_matrix tmp;
00068   tmp.allocate(m.indexmin(),m.indexmax());
00069   for (int i=m.rowmin();i<=m.rowmax();i++)
00070   {
00071     tmp(i)=m(i)/e;
00072   }
00073   return tmp;
00074 }
00075 
00080 dvar_matrix symmetrize(const dvar_matrix& m)
00081 {
00082   if (m.rowmin() != m.colmin() || m.rowmax() != m.colmax() )
00083   {
00084     cerr << " Non square matrix passed to dmatrix symmetrize\n";
00085     ad_exit(1);
00086   }
00087   int rmin=m.rowmin();
00088   int rmax=m.rowmax();
00089 
00090   dvar_matrix s(rmin,rmax,rmin,rmax);
00091 
00092 
00093   for (int i=rmin;i<=rmax;i++)
00094   {
00095     s(i,i)=m(i,i);
00096     for (int j=rmin;j<i;j++)
00097     {
00098       s(i,j)=(m(i,j)+m(j,i))/2.;
00099       s(j,i)=s(i,j);
00100     }
00101   }
00102 
00103   return s;
00104 }