-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathderivates.h
More file actions
51 lines (37 loc) · 880 Bytes
/
Copy pathderivates.h
File metadata and controls
51 lines (37 loc) · 880 Bytes
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
51
/*
* Created on: June 14, 2013
* Author: Mirko Myllykoski (mirko.myllykoski@gmail.com)
*/
#ifndef AUGLAGL1_DERIVATES_H
#define AUGLAGL1_DERIVATES_H
#include "V.h"
#include "Q.h"
namespace auglagL1 {
template <typename T>
Q<T> grad(const V<T>& v) {
std::size_t n1 = 2*(v.getN1()-1);
std::size_t n2 = v.getN2()-1;
T h = v.getH();
Q<T> tmp(n1, n2, h);
for(std::size_t j = 1; j <= n2; j++)
for(std::size_t i = 1; i <= n1; i++)
tmp(i,j) = v.grad(i,j);
return tmp;
}
template <typename T>
V<T> div(const Q<T> q) {
std::size_t n1 = q.getN1()/2+1;
std::size_t n2 = q.getN2()+1;
T h = q.getH();
V<T> tmp(n1, n2, h);
for(std::size_t i = 0; i < n1; i++)
tmp(i,0) = tmp(i,n2-1) = 0.0;
for(std::size_t j = 1; j < n2-1; j++) {
tmp(0,j) = tmp(0,n2-1) = 0.0;
for(std::size_t i = 1; i < n1-1; i++)
tmp(i,j) = q.div(i,j);
}
return tmp;
}
}
#endif