4
4
using System . Collections . Generic ;
5
5
using System ;
6
6
7
- public class BasicComplexVector : AbstractVector
7
+ public class BasicComplexVector : BasicDouble2Vector
8
8
{
9
+ public BasicComplexVector ( int size ) : this ( DATA_FORM . DF_VECTOR , size ) { }
10
+ public BasicComplexVector ( List < Double2 > list ) : base ( list ) { }
9
11
10
- protected List < Double2 > values ;
12
+ public BasicComplexVector ( Double2 [ ] array ) : base ( array ) { }
13
+ internal BasicComplexVector ( DATA_FORM df , int size ) : base ( df , size ) { }
11
14
12
- public BasicComplexVector ( int size ) : this ( DATA_FORM . DF_VECTOR , size )
13
- {
14
- }
15
-
16
- public BasicComplexVector ( List < Double2 > list ) : base ( DATA_FORM . DF_VECTOR )
17
- {
18
- if ( list != null )
19
- {
20
- values = new List < Double2 > ( ) ;
21
- values . AddRange ( new Double2 [ list . Count ] ) ;
22
- for ( int i = 0 ; i < list . Count ; ++ i )
23
- values [ i ] = list [ i ] ;
24
- }
25
- }
26
-
27
- public BasicComplexVector ( Double2 [ ] array ) : base ( DATA_FORM . DF_VECTOR )
28
- {
29
- values = new List < Double2 > ( ) ;
30
- values . AddRange ( array ) ;
31
- }
32
-
33
- internal BasicComplexVector ( DATA_FORM df , int size ) : base ( df )
34
- {
35
-
36
- values = new List < Double2 > ( ) ;
37
- values . AddRange ( new Double2 [ size ] ) ;
38
- for ( int i = 0 ; i < size ; ++ i )
39
- values [ i ] = new Double2 ( - double . MaxValue , - double . MaxValue ) ;
40
- }
41
-
42
- internal BasicComplexVector ( DATA_FORM df , ExtendedDataInput @in ) : base ( df )
43
- {
44
- int rows = @in . readInt ( ) ;
45
- int cols = @in . readInt ( ) ;
46
- int size = rows * cols ;
47
- values = new List < Double2 > ( ) ;
48
- values . AddRange ( new Double2 [ size ] ) ;
49
- int totalBytes = size * 16 , off = 0 ;
50
- bool littleEndian = @in . isLittleEndian ( ) ;
51
- byte [ ] buffer = buf . Value ;
52
- while ( off < totalBytes )
53
- {
54
- int len = System . Math . Min ( BUF_SIZE , totalBytes - off ) ;
55
- @in . readFully ( buffer , 0 , len ) ;
56
- int start = off / 16 , end = len / 16 ;
57
- Byte [ ] dst = new Byte [ len ] ;
58
- Buffer . BlockCopy ( buffer , 0 , dst , 0 , len ) ;
59
- if ( ! littleEndian )
60
- Array . Reverse ( dst ) ;
61
- if ( littleEndian )
62
- {
63
- for ( int i = 0 ; i < end ; i ++ )
64
- {
65
- double real = BitConverter . ToDouble ( dst , i * 16 ) ;
66
- double image = BitConverter . ToDouble ( dst , i * 16 + 8 ) ;
67
- values [ i + start ] = new Double2 ( real , image ) ;
68
- }
69
- }
70
- else
71
- {
72
- for ( int i = 0 ; i < end ; i ++ )
73
- {
74
- double image = BitConverter . ToDouble ( dst , i * 16 ) ;
75
- double real = BitConverter . ToDouble ( dst , i * 16 + 8 ) ;
76
- values [ i + start ] = new Double2 ( real , image ) ;
77
- }
78
- }
79
- off += len ;
80
- }
81
- }
15
+ internal BasicComplexVector ( DATA_FORM df , ExtendedDataInput @in ) : base ( df , @in ) { }
82
16
83
17
public override IScalar get ( int index )
84
18
{
@@ -100,29 +34,6 @@ public void setComplex(int index, double real, double image)
100
34
values [ index ] = new Double2 ( real , image ) ;
101
35
}
102
36
103
- public Double2 getDouble2 ( int index )
104
- {
105
- return values [ index ] ;
106
- }
107
-
108
- public override bool isNull ( int index )
109
- {
110
- return values [ index ] . isNull ( ) ;
111
- }
112
-
113
-
114
- public override void setNull ( int index )
115
- {
116
- values [ index ] = new Double2 ( - double . MaxValue , - double . MaxValue ) ;
117
- }
118
-
119
-
120
- public override DATA_CATEGORY getDataCategory ( )
121
- {
122
- return DATA_CATEGORY . BINARY ;
123
- }
124
-
125
-
126
37
public override DATA_TYPE getDataType ( )
127
38
{
128
39
return DATA_TYPE . DT_COMPLEX ;
@@ -134,38 +45,6 @@ public override Type getElementClass()
134
45
return typeof ( BasicComplex ) ;
135
46
}
136
47
137
-
138
- public override int rows ( )
139
- {
140
- return values . Count ;
141
- }
142
-
143
- protected internal override void writeVectorToOutputStream ( ExtendedDataOutput @out )
144
- {
145
- @out . writeDouble2Array ( values . ToArray ( ) ) ;
146
- }
147
-
148
- public override void set ( int index , string value )
149
- {
150
- throw new NotImplementedException ( ) ;
151
- }
152
-
153
- public override void add ( object value )
154
- {
155
- throw new NotImplementedException ( ) ;
156
- }
157
-
158
- public override void addRange ( object list )
159
- {
160
- throw new NotImplementedException ( ) ;
161
- }
162
-
163
- public override int hashBucket ( int index , int buckets )
164
- {
165
- return values [ index ] . hashBucket ( buckets ) ;
166
- }
167
-
168
-
169
48
public override IVector getSubVector ( int [ ] indices )
170
49
{
171
50
int length = indices . Length ;
@@ -175,100 +54,6 @@ public override IVector getSubVector(int[] indices)
175
54
return new BasicComplexVector ( sub ) ;
176
55
}
177
56
178
- protected Double2 [ ] getSubArray ( int [ ] indices )
179
- {
180
- int length = indices . Length ;
181
- Double2 [ ] sub = new Double2 [ length ] ;
182
- for ( int i = 0 ; i < length ; ++ i )
183
- sub [ i ] = values [ indices [ i ] ] ;
184
- return sub ;
185
- }
186
-
187
- public override int asof ( IScalar value )
188
- {
189
- throw new Exception ( "BasicComplexVector.asof not supported." ) ;
190
- }
191
-
192
- public override void deserialize ( int start , int count , ExtendedDataInput @in )
193
- {
194
- if ( start + count > values . Count )
195
- {
196
- values . AddRange ( new Double2 [ start + count - values . Count ] ) ;
197
- }
198
- int totalBytes = count * 16 , off = 0 ;
199
- bool littleEndian = @in . isLittleEndian ( ) ;
200
- byte [ ] buffer = buf . Value ;
201
- while ( off < totalBytes )
202
- {
203
- int len = System . Math . Min ( BUF_SIZE , totalBytes - off ) ;
204
- @in . readFully ( buffer , 0 , len ) ;
205
- int subStart = off / 16 , end = len / 16 ;
206
- Byte [ ] dst = new Byte [ len ] ;
207
- Buffer . BlockCopy ( buffer , 0 , dst , 0 , len ) ;
208
- if ( ! littleEndian )
209
- Array . Reverse ( dst ) ;
210
- if ( littleEndian )
211
- {
212
- for ( int i = 0 ; i < end ; i ++ )
213
- {
214
- double real = BitConverter . ToDouble ( dst , i * 16 ) ;
215
- double image = BitConverter . ToDouble ( dst , i * 16 + 8 ) ;
216
- values [ i + subStart + start ] = new Double2 ( real , image ) ;
217
- }
218
- }
219
- else
220
- {
221
- for ( int i = 0 ; i < end ; i ++ )
222
- {
223
- double image = BitConverter . ToDouble ( dst , i * 16 ) ;
224
- double real = BitConverter . ToDouble ( dst , i * 16 + 8 ) ;
225
- values [ i + subStart + start ] = new Double2 ( real , image ) ;
226
- }
227
- }
228
- off += len ;
229
- }
230
- }
231
-
232
- public override void serialize ( int start , int count , ExtendedDataOutput @out )
233
- {
234
- Double2 [ ] buffer = new Double2 [ count ] ;
235
- for ( int i = 0 ; i < count ; ++ i )
236
- {
237
- buffer [ i ] = values [ i + start ] ;
238
- }
239
- @out . writeDouble2Array ( buffer ) ;
240
- }
241
-
242
-
243
- public override int getUnitLength ( )
244
- {
245
- return 16 ;
246
- }
247
-
248
- public override int serialize ( int indexStart , int offect , int targetNumElement , out int numElement , out int partial , ByteBuffer @out )
249
- {
250
- targetNumElement = Math . Min ( ( @out . remain ( ) / getUnitLength ( ) ) , targetNumElement ) ;
251
- if ( @out . isLittleEndian )
252
- {
253
- for ( int i = 0 ; i < targetNumElement ; ++ i )
254
- {
255
- @out . WriteDouble ( values [ indexStart + i ] . x ) ;
256
- @out . WriteDouble ( values [ indexStart + i ] . y ) ;
257
- }
258
- }
259
- else
260
- {
261
- for ( int i = 0 ; i < targetNumElement ; ++ i )
262
- {
263
- @out . WriteDouble ( values [ indexStart + i ] . y ) ;
264
- @out . WriteDouble ( values [ indexStart + i ] . x ) ;
265
- }
266
- }
267
- numElement = targetNumElement ;
268
- partial = 0 ;
269
- return targetNumElement * 16 ;
270
- }
271
-
272
57
public override void append ( IScalar value )
273
58
{
274
59
values . Add ( ( ( BasicComplex ) value ) . getValue ( ) ) ;
@@ -278,14 +63,4 @@ public override void append(IVector value)
278
63
{
279
64
values . AddRange ( ( ( BasicComplexVector ) value ) . getDataArray ( ) ) ;
280
65
}
281
-
282
- public List < Double2 > getDataArray ( )
283
- {
284
- return values ;
285
- }
286
-
287
- public override IEntity getEntity ( int index )
288
- {
289
- return get ( index ) ;
290
- }
291
66
}
0 commit comments