File: dcmatrxc.h

package info (click to toggle)
arpack%2B%2B 2.1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,216 kB
  • ctags: 2,349
  • sloc: cpp: 19,093; ansic: 2,201; makefile: 508
file content (50 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
   ARPACK++ v1.0 8/1/1997
   c++ interface to ARPACK code.

   MODULE DCMatrxC.h
   Function template for the mass matrix formed by using piecewise 
   linear elements on [0, 1].

   ARPACK Authors
      Richard Lehoucq
      Danny Sorensen
      Chao Yang
      Dept. of Computational & Applied Mathematics
      Rice University
      Houston, Texas
*/

#ifndef DCMATRXC_H
#define DCMATRXC_H

#include "arcomp.h"

template<class FLOAT, class INT>
void CompMatrixC(INT n, arcomplex<FLOAT>* &A)
{

  INT              i, j;
  arcomplex<FLOAT> diag, sub;

  // Defining constants.

  sub  = arcomplex<FLOAT>(1.0/(FLOAT)(n+1), 0.0);
  diag = arcomplex<FLOAT>(4.0/(FLOAT)(n+1), 0.0);

  // Creating output vector A.

  A  = new arcomplex<FLOAT>[n*n];

  for (i=0; i<n*n; i++) A[i] = arcomplex<FLOAT>(0.0, 0.0);

  for (i=0, j=0; i<n; i++, j+=n+1) {
    if (i)      A[j-1]  = sub;
                A[j]    = diag;
    if (n-i-1)  A[j+1]  = sub;
  }

} // CompMatrixC.

#endif // DCMATRXC_H