Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00011 #include <fvar.hpp>
00012
00017 dmatrix symmetrize(const dmatrix& m)
00018 {
00019 if (m.rowmin() != m.colmin() || m.rowmax() != m.colmax() )
00020 {
00021 cerr << " Non square matrix passed to dmatrix symmetrize\n";
00022 ad_exit(1);
00023 }
00024 int rmin=m.rowmin();
00025 int rmax=m.rowmax();
00026
00027 dmatrix s(rmin,rmax,rmin,rmax);
00028 for (int i=rmin;i<=rmax;i++)
00029 {
00030 s(i,i)=m(i,i);
00031
00032 for (int j=rmin;j<i;j++)
00033 {
00034 s(i,j)=(m(i,j)+m(j,i))/2.;
00035 s(j,i)=s(i,j);
00036 }
00037 }
00038 return s;
00039 }