-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComplexSignClass.h
67 lines (64 loc) · 1.28 KB
/
ComplexSignClass.h
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
59
60
61
62
63
64
65
66
67
#pragma once
#ifndef COMPLEXSIGNCLASS_H
#define COMPLEXSIGNCLASS_H
#include "ComplexCoreClass.h"
TemplateDefinition
class ComplexSignClass : ComplexCoreClass <TemplateParameter>
{
public:
ComplexSignClass()
{
// dont call base class default constructor directly, icc has problem with it.
// default constructor of base class automatically called befor constructor of derived class.
// but parametrized constructor of base class should be called explicitly.
}
ComplexSignClass(MemoryManagerClass *MemoryManager) : BaseConstructor
{
}
Ts Sign(Ts A)
{
if (A<0)
{
return -1;
}
else if (A>0)
{
return 1;
}
else
{
return 0;
}
}
Ts * Sign(Ts* A, int ALength)
{
Ts* sign = this->AllocMem_Single(ALength);
for (size_t i = 0; i < ALength; i++)
{
sign[i] = Sign(A[i]);
}
return sign;
}
Ta Sign(Ta A)
{
Ta res(this->MemManager);
if (A.Length <= 0)
return res;
res.SetArray(Sign(A.GetArray(), A.Length), A.Length);
return res;
}
void Sign_inplace(Ts* A, int ALength)
{
// double* sign = AllocDouble(ALength);
for (size_t i = 0; i < ALength; i++)
{
A[i] = Sign(A[i]);
}
//return sign;
}
void Sign_inplace(Ta A)
{
Sign_inplace(A.GetArray(), A.Length);
}
};
#endif