-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComplexMatrixClass.h
136 lines (131 loc) · 3.27 KB
/
ComplexMatrixClass.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#pragma once
#ifndef COMPLEXMATRIXCLASS_H
#define COMPLEXMATRIXCLASS_H
#include "ComplexCoreClass.h"
TemplateDefinition
class ComplexMatrixClass : ComplexCoreClass <TemplateParameter>
{
public:
ComplexMatrixClass()
{
// 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.
}
ComplexMatrixClass(MemoryManagerClass *MemoryManager) : BaseConstructor
{
}
Ts* GetColumn(Ts **A, int RowsCount, int ColumnIndex)
{
if (RowsCount == 0)
return NULL;
Ts * Column = this->AllocMem_Single(RowsCount);
for (int i = 0; i < RowsCount; i++)
{
Column[i] = A[i][ColumnIndex];
}
return Column;
}
Tc* GetColumn(Tc **A, int RowsCount, int ColumnIndex)
{
if (RowsCount == 0)
return NULL;
Tc * Column = this->AllocMem_Complex(RowsCount);
for (int i = 0; i < RowsCount; i++)
{
Column[i] = A[i][ColumnIndex];
}
return Column;
}
void GetColumn_ToOutMem(Ts **A, int RowsCount, int ColumnIndex, Ts* OutA)
{
memset(OutA, 0, sizeof(Ts)*RowsCount);
for (int i = 0; i < RowsCount; i++)
{
OutA[i] = A[i][ColumnIndex];
}
}
void GetColumn_ToOutMem(Tc **A, int RowsCount, int ColumnIndex, Tc* OutA)
{
memset(OutA, 0, sizeof(Tc)*RowsCount);
for (int i = 0; i < RowsCount; i++)
{
OutA[i] = A[i][ColumnIndex];
}
}
Tca GetColumn(Tca2d A, int ColumnIndex)
{
Tca res(this->MemManager);
if (A.RowsCount == 0)
return res;
Tc * Column = this->AllocMem_Complex(A.RowsCount);
for (int i = 0; i < A.RowsCount; i++)
{
Column[i] = A.Rows[i][ColumnIndex];
}
res.SetArray(Column, A.RowsCount);
return res;
}
Ta GetColumn(Ta2d A, int ColumnIndex)
{
Ta res(this->MemManager);
if (A.RowsCount == 0)
return res;
Ts * Column = this->AllocMem_Single(A.RowsCount);
for (int i = 0; i < A.RowsCount; i++)
{
Column[i] = A.Rows[i][ColumnIndex];
}
res.SetArray(Column, A.RowsCount);
return res;
}
Ts* GetRow(Ts **A, int ColumnCount, int RowIndex)
{
if (ColumnCount == 0)
return NULL;
Ts * Row = this->AllocMem_Single(ColumnCount);
for (int i = 0; i < ColumnCount; i++)
{
Row[i] = A[RowIndex][i];
}
return Row;
}
Tc* GetRow(Tc **A, int ColumnCount, int RowIndex)
{
if (ColumnCount == 0)
return NULL;
Tc * Row = this->AllocMem_Complex(ColumnCount);
for (int i = 0; i < ColumnCount; i++)
{
Row[i] = A[RowIndex][i];
}
return Row;
}
Ta GetRow(Ta2d A, int RowIndex)
{
Ta res(this->MemManager);
if (A.Rows[RowIndex].Length == 0)
return res;
Ts * Row = this->AllocMem_Single(A.Rows[RowIndex].Length);
for (int i = 0; i < A.Rows[RowIndex].Length; i++)
{
Row[i] = A.Rows[RowIndex][i];
}
res.SetArray(Row, A.Rows[RowIndex].Length);
return res;
}
Tca GetRow(Tca2d A, int RowIndex)
{
Tca res(this->MemManager);
if (A.Rows[RowIndex].Length == 0)
return res;
Tc * Row = this->AllocMem_Complex(A.Rows[RowIndex].Length);
for (int i = 0; i < A.Rows[RowIndex].Length; i++)
{
Row[i] = A.Rows[RowIndex][i];
}
res.SetArray(Row, A.Rows[RowIndex].Length);
return res;
}
};
#endif