-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModFunction.cs
58 lines (48 loc) · 1.41 KB
/
ModFunction.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
51
52
53
54
55
56
57
58
using System;
using UnityEngine;
using System.Collections.Generic;
namespace YAMP
{
class ModFunction : StandardFunction
{
public override Value Perform(Value argument)
{
if (argument is ScalarValue)
return argument;
else if (argument is MatrixValue)
{
var m = argument as MatrixValue;
if(m.DimensionX == 1)
return GetVectorMod(m.GetColumnVector(1));
else if(m.DimensionY == 1)
return GetVectorMod(m.GetRowVector(1));
else
{
var M = new MatrixValue(1, m.DimensionX);
for(var i = 1; i <= m.DimensionX; i++)
M[1, i] = GetVectorMod(m.GetColumnVector(i));
return M;
}
}
throw new OperationNotSupportedException("mod", argument);
}
ScalarValue GetVectorMod(MatrixValue vec)
{
//Debug.Log(vec.Length+" | "+vec[1].Value);
return new ScalarValue(vec[1].Value%vec[2].Value);
//var buf = new ScalarValue();
//var max = double.NegativeInfinity;
//var temp = 0.0;
//for(var i = 1; i <= vec.Length; i++)
//{
// temp = vec[i].Abs().Value;
// if (temp > max)
// {
// buf = vec[i];
// max = temp;
// }
//}
//return buf;
}
}
}