ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_m52.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_vector solve_trans(const banded_lower_triangular_dvar_matrix& M,
00018   const dvector& y)
00019 {
00020   int mmin=M.indexmin();
00021   int mmax=M.indexmax();
00022   int bw=M.bandwidth();
00023 
00024   if (y.indexmin() !=mmin || y.indexmax() !=mmax)
00025   {
00026     cerr << "incompatible size in solve_trans" << endl;
00027     ad_exit(1);
00028   }
00029   dvar_vector x(mmin,mmax);
00030   int i,j;
00031 
00032   for (i=mmax;i>=mmin;i--)
00033   {
00034     dvariable sum=0.0;
00035     int jmax=admin(mmax,i+bw-1);
00036     for (j=i+1;j<=jmax;j++)
00037     {
00038       sum+=M(j,i)*x(j);
00039     }
00040     x(i)=(y(i)-sum)/M(i,i);
00041   }
00042 
00043   return x;
00044 }