Statistics
| Revision:

root / branches / pthreads-737 / src / linad99 / dcompressed.cpp @ 765

History | View | Annotate | Download (1009 Bytes)

1

    
2
/*
3
 * $Id: dvector.cpp 422 2012-04-12 23:02:36Z johnoel $
4
 *
5
 * Author: David Fournier
6
 * Copyright (c) 2008-2011 Regents of the University of California 
7
 */
8
/**
9
 * \file
10
 * Description not yet available.
11
 */
12
#include "fvar.hpp"
13

    
14
  // this is for a symmetrixc matrix
15
  dvector operator * (const dcompressed_triplet& _M,const dvector& _v)
16
  {
17
    ADUNCONST(dcompressed_triplet,M)
18
    ADUNCONST(dvector,v)
19
    
20
    if (v.indexmin()!=1 ||
21
         M.get_m() !=v.indexmax() )
22
    {
23
      cerr << "Indices do not match in "
24
        " operator * (const dcompressed_triplet& _M,const dvector& _v)"
25
        << endl;
26
      ad_exit(1);
27
    }
28
    imatrix coords= M.get_coords();
29
    dvector x= M.get_x();
30
    dvector tmp(1,v.indexmax());
31
    int mmin=x.indexmin();
32
    int mmax=x.indexmax();
33
    tmp.initialize();
34
    for (int i=mmin;i<=mmax;i++)
35
    {
36
      tmp(coords(1,i))+=x(i)*v(coords(2,i));
37
      if(coords(1,i)!=coords(2,i))
38
        tmp(coords(2,i))+=x(i)*v(coords(1,i));
39
    }
40
     
41
    return tmp;
42
  } 
43