-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionMatrix.cs
50 lines (48 loc) · 1.3 KB
/
FunctionMatrix.cs
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
using System;
using System.Collections.Generic;
using System.Text;
namespace NewtonMD
{
public delegate double func(Vector v);
class FunctionMatrix
{
private func [,] functions = null;
public FunctionMatrix()
{
functions = new func[3, 3];
}
public func this[int row, int col]
{
get {return functions[row, col]; }
set {functions[row,col] = value; }
}
public SquareMatrix Evaluate(Vector v)
{
SquareMatrix tmp = new SquareMatrix();
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
tmp[i, j] = functions[i, j](v);
return tmp;
}
}
class FunctionVector
{
private func[] functions = null;
public FunctionVector()
{
functions = new func[3];
}
public func this[int index]
{
get { return functions[index]; }
set { functions[index] = value; }
}
public Vector Evaluate(Vector v)
{
Vector tmp = new Vector();
for (int i = 0; i < 3; i++)
tmp[i] = functions[i](v);
return tmp;
}
}
}