ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat29.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include "fvar.hpp"
12 
17 dvector VEC(const dmatrix& _m)
18  {
19  dmatrix& m= (dmatrix&) _m;
20  int i;
21  int mmin=m.indexmin();
22  int mmax=m.indexmax();
23  int ii=0;
24  ivector io(mmin-1,mmax);
25  io(mmin-1)=0;
26  for (i=mmin;i<=mmax;i++)
27  {
28  ii+=m(i).indexmax()-m(i).indexmin()+1;
29  io(i)=ii;
30  }
31  dvector tmp(1,ii);
32  for (i=mmin;i<=mmax;i++)
33  {
34  tmp(io(i-1)+1,io(i)).shift(m(i).indexmin())=m(i);
35  }
36  return tmp;
37  }
38 
45 dmatrix MAT(const dvector& v, int n, int m)
46  {
47  dmatrix tmp(1,n,1,m);
48  int mmin=v.indexmin();
49  int mmax=v.indexmax();
50  int ii=mmin;
51  if ( mmax-mmin+1 != n*m)
52  {
53  cerr << " Vector and Matrix sizes don't match in function MAT" << endl;
54  tmp.initialize();
55  return tmp;
56  }
57  for (int i=1;i<=n;i++)
58  {
59  for (int j=1;j<=m;j++)
60  {
61  tmp(i,j)=v(ii++);
62  }
63  }
64  return tmp;
65  }
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
int indexmin() const
Definition: fvar.hpp:2917
prnstream & endl(prnstream &)
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
Definition: fvar.hpp:2819
dvector & shift(int min)
Shift valid range of subscripts.
Definition: dvector.cpp:52
dmatrix MAT(const dvector &v, int n, int m)
The MAT operator is the inverse of the VEC operator.
Definition: dmat29.cpp:45
int indexmax() const
Definition: fvar.hpp:2921
dvector VEC(const dmatrix &_m)
The VEC operator concatenates the columns of matrix M into a column vector.
Definition: dmat29.cpp:17
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat7.cpp:12