20 #ifndef SELDON_FILE_MATRIX_COMPLEX_CONVERSIONS_CXX
23 #include "Matrix_ComplexConversions.hxx"
34 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
35 class Tint,
class Allocator3,
class Allocator4>
44 typedef typename ClassComplexType<T>::Treal Treal;
46 long nnz = A.GetRealDataSize() + A.GetImagDataSize();
48 IndRow.Reallocate(nnz);
49 IndCol.Reallocate(nnz);
52 long* real_ptr = A.GetRealPtr();
53 long* imag_ptr = A.GetImagPtr();
54 int* real_ind = A.GetRealInd();
55 int* imag_ind = A.GetImagInd();
56 Treal* real_data = A.GetRealData();
57 Treal* imag_data = A.GetImagData();
58 for (
int i = 0; i < m; i++)
61 long num_i = imag_ptr[i];
62 for (
long j = real_ptr[i]; j < real_ptr[i+1]; j++)
64 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
67 IndCol(nnz) = imag_ind[num_i] + index;
68 Val(nnz) = T(0, imag_data[num_i]);
72 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
75 IndCol(nnz) = real_ind[j] + index;
76 Val(nnz) = T(real_data[j], imag_data[num_i]);
82 IndCol(nnz) = real_ind[j] + index;
83 Val(nnz) = T(real_data[j], 0);
89 for (
long j = num_i; j < imag_ptr[i+1]; j++)
91 IndCol(nnz) = imag_ind[j] + index;
92 Val(nnz) = T(0, imag_data[j]);
97 for (
long j = num_old; j < nnz; j++)
98 IndRow(j) = index + i;
108 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
109 class Tint,
class Allocator3,
class Allocator4>
118 typedef typename ClassComplexType<T>::Treal Treal;
120 long nnz = A.GetRealDataSize() + A.GetImagDataSize();
122 IndRow.Reallocate(nnz);
123 IndCol.Reallocate(nnz);
126 long* real_ptr = A.GetRealPtr();
127 long* imag_ptr = A.GetImagPtr();
128 int* real_ind = A.GetRealInd();
129 int* imag_ind = A.GetImagInd();
130 Treal* real_data = A.GetRealData();
131 Treal* imag_data = A.GetImagData();
132 for (
int i = 0; i < n; i++)
135 long num_i = imag_ptr[i];
136 for (
long j = real_ptr[i]; j < real_ptr[i+1]; j++)
138 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
141 IndRow(nnz) = imag_ind[num_i] + index;
142 Val(nnz) = T(0, imag_data[num_i]);
146 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
149 IndRow(nnz) = real_ind[j] + index;
150 Val(nnz) = T(real_data[j], imag_data[num_i]);
156 IndRow(nnz) = real_ind[j] + index;
157 Val(nnz) = T(real_data[j], 0);
163 for (
long j = num_i; j < imag_ptr[i+1]; j++)
165 IndRow(nnz) = imag_ind[j] + index;
166 Val(nnz) = T(0, imag_data[j]);
171 for (
long j = num_old; j < nnz; j++)
172 IndCol(j) = index + i;
182 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
183 class Tint,
class Allocator3,
class Allocator4>
192 typedef typename ClassComplexType<T>::Treal Treal;
194 long nnz = A.GetDataSize();
195 long* real_ptr = A.GetRealPtr();
196 long* imag_ptr = A.GetImagPtr();
197 int* real_ind = A.GetRealInd();
198 int* imag_ind = A.GetImagInd();
199 Treal* real_data = A.GetRealData();
200 Treal* imag_data = A.GetImagData();
212 for (
int i = 0; i < m; i++)
214 long num_i = imag_ptr[i], nnz_old = nnz;
215 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
217 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
220 if (imag_ind[num_i] != i)
221 NumNnzRow(imag_ind[num_i])++;
227 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
230 if (real_ind[j] != i)
231 NumNnzRow(real_ind[j])++;
238 if (real_ind[j] != i)
239 NumNnzRow(real_ind[j])++;
246 nnz += imag_ptr[i+1] - num_i;
247 for (
long j = num_i; j < imag_ptr[i+1]; j++)
248 if (imag_ind[j] != i)
249 NumNnzRow(imag_ind[j])++;
251 PtrLower(i+1) = PtrLower(i) + NumNnzRow(i) + nnz - nnz_old;
253 PtrUpper(i+1) = PtrLower(i+1) + NumNnzRow(i+1);
261 IndRow.Reallocate(nnz);
262 IndCol.Reallocate(nnz);
264 for (
int i = 0; i < m; i++)
266 long num_i = imag_ptr[i];
int jcol = 0;
267 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
269 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
271 jcol = imag_ind[num_i];
275 IndRow(PtrLower(jcol)) = jcol + index;
276 IndCol(PtrLower(jcol)) = i + index;
277 Val(PtrLower(jcol)) = T(0, imag_data[num_i]);
281 IndRow(PtrUpper(i)) = i + index;
282 IndCol(PtrUpper(i)) = jcol + index;
283 Val(PtrUpper(i)) = T(0, imag_data[num_i]);
289 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
293 if (real_ind[j] != i)
295 IndRow(PtrLower(jcol)) = jcol + index;
296 IndCol(PtrLower(jcol)) = i + index;
297 Val(PtrLower(jcol)) = T(real_data[j], imag_data[num_i]);
301 IndRow(PtrUpper(i)) = i + index;
302 IndCol(PtrUpper(i)) = jcol + index;
303 Val(PtrUpper(i)) = T(real_data[j], imag_data[num_i]);
311 if (real_ind[j] != i)
313 IndRow(PtrLower(jcol)) = jcol + index;
314 IndCol(PtrLower(jcol)) = i + index;
315 Val(PtrLower(jcol)) = T(real_data[j], 0);
319 IndRow(PtrUpper(i)) = i + index;
320 IndCol(PtrUpper(i)) = jcol + index;
321 Val(PtrUpper(i)) = T(real_data[j], 0);
327 for (
long j = num_i; j < imag_ptr[i+1]; j++)
330 if (imag_ind[j] != i)
332 IndRow(PtrLower(jcol)) = jcol + index;
333 IndCol(PtrLower(jcol)) = i + index;
334 Val(PtrLower(jcol)) = T(0, imag_data[j]);
338 IndRow(PtrUpper(i)) = i + index;
339 IndCol(PtrUpper(i)) = jcol + index;
340 Val(PtrUpper(i)) = T(0, imag_data[j]);
348 IndRow.Reallocate(nnz);
349 IndCol.Reallocate(nnz);
352 for (
int i = 0; i < m; i++)
355 long num_i = imag_ptr[i];
356 for (
long j = real_ptr[i]; j < real_ptr[i+1]; j++)
358 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
361 IndCol(nnz) = imag_ind[num_i] + index;
362 Val(nnz) = T(0, imag_data[num_i]);
366 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
369 IndCol(nnz) = real_ind[j] + index;
370 Val(nnz) = T(real_data[j], imag_data[num_i]);
376 IndCol(nnz) = real_ind[j] + index;
377 Val(nnz) = T(real_data[j], 0);
383 for (
long j = num_i; j < imag_ptr[i+1]; j++)
385 IndCol(nnz) = imag_ind[j] + index;
386 Val(nnz) = T(0, imag_data[j]);
391 for (
long j = num_old; j < nnz; j++)
392 IndRow(j) = index + i;
403 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
404 class Tint,
class Allocator3,
class Allocator4>
413 typedef typename ClassComplexType<T>::Treal Treal;
415 long nnz = A.GetDataSize();
416 long* real_ptr = A.GetRealPtr();
417 long* imag_ptr = A.GetImagPtr();
418 int* real_ind = A.GetRealInd();
419 int* imag_ind = A.GetImagInd();
420 Treal* real_data = A.GetRealData();
421 Treal* imag_data = A.GetImagData();
431 for (
int i = 0; i < m; i++)
433 long num_i = imag_ptr[i], nnz_old = nnz;
434 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
436 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
439 if (imag_ind[num_i] != i)
440 NumNnzCol(imag_ind[num_i])++;
445 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
448 if (real_ind[j] != i)
449 NumNnzCol(real_ind[j])++;
456 if (real_ind[j] != i)
457 NumNnzCol(real_ind[j])++;
464 nnz += imag_ptr[i+1] - num_i;
465 for (
long j = num_i; j < imag_ptr[i+1]; j++)
466 if (imag_ind[j] != i)
467 NumNnzCol(imag_ind[j])++;
469 PtrUpper(i+1) = nnz - nnz_old;
474 PtrLower(0) = PtrUpper(1);
475 for (
int i = 0; i < m; i++)
477 long ncol_upper = PtrUpper(i+1);
478 int ncol_lower = NumNnzCol(i);
480 PtrUpper(i+1) = PtrUpper(i) + ncol_upper + ncol_lower;
482 PtrLower(i+1) = PtrUpper(i+1) + PtrUpper(i+2);
490 IndRow.Reallocate(nnz);
491 IndCol.Reallocate(nnz);
493 for (
int i = 0; i < m; i++)
495 long num_i = imag_ptr[i];
int jrow = 0;
496 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
498 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
500 jrow = imag_ind[num_i];
504 IndRow(PtrLower(jrow)) = i + index;
505 IndCol(PtrLower(jrow)) = jrow + index;
506 Val(PtrLower(jrow)) = T(0, imag_data[num_i]);
510 IndRow(PtrUpper(i)) = jrow + index;
511 IndCol(PtrUpper(i)) = i + index;
512 Val(PtrUpper(i)) = T(0, imag_data[num_i]);
518 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
522 if (real_ind[j] != i)
524 IndRow(PtrLower(jrow)) = i + index;
525 IndCol(PtrLower(jrow)) = jrow + index;
526 Val(PtrLower(jrow)) = T(real_data[j], imag_data[num_i]);
530 IndRow(PtrUpper(i)) = jrow + index;
531 IndCol(PtrUpper(i)) = i + index;
532 Val(PtrUpper(i)) = T(real_data[j], imag_data[num_i]);
540 if (real_ind[j] != i)
542 IndRow(PtrLower(jrow)) = i + index;
543 IndCol(PtrLower(jrow)) = jrow + index;
544 Val(PtrLower(jrow)) = T(real_data[j], 0);
548 IndRow(PtrUpper(i)) = jrow + index;
549 IndCol(PtrUpper(i)) = i + index;
550 Val(PtrUpper(i)) = T(real_data[j], 0);
556 for (
long j = num_i; j < imag_ptr[i+1]; j++)
559 if (imag_ind[j] != i)
561 IndRow(PtrLower(jrow)) = i + index;
562 IndCol(PtrLower(jrow)) = jrow + index;
563 Val(PtrLower(jrow)) = T(0, imag_data[j]);
567 IndRow(PtrUpper(i)) = jrow + index;
568 IndCol(PtrUpper(i)) = i + index;
569 Val(PtrUpper(i)) = T(0, imag_data[j]);
577 IndRow.Reallocate(nnz);
578 IndCol.Reallocate(nnz);
582 for (
int i = 0; i < m; i++)
585 long num_i = imag_ptr[i];
586 for (
long j = real_ptr[i]; j < real_ptr[i+1]; j++)
588 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
591 IndRow(nnz) = imag_ind[num_i] + index;
592 Val(nnz) = T(0, imag_data[num_i]);
596 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
599 IndRow(nnz) = real_ind[j] + index;
600 Val(nnz) = T(real_data[j], imag_data[num_i]);
606 IndRow(nnz) = real_ind[j] + index;
607 Val(nnz) = T(real_data[j], 0);
613 for (
long j = num_i; j < imag_ptr[i+1]; j++)
615 IndRow(nnz) = imag_ind[j] + index;
616 Val(nnz) = T(0, imag_data[j]);
621 for (
long j = num_old; j < nnz; j++)
622 IndCol(j) = index + i;
633 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
634 class Tint,
class Allocator3,
class Allocator4>
644 long nnz = A.GetRealDataSize() + A.GetImagDataSize();
646 IndRow.Reallocate(nnz);
647 IndCol.Reallocate(nnz);
650 for (
int i = 0; i < m; i++)
653 int num_i = 0, size_imag = A.GetImagRowSize(i);
654 for (
int j = 0; j < A.GetRealRowSize(i); j++)
656 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
659 IndCol(nnz) = A.IndexImag(i, num_i) + index;
660 Val(nnz) = T(0, A.ValueImag(i, num_i));
664 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
667 IndCol(nnz) = A.IndexReal(i, j) + index;
668 Val(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
674 IndCol(nnz) = A.IndexReal(i, j) + index;
675 Val(nnz) = T(A.ValueReal(i, j), 0);
680 for (
int j = num_i; j < size_imag; j++)
682 IndCol(nnz) = A.IndexImag(i, j) + index;
683 Val(nnz) = T(0, A.ValueImag(i, j));
688 for (
long j = num_old; j < nnz; j++)
689 IndRow(j) = i + index;
699 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
700 class Tint,
class Allocator3,
class Allocator4>
709 long nnz = A.GetRealDataSize() + A.GetImagDataSize();
711 IndRow.Reallocate(nnz);
712 IndCol.Reallocate(nnz);
715 for (
int i = 0; i < A.GetN(); i++)
718 int num_i = 0, size_imag = A.GetImagColumnSize(i);
719 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
721 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
724 IndRow(nnz) = A.IndexImag(i, num_i) + index;
725 Val(nnz) = T(0, A.ValueImag(i, num_i));
729 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
732 IndRow(nnz) = A.IndexReal(i, j) + index;
733 Val(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
739 IndRow(nnz) = A.IndexReal(i, j) + index;
740 Val(nnz) = T(A.ValueReal(i, j), 0);
745 for (
int j = num_i; j < size_imag; j++)
747 IndRow(nnz) = A.IndexImag(i, j) + index;
748 Val(nnz) = T(0, A.ValueImag(i, j));
753 for (
long j = num_old; j < nnz; j++)
754 IndCol(j) = i + index;
764 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
765 class Tint,
class Allocator3,
class Allocator4>
775 long nnz = A.GetDataSize();
787 for (
int i = 0; i < m; i++)
789 int num_i = 0;
long nnz_old = nnz;
790 int size_imag = A.GetImagRowSize(i);
791 for (
int j = 0; j < A.GetRealRowSize(i); j++)
793 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
796 if (A.IndexImag(i, num_i) != i)
797 NumNnzRow(A.IndexImag(i, num_i))++;
802 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
805 if (A.IndexReal(i, j) != i)
806 NumNnzRow(A.IndexReal(i, j))++;
813 if (A.IndexReal(i, j) != i)
814 NumNnzRow(A.IndexReal(i, j))++;
821 nnz += (size_imag-num_i);
822 for (
int j = num_i; j < size_imag; j++)
823 if (A.IndexImag(i, j) != i)
824 NumNnzRow(A.IndexImag(i, j))++;
826 PtrLower(i+1) = PtrLower(i) + NumNnzRow(i) + nnz - nnz_old;
828 PtrUpper(i+1) = PtrLower(i+1) + NumNnzRow(i+1);
836 IndRow.Reallocate(nnz);
837 IndCol.Reallocate(nnz);
839 for (
int i = 0; i < m; i++)
841 int num_i = 0, jcol = 0;
842 int size_imag = A.GetImagRowSize(i);
843 for (
int j = 0; j < A.GetRealRowSize(i); j++)
845 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
847 jcol = A.IndexImag(i, num_i);
851 IndRow(PtrLower(jcol)) = jcol + index;
852 IndCol(PtrLower(jcol)) = i + index;
853 Val(PtrLower(jcol)) = T(0, A.ValueImag(i, num_i));
857 IndRow(PtrUpper(i)) = i + index;
858 IndCol(PtrUpper(i)) = jcol + index;
859 Val(PtrUpper(i)) = T(0, A.ValueImag(i, num_i));
865 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
867 jcol = A.IndexReal(i, j);
871 IndRow(PtrLower(jcol)) = jcol + index;
872 IndCol(PtrLower(jcol)) = i + index;
873 Val(PtrLower(jcol)) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
877 IndRow(PtrUpper(i)) = i + index;
878 IndCol(PtrUpper(i)) = jcol + index;
879 Val(PtrUpper(i)) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
885 jcol = A.IndexReal(i, j);
889 IndRow(PtrLower(jcol)) = jcol + index;
890 IndCol(PtrLower(jcol)) = i + index;
891 Val(PtrLower(jcol)) = T(A.ValueReal(i, j), 0);
895 IndRow(PtrUpper(i)) = i + index;
896 IndCol(PtrUpper(i)) = jcol + index;
897 Val(PtrUpper(i)) = T(A.ValueReal(i, j), 0);
903 for (
int j = num_i; j < size_imag; j++)
905 jcol = A.IndexImag(i, j);
908 IndRow(PtrLower(jcol)) = jcol + index;
909 IndCol(PtrLower(jcol)) = i + index;
910 Val(PtrLower(jcol)) = T(0, A.ValueImag(i, j));
914 IndRow(PtrUpper(i)) = i + index;
915 IndCol(PtrUpper(i)) = jcol + index;
916 Val(PtrUpper(i)) = T(0, A.ValueImag(i, j));
924 IndRow.Reallocate(nnz);
925 IndCol.Reallocate(nnz);
928 for (
int i = 0; i < m; i++)
931 int num_i = 0, size_imag = A.GetImagRowSize(i);
932 for (
int j = 0; j < A.GetRealRowSize(i); j++)
934 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
937 IndCol(nnz) = A.IndexImag(i, num_i) + index;
938 Val(nnz) = T(0, A.ValueImag(i, num_i));
942 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
945 IndCol(nnz) = A.IndexReal(i, j) + index;
946 Val(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
952 IndCol(nnz) = A.IndexReal(i, j) + index;
953 Val(nnz) = T(A.ValueReal(i, j), 0);
959 for (
int j = num_i; j < size_imag; j++)
961 IndCol(nnz) = A.IndexImag(i, j) + index;
962 Val(nnz) = T(0, A.ValueImag(i, j));
967 for (
long j = num_old; j < nnz; j++)
968 IndRow(j) = index + i;
979 template<
class T,
class Prop,
class Allocator1,
class Allocator2,
980 class Tint,
class Allocator3,
class Allocator4>
990 long nnz = A.GetDataSize();
1000 for (
int i = 0; i < m; i++)
1002 int num_i = 0;
long nnz_old = nnz;
1003 int size_imag = A.GetImagColumnSize(i);
1004 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
1006 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
1009 if (A.IndexImag(i, num_i) != i)
1010 NumNnzCol(A.IndexImag(i, num_i))++;
1015 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
1018 if (A.IndexReal(i, j) != i)
1019 NumNnzCol(A.IndexReal(i, j))++;
1026 if (A.IndexReal(i, j) != i)
1027 NumNnzCol(A.IndexReal(i, j))++;
1034 nnz += size_imag - num_i;
1035 for (
int j = num_i; j < size_imag; j++)
1036 if (A.IndexImag(i, j) != i)
1037 NumNnzCol(A.IndexImag(i, j))++;
1039 PtrUpper(i+1) = nnz - nnz_old;
1044 PtrLower(0) = PtrUpper(1);
1045 for (
int i = 0; i < m; i++)
1047 long ncol_upper = PtrUpper(i+1);
1048 int ncol_lower = NumNnzCol(i);
1050 PtrUpper(i+1) = PtrUpper(i) + ncol_upper + ncol_lower;
1052 PtrLower(i+1) = PtrUpper(i+1) + PtrUpper(i+2);
1060 IndRow.Reallocate(nnz);
1061 IndCol.Reallocate(nnz);
1062 Val.Reallocate(nnz);
1063 for (
int i = 0; i < m; i++)
1065 int num_i = 0, jrow = 0;
1066 int size_imag = A.GetImagColumnSize(i);
1067 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
1069 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
1071 jrow = A.IndexImag(i, num_i);
1075 IndRow(PtrLower(jrow)) = i + index;
1076 IndCol(PtrLower(jrow)) = jrow + index;
1077 Val(PtrLower(jrow)) = T(0, A.ValueImag(i, num_i));
1081 IndRow(PtrUpper(i)) = jrow + index;
1082 IndCol(PtrUpper(i)) = i + index;
1083 Val(PtrUpper(i)) = T(0, A.ValueImag(i, num_i));
1088 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
1090 jrow = A.IndexReal(i, j);
1094 IndRow(PtrLower(jrow)) = i + index;
1095 IndCol(PtrLower(jrow)) = jrow + index;
1096 Val(PtrLower(jrow)) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
1100 IndRow(PtrUpper(i)) = jrow + index;
1101 IndCol(PtrUpper(i)) = i + index;
1102 Val(PtrUpper(i)) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
1108 jrow = A.IndexReal(i, j);
1112 IndRow(PtrLower(jrow)) = i + index;
1113 IndCol(PtrLower(jrow)) = jrow + index;
1114 Val(PtrLower(jrow)) = T(A.ValueReal(i, j), 0);
1118 IndRow(PtrUpper(i)) = jrow + index;
1119 IndCol(PtrUpper(i)) = i + index;
1120 Val(PtrUpper(i)) = T(A.ValueReal(i, j), 0);
1126 for (
int j = num_i; j < size_imag; j++)
1128 jrow = A.IndexImag(i, j);
1131 IndRow(PtrLower(jrow)) = i + index;
1132 IndCol(PtrLower(jrow)) = jrow + index;
1133 Val(PtrLower(jrow)) = T(0, A.ValueImag(i, j));
1137 IndRow(PtrUpper(i)) = jrow + index;
1138 IndCol(PtrUpper(i)) = i + index;
1139 Val(PtrUpper(i)) = T(0, A.ValueImag(i, j));
1147 IndRow.Reallocate(nnz);
1148 IndCol.Reallocate(nnz);
1149 Val.Reallocate(nnz);
1152 for (
int i = 0; i < m; i++)
1155 int num_i = 0, size_imag = A.GetImagColumnSize(i);
1156 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
1158 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
1161 IndRow(nnz) = A.IndexImag(i, num_i) + index;
1162 Val(nnz) = T(0, A.ValueImag(i, num_i));
1166 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
1169 IndRow(nnz) = A.IndexReal(i, j) + index;
1170 Val(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
1176 IndRow(nnz) = A.IndexReal(i, j) + index;
1177 Val(nnz) = T(A.ValueReal(i, j), 0);
1182 for (
int j = num_i; j < size_imag; j++)
1184 IndRow(nnz) = A.IndexImag(i, j) + index;
1185 Val(nnz) = T(0, A.ValueImag(i, j));
1190 for (
long j = num_old; j < nnz; j++)
1191 IndCol(j) = i + index;
1202 template<
class T,
class Prop,
class Allocator1,
1203 class Allocator2,
class Allocator3,
class Allocator4>
1209 Allocator4>& A,
int index)
1211 typedef typename ClassComplexType<T>::Treal Treal;
1215 int row_max = IndRow.GetNormInf() - index;
1216 int col_max = IndCol.GetNormInf() - index;
1217 int m = row_max + 1;
1218 int n = col_max + 1;
1221 m = max(m, A.GetM());
1222 n = max(n, A.GetN());
1226 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1228 for (
long i = 0; i < IndRow.GetM(); i++)
1230 int irow = IndRow(i) - index;
1231 if (real(Val(i)) != zero)
1232 NumRealNnzRow(irow)++;
1234 if (imag(Val(i)) != zero)
1235 NumImagNnzRow(irow)++;
1240 PtrReal(0) = 0; PtrImag(0) = 0;
1241 for (
int i = 0; i < m; i++)
1243 PtrReal(i+1) = PtrReal(i) + NumRealNnzRow(i);
1244 PtrImag(i+1) = PtrImag(i) + NumImagNnzRow(i);
1247 long real_nz = PtrReal(m), imag_nz = PtrImag(m);
1252 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1253 for (
long i = 0; i < IndRow.GetM(); i++)
1255 int irow = IndRow(i) - index;
1256 int icol = IndCol(i) - index;
1257 if (real(Val(i)) != zero)
1259 long num_r = PtrReal(irow) + NumRealNnzRow(irow);
1260 IndReal(num_r) = icol;
1261 ValReal(num_r) = real(Val(i));
1262 NumRealNnzRow(irow)++;
1265 if (imag(Val(i)) != zero)
1267 long num_i = PtrImag(irow) + NumImagNnzRow(irow);
1268 IndImag(num_i) = icol;
1269 ValImag(num_i) = imag(Val(i));
1270 NumImagNnzRow(irow)++;
1275 for (
int i = 0; i < m; i++)
1277 Sort(PtrReal(i), PtrReal(i+1)-1, IndReal, ValReal);
1278 Sort(PtrImag(i), PtrImag(i+1)-1, IndImag, ValImag);
1282 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
1287 template<
class T,
class Prop,
class Allocator1,
1288 class Allocator2,
class Allocator3,
class Allocator4>
1294 Allocator4>& A,
int index)
1296 typedef typename ClassComplexType<T>::Treal Treal;
1300 int row_max = IndRow.GetNormInf() - index;
1301 int col_max = IndCol.GetNormInf() - index;
1302 int m = row_max + 1;
1303 int n = col_max + 1;
1306 m = max(m, A.GetM());
1307 n = max(n, A.GetN());
1311 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1313 for (
long i = 0; i < IndCol.GetM(); i++)
1315 int irow = IndCol(i) - index;
1316 if (real(Val(i)) != zero)
1317 NumRealNnzCol(irow)++;
1319 if (imag(Val(i)) != zero)
1320 NumImagNnzCol(irow)++;
1325 PtrReal(0) = 0; PtrImag(0) = 0;
1326 for (
int i = 0; i < n; i++)
1328 PtrReal(i+1) = PtrReal(i) + NumRealNnzCol(i);
1329 PtrImag(i+1) = PtrImag(i) + NumImagNnzCol(i);
1332 long real_nz = PtrReal(n), imag_nz = PtrImag(n);
1337 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1338 for (
long i = 0; i < IndCol.GetM(); i++)
1340 int irow = IndRow(i) - index;
1341 int icol = IndCol(i) - index;
1342 if (real(Val(i)) != zero)
1344 long num_r = PtrReal(icol) + NumRealNnzCol(icol);
1345 IndReal(num_r) = irow;
1346 ValReal(num_r) = real(Val(i));
1347 NumRealNnzCol(icol)++;
1350 if (imag(Val(i)) != zero)
1352 long num_i = PtrImag(icol) + NumImagNnzCol(icol);
1353 IndImag(num_i) = irow;
1354 ValImag(num_i) = imag(Val(i));
1355 NumImagNnzCol(icol)++;
1360 for (
int i = 0; i < n; i++)
1362 Sort(PtrReal(i), PtrReal(i+1)-1, IndReal, ValReal);
1363 Sort(PtrImag(i), PtrImag(i+1)-1, IndImag, ValImag);
1367 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
1372 template<
class T,
class Prop,
class Allocator1,
1373 class Allocator2,
class Allocator3,
class Allocator4>
1379 Allocator4>& A,
int index)
1381 typedef typename ClassComplexType<T>::Treal Treal;
1385 int row_max = IndRow.GetNormInf();
1386 int col_max = IndCol.GetNormInf();
1387 int m = row_max - index + 1;
1388 int n = col_max - index + 1;
1391 m = max(m, A.GetM());
1392 n = max(n, A.GetN());
1396 PtrReal.Zero(); PtrImag.Zero();
1397 for (
long i = 0; i < IndRow.GetM(); i++)
1399 int irow = IndRow(i) - index;
1400 int icol = IndCol(i) - index;
1404 if (real(Val(i)) != zero)
1407 if (imag(Val(i)) != zero)
1413 for (
int i = 0; i < m; i++)
1415 PtrReal(i+1) += PtrReal(i);
1416 PtrImag(i+1) += PtrImag(i);
1419 long real_nz = PtrReal(m), imag_nz = PtrImag(m);
1422 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1427 for (
long i = 0; i < IndRow.GetM(); i++)
1429 int irow = IndRow(i) - index;
1430 int icol = IndCol(i) - index;
1433 if (real(Val(i)) != zero)
1435 long num_r = PtrReal(irow) + NumRealNnzRow(irow);
1436 IndReal(num_r) = icol;
1437 ValReal(num_r) = real(Val(i));
1438 NumRealNnzRow(irow)++;
1441 if (imag(Val(i)) != zero)
1443 long num_i = PtrImag(irow) + NumImagNnzRow(irow);
1444 IndImag(num_i) = icol;
1445 ValImag(num_i) = imag(Val(i));
1446 NumImagNnzRow(irow)++;
1452 for (
int i = 0; i < m; i++)
1454 Sort(PtrReal(i), PtrReal(i+1)-1, IndReal, ValReal);
1455 Sort(PtrImag(i), PtrImag(i+1)-1, IndImag, ValImag);
1459 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
1464 template<
class T,
class Prop,
class Allocator1,
1465 class Allocator2,
class Allocator3,
class Allocator4>
1471 Allocator4>& A,
int index)
1473 typedef typename ClassComplexType<T>::Treal Treal;
1477 int row_max = IndRow.GetNormInf();
1478 int col_max = IndCol.GetNormInf();
1479 int m = row_max - index + 1;
1480 int n = col_max - index + 1;
1483 m = max(m, A.GetM());
1484 n = max(n, A.GetN());
1488 PtrReal.Zero(); PtrImag.Zero();
1489 for (
long i = 0; i < IndCol.GetM(); i++)
1491 int irow = IndRow(i) - index;
1492 int icol = IndCol(i) - index;
1496 if (real(Val(i)) != zero)
1497 PtrReal(icol + 1)++;
1499 if (imag(Val(i)) != zero)
1500 PtrImag(icol + 1)++;
1505 for (
int i = 0; i < n; i++)
1507 PtrReal(i+1) += PtrReal(i);
1508 PtrImag(i+1) += PtrImag(i);
1511 long real_nz = PtrReal(n), imag_nz = PtrImag(n);
1514 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1519 for (
long i = 0; i < IndCol.GetM(); i++)
1521 int irow = IndRow(i) - index;
1522 int icol = IndCol(i) - index;
1525 if (real(Val(i)) != zero)
1527 long num_r = PtrReal(icol) + NumRealNnzCol(icol);
1528 IndReal(num_r) = irow;
1529 ValReal(num_r) = real(Val(i));
1530 NumRealNnzCol(icol)++;
1533 if (imag(Val(i)) != zero)
1535 long num_i = PtrImag(icol) + NumImagNnzCol(icol);
1536 IndImag(num_i) = irow;
1537 ValImag(num_i) = imag(Val(i));
1538 NumImagNnzCol(icol)++;
1544 for (
int i = 0; i < n; i++)
1546 Sort(PtrReal(i), PtrReal(i+1)-1, IndReal, ValReal);
1547 Sort(PtrImag(i), PtrImag(i+1)-1, IndImag, ValImag);
1551 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
1556 template<
class T,
class Prop,
class Allocator1,
1557 class Allocator2,
class Allocator3,
class Allocator4>
1563 Allocator4>& A,
int index)
1565 typedef typename ClassComplexType<T>::Treal Treal;
1569 int row_max = IndRow.GetNormInf();
1570 int col_max = IndCol.GetNormInf();
1571 int m = row_max - index + 1;
1572 int n = col_max - index + 1;
1575 m = max(m, A.GetM());
1576 n = max(n, A.GetN());
1580 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1582 for (
long i = 0; i < IndRow.GetM(); i++)
1584 int irow = IndRow(i) - index;
1585 if (real(Val(i)) != zero)
1586 NumRealNnzRow(irow)++;
1588 if (imag(Val(i)) != zero)
1589 NumImagNnzRow(irow)++;
1594 for (
int i = 0; i < m; i++)
1596 if (NumRealNnzRow(i) > 0)
1597 A.ReallocateRealRow(i, NumRealNnzRow(i));
1599 if (NumImagNnzRow(i) > 0)
1600 A.ReallocateImagRow(i, NumImagNnzRow(i));
1604 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1605 for (
long i = 0; i < IndRow.GetM(); i++)
1607 int irow = IndRow(i) - index;
1608 int icol = IndCol(i) - index;
1609 if (real(Val(i)) != zero)
1611 int num = NumRealNnzRow(irow);
1612 A.IndexReal(irow, num) = icol;
1613 A.ValueReal(irow, num) = real(Val(i));
1614 NumRealNnzRow(irow)++;
1617 if (imag(Val(i)) != zero)
1619 int num = NumImagNnzRow(irow);
1620 A.IndexImag(irow, num) = icol;
1621 A.ValueImag(irow, num) = imag(Val(i));
1622 NumImagNnzRow(irow)++;
1632 template<
class T,
class Prop,
class Allocator1,
1633 class Allocator2,
class Allocator3,
class Allocator4>
1639 Allocator4>& A,
int index)
1641 typedef typename ClassComplexType<T>::Treal Treal;
1645 int row_max = IndRow.GetNormInf();
1646 int col_max = IndCol.GetNormInf();
1647 int m = row_max - index + 1;
1648 int n = col_max - index + 1;
1651 m = max(m, A.GetM());
1652 n = max(n, A.GetN());
1656 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1658 for (
long i = 0; i < IndCol.GetM(); i++)
1660 int icol = IndCol(i) - index;
1661 if (real(Val(i)) != zero)
1662 NumRealNnzCol(icol)++;
1664 if (imag(Val(i)) != zero)
1665 NumImagNnzCol(icol)++;
1670 for (
int i = 0; i < n; i++)
1672 if (NumRealNnzCol(i) > 0)
1673 A.ReallocateRealColumn(i, NumRealNnzCol(i));
1675 if (NumImagNnzCol(i) > 0)
1676 A.ReallocateImagColumn(i, NumImagNnzCol(i));
1680 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1681 for (
long i = 0; i < IndRow.GetM(); i++)
1683 int irow = IndRow(i) - index;
1684 int icol = IndCol(i) - index;
1685 if (real(Val(i)) != zero)
1687 int num = NumRealNnzCol(icol);
1688 A.IndexReal(icol, num) = irow;
1689 A.ValueReal(icol, num) = real(Val(i));
1690 NumRealNnzCol(icol)++;
1693 if (imag(Val(i)) != zero)
1695 int num = NumImagNnzCol(icol);
1696 A.IndexImag(icol, num) = irow;
1697 A.ValueImag(icol, num) = imag(Val(i));
1698 NumImagNnzCol(icol)++;
1708 template<
class T,
class Prop,
class Allocator1,
1709 class Allocator2,
class Allocator3,
class Allocator4>
1715 Allocator4>& A,
int index)
1717 typedef typename ClassComplexType<T>::Treal Treal;
1721 int row_max = IndRow.GetNormInf();
1722 int col_max = IndCol.GetNormInf();
1723 int m = row_max - index + 1;
1724 int n = col_max - index + 1;
1727 m = max(m, A.GetM());
1728 n = max(n, A.GetN());
1732 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1734 for (
long i = 0; i < IndRow.GetM(); i++)
1736 int irow = IndRow(i) - index;
1737 int icol = IndCol(i) - index;
1741 if (real(Val(i)) != zero)
1742 NumRealNnzRow(irow)++;
1744 if (imag(Val(i)) != zero)
1745 NumImagNnzRow(irow)++;
1751 for (
int i = 0; i < m; i++)
1753 if (NumRealNnzRow(i) > 0)
1754 A.ReallocateRealRow(i, NumRealNnzRow(i));
1756 if (NumImagNnzRow(i) > 0)
1757 A.ReallocateImagRow(i, NumImagNnzRow(i));
1761 NumRealNnzRow.Zero(); NumImagNnzRow.Zero();
1762 for (
long i = 0; i < IndRow.GetM(); i++)
1764 int irow = IndRow(i) - index;
1765 int icol = IndCol(i) - index;
1768 if (real(Val(i)) != zero)
1770 int num = NumRealNnzRow(irow);
1771 A.IndexReal(irow, num) = icol;
1772 A.ValueReal(irow, num) = real(Val(i));
1773 NumRealNnzRow(irow)++;
1776 if (imag(Val(i)) != zero)
1778 int num = NumImagNnzRow(irow);
1779 A.IndexImag(irow, num) = icol;
1780 A.ValueImag(irow, num) = imag(Val(i));
1781 NumImagNnzRow(irow)++;
1792 template<
class T,
class Prop,
class Allocator1,
1793 class Allocator2,
class Allocator3,
class Allocator4>
1799 Allocator4>& A,
int index)
1801 typedef typename ClassComplexType<T>::Treal Treal;
1805 int row_max = IndRow.GetNormInf();
1806 int col_max = IndCol.GetNormInf();
1807 int m = row_max - index + 1;
1808 int n = col_max - index + 1;
1811 m = max(m, A.GetM());
1812 n = max(n, A.GetN());
1816 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1818 for (
long i = 0; i < IndCol.GetM(); i++)
1820 int irow = IndRow(i) - index;
1821 int icol = IndCol(i) - index;
1825 if (real(Val(i)) != zero)
1826 NumRealNnzCol(icol)++;
1828 if (imag(Val(i)) != zero)
1829 NumImagNnzCol(icol)++;
1835 for (
int i = 0; i < n; i++)
1837 if (NumRealNnzCol(i) > 0)
1838 A.ReallocateRealColumn(i, NumRealNnzCol(i));
1840 if (NumImagNnzCol(i) > 0)
1841 A.ReallocateImagColumn(i, NumImagNnzCol(i));
1845 NumRealNnzCol.Zero(); NumImagNnzCol.Zero();
1846 for (
long i = 0; i < IndRow.GetM(); i++)
1848 int irow = IndRow(i) - index;
1849 int icol = IndCol(i) - index;
1852 if (real(Val(i)) != zero)
1854 int num = NumRealNnzCol(icol);
1855 A.IndexReal(icol, num) = irow;
1856 A.ValueReal(icol, num) = real(Val(i));
1857 NumRealNnzCol(icol)++;
1860 if (imag(Val(i)) != zero)
1862 int num = NumImagNnzCol(icol);
1863 A.IndexImag(icol, num) = irow;
1864 A.ValueImag(icol, num) = imag(Val(i));
1865 NumImagNnzCol(icol)++;
1876 template<
class T,
class Prop,
class Alloc1,
class Tint0,
1877 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
1892 typedef typename ClassComplexType<T>::Treal Treal;
1893 long* real_ptr_ = A.GetRealPtr();
1894 int* real_ind_ = A.GetRealInd();
1895 Treal* real_data_ = A.GetRealData();
1897 long* imag_ptr_ = A.GetImagPtr();
1898 int* imag_ind_ = A.GetImagInd();
1899 Treal* imag_data_ = A.GetImagData();
1901 long real_nnz = A.GetRealDataSize();
1902 long imag_nnz = A.GetImagDataSize();
1904 Ptr.Reallocate(m+1);
1905 IndCol.Reallocate(real_nnz + imag_nnz);
1906 Value.Reallocate(real_nnz + imag_nnz);
1909 for (
int i = 0; i < m; i++)
1911 long num_i = imag_ptr_[i];
1912 for (
long j = real_ptr_[i]; j < real_ptr_[i+1]; j++)
1914 while ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] < real_ind_[j]))
1917 IndCol(nnz) = imag_ind_[num_i];
1918 Value(nnz) = T(0, imag_data_[num_i]);
1922 if ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] == real_ind_[j]))
1925 IndCol(nnz) = real_ind_[j];
1926 Value(nnz) = T(real_data_[j], imag_data_[num_i]);
1932 IndCol(nnz) = real_ind_[j];
1933 Value(nnz) = T(real_data_[j], 0);
1939 for (
long j = num_i; j < imag_ptr_[i+1]; j++)
1941 IndCol(nnz) = imag_ind_[j];
1942 Value(nnz) = T(0, imag_data_[j]);
1955 template<
class T,
class Prop,
class Alloc1,
class Tint0,
1956 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
1962 typedef typename ClassComplexType<T>::Treal Treal;
1965 long nnz = A.GetDataSize();
1966 long* real_ptr = A.GetRealPtr();
1967 long* imag_ptr = A.GetImagPtr();
1968 int* real_ind = A.GetRealInd();
1969 int* imag_ind = A.GetImagInd();
1970 Treal* real_data = A.GetRealData();
1971 Treal* imag_data = A.GetImagData();
1976 for (
int i = 0; i < n; i++)
1978 long num_i = imag_ptr[i];
1979 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
1981 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
1984 NumNnzRow(imag_ind[num_i])++;
1989 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
1992 NumNnzRow(real_ind[j])++;
1996 NumNnzRow(real_ind[j])++;
2000 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2001 NumNnzRow(imag_ind[j])++;
2005 Ptr.Reallocate(m+1);
2007 for (
int i = 0; i < m; i++)
2008 Ptr(i+1) = Ptr(i) + NumNnzRow(i);
2014 IndCol.Reallocate(nnz);
2015 Val.Reallocate(nnz);
2017 for (
int i = 0; i < n; i++)
2019 long num_i = imag_ptr[i];
int jcol = 0;
2020 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2022 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2024 jcol = imag_ind[num_i];
2026 long num = Ptr(jcol) + NumNnzRow(jcol);
2028 Val(num) = T(0, imag_data[num_i]);
2033 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2036 long num = Ptr(jcol) + NumNnzRow(jcol);
2039 Val(num) = T(real_data[j], imag_data[num_i]);
2046 long num = Ptr(jcol) + NumNnzRow(jcol);
2049 Val(num) = T(real_data[j], 0);
2055 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2058 long num = Ptr(jcol) + NumNnzRow(jcol);
2060 Val(num) = T(0, imag_data[j]);
2068 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2069 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2084 typedef typename ClassComplexType<T>::Treal Treal;
2085 long* real_ptr_ = A.GetRealPtr();
2086 int* real_ind_ = A.GetRealInd();
2087 Treal* real_data_ = A.GetRealData();
2089 long* imag_ptr_ = A.GetImagPtr();
2090 int* imag_ind_ = A.GetImagInd();
2091 Treal* imag_data_ = A.GetImagData();
2093 long real_nnz = A.GetRealDataSize();
2094 long imag_nnz = A.GetImagDataSize();
2096 Ptr.Reallocate(m+1);
2097 IndCol.Reallocate(real_nnz + imag_nnz);
2098 Value.Reallocate(real_nnz + imag_nnz);
2101 for (
int i = 0; i < m; i++)
2103 long num_i = imag_ptr_[i];
2104 for (
long j = real_ptr_[i]; j < real_ptr_[i+1]; j++)
2106 while ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] < real_ind_[j]))
2109 IndCol(nnz) = imag_ind_[num_i];
2110 Value(nnz) = T(0, imag_data_[num_i]);
2114 if ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] == real_ind_[j]))
2117 IndCol(nnz) = real_ind_[j];
2118 Value(nnz) = T(real_data_[j], imag_data_[num_i]);
2124 IndCol(nnz) = real_ind_[j];
2125 Value(nnz) = T(real_data_[j], 0);
2131 for (
long j = num_i; j < imag_ptr_[i+1]; j++)
2133 IndCol(nnz) = imag_ind_[j];
2134 Value(nnz) = T(0, imag_data_[j]);
2147 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2148 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2160 ConvertMatrix_to_Coordinates(A, IndRow, IndCol, Val, 0,
true);
2163 Ptr.Reallocate(m + 1);
2167 for (
long i = 0; i < IndRow.GetM(); i++)
2168 Ptr(IndRow(i) + 1)++;
2172 for (
int i = 0; i < m; i++)
2173 Ptr(i + 1) += Ptr(i);
2178 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2179 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2185 typedef typename ClassComplexType<T>::Treal Treal;
2188 long nnz = A.GetDataSize();
2189 long* real_ptr = A.GetRealPtr();
2190 long* imag_ptr = A.GetImagPtr();
2191 int* real_ind = A.GetRealInd();
2192 int* imag_ind = A.GetImagInd();
2193 Treal* real_data = A.GetRealData();
2194 Treal* imag_data = A.GetImagData();
2199 for (
int i = 0; i < n; i++)
2201 long num_i = imag_ptr[i];
2202 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2204 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2207 NumNnzRow(imag_ind[num_i])++;
2212 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2215 NumNnzRow(real_ind[j])++;
2219 NumNnzRow(real_ind[j])++;
2223 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2224 NumNnzRow(imag_ind[j])++;
2228 Ptr.Reallocate(m+1);
2230 for (
int i = 0; i < m; i++)
2231 Ptr(i+1) = Ptr(i) + NumNnzRow(i);
2237 IndCol.Reallocate(nnz);
2238 Val.Reallocate(nnz);
2240 for (
int i = 0; i < n; i++)
2242 long num_i = imag_ptr[i];
int jcol = 0;
2243 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2245 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2247 jcol = imag_ind[num_i];
2249 long num = Ptr(jcol) + NumNnzRow(jcol);
2251 Val(num) = T(0, imag_data[num_i]);
2256 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2259 long num = Ptr(jcol) + NumNnzRow(jcol);
2262 Val(num) = T(real_data[j], imag_data[num_i]);
2269 long num = Ptr(jcol) + NumNnzRow(jcol);
2272 Val(num) = T(real_data[j], 0);
2278 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2281 long num = Ptr(jcol) + NumNnzRow(jcol);
2283 Val(num) = T(0, imag_data[j]);
2291 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2292 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2303 ConvertMatrix_to_Coordinates(A, IndCol, IndRow, Val, 0,
true);
2306 Ptr.Reallocate(m+1);
2309 for (
long i = 0; i < IndCol.GetM(); i++)
2310 Ptr(IndRow(i) + 1)++;
2313 for (
int i = 2; i <= m; i++)
2319 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2320 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2335 long real_nnz = A.GetRealDataSize();
2336 long imag_nnz = A.GetImagDataSize();
2338 Ptr.Reallocate(m+1);
2339 IndCol.Reallocate(real_nnz + imag_nnz);
2340 Value.Reallocate(real_nnz + imag_nnz);
2343 for (
int i = 0; i < m; i++)
2346 int size_imag = A.GetImagRowSize(i);
2347 for (
int j = 0; j < A.GetRealRowSize(i); j++)
2349 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2352 IndCol(nnz) = A.IndexImag(i, num_i);
2353 Value(nnz) = T(0, A.ValueImag(i, num_i));
2357 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2360 IndCol(nnz) = A.IndexReal(i, j);
2361 Value(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
2367 IndCol(nnz) = A.IndexReal(i, j);
2368 Value(nnz) = T(A.ValueReal(i, j), 0);
2374 for (
int j = num_i; j < size_imag; j++)
2376 IndCol(nnz) = A.IndexImag(i, j);
2377 Value(nnz) = T(0, A.ValueImag(i, j));
2390 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2391 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2399 long nnz = A.GetDataSize();
2404 for (
int i = 0; i < n; i++)
2407 int size_imag = A.GetImagColumnSize(i);
2408 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
2410 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2413 NumNnzRow(A.IndexImag(i, num_i))++;
2417 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2420 NumNnzRow(A.IndexReal(i, j))++;
2424 NumNnzRow(A.IndexReal(i, j))++;
2428 for (
int j = num_i; j < size_imag; j++)
2429 NumNnzRow(A.IndexImag(i, j))++;
2433 Ptr.Reallocate(m+1);
2435 for (
int i = 0; i < m; i++)
2436 Ptr(i+1) = Ptr(i) + NumNnzRow(i);
2442 IndCol.Reallocate(nnz);
2443 Val.Reallocate(nnz);
2445 for (
int i = 0; i < n; i++)
2447 int num_i = 0, jcol = 0;
2448 int size_imag = A.GetImagColumnSize(i);
2449 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
2451 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2453 jcol = A.IndexImag(i, num_i);
2455 long num = Ptr(jcol) + NumNnzRow(jcol);
2457 Val(num) = T(0, A.ValueImag(i, num_i));
2462 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2464 jcol = A.IndexReal(i, j);
2465 long num = Ptr(jcol) + NumNnzRow(jcol);
2468 Val(num) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
2474 jcol = A.IndexReal(i, j);
2475 long num = Ptr(jcol) + NumNnzRow(jcol);
2478 Val(num) = T(A.ValueReal(i, j), 0);
2484 for (
int j = num_i; j < size_imag; j++)
2486 jcol = A.IndexImag(i, j);
2487 long num = Ptr(jcol) + NumNnzRow(jcol);
2489 Val(num) = T(0, A.ValueImag(i, j));
2497 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2498 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2513 long real_nnz = A.GetRealDataSize();
2514 long imag_nnz = A.GetImagDataSize();
2516 Ptr.Reallocate(m+1);
2517 IndCol.Reallocate(real_nnz + imag_nnz);
2518 Value.Reallocate(real_nnz + imag_nnz);
2521 for (
int i = 0; i < m; i++)
2524 int size_imag = A.GetImagRowSize(i);
2525 for (
int j = 0; j < A.GetRealRowSize(i); j++)
2527 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2530 IndCol(nnz) = A.IndexImag(i, num_i);
2531 Value(nnz) = T(0, A.ValueImag(i, num_i));
2535 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2538 IndCol(nnz) = A.IndexReal(i, j);
2539 Value(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
2545 IndCol(nnz) = A.IndexReal(i, j);
2546 Value(nnz) = T(A.ValueReal(i, j), 0);
2552 for (
int j = num_i; j < size_imag; j++)
2554 IndCol(nnz) = A.IndexImag(i, j);
2555 Value(nnz) = T(0, A.ValueImag(i, j));
2568 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2569 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2581 ConvertMatrix_to_Coordinates(A, IndRow, IndCol, Value, 0,
true);
2584 Ptr.Reallocate(m + 1);
2588 for (
long i = 0; i < IndRow.GetM(); i++)
2589 Ptr(IndRow(i) + 1)++;
2593 for (
int i = 0; i < m; i++)
2594 Ptr(i + 1) += Ptr(i);
2599 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2600 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2608 long nnz = A.GetDataSize();
2613 for (
int i = 0; i < n; i++)
2616 int size_imag = A.GetImagColumnSize(i);
2617 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
2619 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2622 NumNnzRow(A.IndexImag(i, num_i))++;
2626 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2629 NumNnzRow(A.IndexReal(i, j))++;
2633 NumNnzRow(A.IndexReal(i, j))++;
2637 for (
int j = num_i; j < size_imag; j++)
2638 NumNnzRow(A.IndexImag(i, j))++;
2642 Ptr.Reallocate(m+1);
2644 for (
int i = 0; i < m; i++)
2645 Ptr(i+1) = Ptr(i) + NumNnzRow(i);
2651 IndCol.Reallocate(nnz);
2652 Val.Reallocate(nnz);
2654 for (
int i = 0; i < n; i++)
2656 int num_i = 0, jcol = 0;
2657 int size_imag = A.GetImagColumnSize(i);
2658 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
2660 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
2662 jcol = A.IndexImag(i, num_i);
2664 long num = Ptr(jcol) + NumNnzRow(jcol);
2666 Val(num) = T(0, A.ValueImag(i, num_i));
2671 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
2673 jcol = A.IndexReal(i, j);
2674 long num = Ptr(jcol) + NumNnzRow(jcol);
2677 Val(num) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
2683 jcol = A.IndexReal(i, j);
2684 long num = Ptr(jcol) + NumNnzRow(jcol);
2687 Val(num) = T(A.ValueReal(i, j), 0);
2693 for (
int j = num_i; j < size_imag; j++)
2695 jcol = A.IndexImag(i, j);
2696 long num = Ptr(jcol) + NumNnzRow(jcol);
2698 Val(num) = T(0, A.ValueImag(i, j));
2706 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2707 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2718 ConvertMatrix_to_Coordinates(A, IndCol, IndRow, Val, 0,
true);
2721 Ptr.Reallocate(m+1);
2724 for (
long i = 0; i < IndCol.GetM(); i++)
2725 Ptr(IndRow(i) + 1)++;
2728 for (
int i = 2; i <= m; i++)
2738 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2739 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2746 throw Undefined(
"ConvertToCSC",
"Symmetrization of pattern not"
2747 " implemented for RowComplexSparse storage");
2749 typedef typename ClassComplexType<T>::Treal Treal;
2752 long nnz = A.GetDataSize();
2753 long* real_ptr = A.GetRealPtr();
2754 long* imag_ptr = A.GetImagPtr();
2755 int* real_ind = A.GetRealInd();
2756 int* imag_ind = A.GetImagInd();
2757 Treal* real_data = A.GetRealData();
2758 Treal* imag_data = A.GetImagData();
2763 for (
int i = 0; i < m; i++)
2765 long num_i = imag_ptr[i];
2766 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2768 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2771 NumNnzCol(imag_ind[num_i])++;
2776 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2779 NumNnzCol(real_ind[j])++;
2783 NumNnzCol(real_ind[j])++;
2787 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2788 NumNnzCol(imag_ind[j])++;
2792 Ptr.Reallocate(n+1);
2794 for (
int i = 0; i < n; i++)
2795 Ptr(i+1) = Ptr(i) + NumNnzCol(i);
2801 IndRow.Reallocate(nnz);
2802 Val.Reallocate(nnz);
2804 for (
int i = 0; i < m; i++)
2806 long num_i = imag_ptr[i];
int jcol = 0;
2807 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2809 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2811 jcol = imag_ind[num_i];
2813 long num = Ptr(jcol) + NumNnzCol(jcol);
2815 Val(num) = T(0, imag_data[num_i]);
2820 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2823 long num = Ptr(jcol) + NumNnzCol(jcol);
2826 Val(num) = T(real_data[j], imag_data[num_i]);
2833 long num = Ptr(jcol) + NumNnzCol(jcol);
2836 Val(num) = T(real_data[j], 0);
2842 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2845 long num = Ptr(jcol) + NumNnzCol(jcol);
2847 Val(num) = T(0, imag_data[j]);
2855 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2856 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2864 throw Undefined(
"ConvertToCSC",
"Symmetrization of pattern not"
2865 " implemented for ColComplexSparse storage");
2876 typedef typename ClassComplexType<T>::Treal Treal;
2878 long* real_ptr_ = A.GetRealPtr();
2879 int* real_ind_ = A.GetRealInd();
2880 Treal* real_data_ = A.GetRealData();
2882 long* imag_ptr_ = A.GetImagPtr();
2883 int* imag_ind_ = A.GetImagInd();
2884 Treal* imag_data_ = A.GetImagData();
2886 long real_nnz = A.GetRealDataSize();
2887 long imag_nnz = A.GetImagDataSize();
2889 Ptr.Reallocate(n+1);
2890 IndCol.Reallocate(real_nnz + imag_nnz);
2891 Value.Reallocate(real_nnz + imag_nnz);
2894 for (
int i = 0; i < n; i++)
2896 long num_i = imag_ptr_[i];
2897 for (
long j = real_ptr_[i]; j < real_ptr_[i+1]; j++)
2899 while ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] < real_ind_[j]))
2902 IndCol(nnz) = imag_ind_[num_i];
2903 Value(nnz) = T(0, imag_data_[num_i]);
2907 if ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] == real_ind_[j]))
2910 IndCol(nnz) = real_ind_[j];
2911 Value(nnz) = T(real_data_[j], imag_data_[num_i]);
2917 IndCol(nnz) = real_ind_[j];
2918 Value(nnz) = T(real_data_[j], 0);
2924 for (
long j = num_i; j < imag_ptr_[i+1]; j++)
2926 IndCol(nnz) = imag_ind_[j];
2927 Value(nnz) = T(0, imag_data_[j]);
2940 template<
class T,
class Prop,
class Alloc1,
class Tint0,
2941 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
2947 typedef typename ClassComplexType<T>::Treal Treal;
2950 long nnz = A.GetDataSize();
2951 long* real_ptr = A.GetRealPtr();
2952 long* imag_ptr = A.GetImagPtr();
2953 int* real_ind = A.GetRealInd();
2954 int* imag_ind = A.GetImagInd();
2955 Treal* real_data = A.GetRealData();
2956 Treal* imag_data = A.GetImagData();
2961 for (
int i = 0; i < n; i++)
2963 long num_i = imag_ptr[i];
2964 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
2966 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
2969 NumNnzCol(imag_ind[num_i])++;
2974 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
2977 NumNnzCol(real_ind[j])++;
2981 NumNnzCol(real_ind[j])++;
2985 for (
long j = num_i; j < imag_ptr[i+1]; j++)
2986 NumNnzCol(imag_ind[j])++;
2990 Ptr.Reallocate(m+1);
2992 for (
int i = 0; i < m; i++)
2993 Ptr(i+1) = Ptr(i) + NumNnzCol(i);
2999 IndRow.Reallocate(nnz);
3000 Val.Reallocate(nnz);
3002 for (
int i = 0; i < n; i++)
3004 long num_i = imag_ptr[i];
int jcol = 0;
3005 for (
long j = real_ptr[i]; j < real_ptr[i + 1]; j++)
3007 while ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] < real_ind[j]))
3009 jcol = imag_ind[num_i];
3011 long num = Ptr(jcol) + NumNnzCol(jcol);
3013 Val(num) = T(0, imag_data[num_i]);
3018 if ((num_i < imag_ptr[i+1]) && (imag_ind[num_i] == real_ind[j]))
3021 long num = Ptr(jcol) + NumNnzCol(jcol);
3024 Val(num) = T(real_data[j], imag_data[num_i]);
3031 long num = Ptr(jcol) + NumNnzCol(jcol);
3034 Val(num) = T(real_data[j], 0);
3040 for (
long j = num_i; j < imag_ptr[i+1]; j++)
3043 long num = Ptr(jcol) + NumNnzCol(jcol);
3045 Val(num) = T(0, imag_data[j]);
3053 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3054 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3065 ConvertMatrix_to_Coordinates(A, IndCol, IndRow, Val, 0,
true);
3068 Ptr.Reallocate(m+1);
3071 for (
long i = 0; i < IndCol.GetM(); i++)
3072 Ptr(IndCol(i) + 1)++;
3075 for (
int i = 2; i <= m; i++)
3081 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3082 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3098 typedef typename ClassComplexType<T>::Treal Treal;
3100 long* real_ptr_ = A.GetRealPtr();
3101 int* real_ind_ = A.GetRealInd();
3102 Treal* real_data_ = A.GetRealData();
3104 long* imag_ptr_ = A.GetImagPtr();
3105 int* imag_ind_ = A.GetImagInd();
3106 Treal* imag_data_ = A.GetImagData();
3108 long real_nnz = A.GetRealDataSize();
3109 long imag_nnz = A.GetImagDataSize();
3111 Ptr.Reallocate(m+1);
3112 IndCol.Reallocate(real_nnz + imag_nnz);
3113 Value.Reallocate(real_nnz + imag_nnz);
3116 for (
int i = 0; i < m; i++)
3118 long num_i = imag_ptr_[i];
3119 for (
long j = real_ptr_[i]; j < real_ptr_[i+1]; j++)
3121 while ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] < real_ind_[j]))
3124 IndCol(nnz) = imag_ind_[num_i];
3125 Value(nnz) = T(0, imag_data_[num_i]);
3129 if ((num_i < imag_ptr_[i+1]) && (imag_ind_[num_i] == real_ind_[j]))
3132 IndCol(nnz) = real_ind_[j];
3133 Value(nnz) = T(real_data_[j], imag_data_[num_i]);
3139 IndCol(nnz) = real_ind_[j];
3140 Value(nnz) = T(real_data_[j], 0);
3146 for (
long j = num_i; j < imag_ptr_[i+1]; j++)
3148 IndCol(nnz) = imag_ind_[j];
3149 Value(nnz) = T(0, imag_data_[j]);
3162 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3163 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3175 ConvertMatrix_to_Coordinates(A, IndRow, IndCol, Val, 0,
true);
3178 Ptr.Reallocate(m + 1);
3182 for (
long i = 0; i < IndRow.GetM(); i++)
3183 Ptr(IndCol(i) + 1)++;
3187 for (
int i = 0; i < m; i++)
3188 Ptr(i + 1) += Ptr(i);
3198 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3199 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3206 throw Undefined(
"ConvertToCSC",
"Symmetrization of pattern not"
3207 "implemented for RowComplexSparse storage");
3211 long nnz = A.GetDataSize();
3216 for (
int i = 0; i < m; i++)
3219 int size_imag = A.GetImagRowSize(i);
3220 for (
int j = 0; j < A.GetRealRowSize(i); j++)
3222 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3225 NumNnzCol(A.IndexImag(i, num_i))++;
3229 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3232 NumNnzCol(A.IndexReal(i, j))++;
3236 NumNnzCol(A.IndexReal(i, j))++;
3240 for (
int j = num_i; j < size_imag; j++)
3241 NumNnzCol(A.IndexImag(i, j))++;
3245 Ptr.Reallocate(n+1);
3247 for (
int i = 0; i < n; i++)
3248 Ptr(i+1) = Ptr(i) + NumNnzCol(i);
3254 IndRow.Reallocate(nnz);
3255 Val.Reallocate(nnz);
3257 for (
int i = 0; i < m; i++)
3259 int num_i = 0, jcol = 0;
3260 int size_imag = A.GetImagRowSize(i);
3261 for (
int j = 0; j < A.GetRealRowSize(i); j++)
3263 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3265 jcol = A.IndexImag(i, num_i);
3267 long num = Ptr(jcol) + NumNnzCol(jcol);
3269 Val(num) = T(0, A.ValueImag(i, num_i));
3274 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3276 jcol = A.IndexReal(i, j);
3277 long num = Ptr(jcol) + NumNnzCol(jcol);
3280 Val(num) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
3286 jcol = A.IndexReal(i, j);
3287 long num = Ptr(jcol) + NumNnzCol(jcol);
3290 Val(num) = T(A.ValueReal(i, j), 0);
3296 for (
int j = num_i; j < size_imag; j++)
3298 jcol = A.IndexImag(i, j);
3299 long num = Ptr(jcol) + NumNnzCol(jcol);
3301 Val(num) = T(0, A.ValueImag(i, j));
3309 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3310 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3318 throw Undefined(
"ConvertToCSC",
"Symmetrization of pattern not"
3319 "implemented for ColComplexSparse storage");
3330 typedef typename ClassComplexType<T>::Treal Treal;
3332 long real_nnz = A.GetRealDataSize();
3333 long imag_nnz = A.GetImagDataSize();
3335 Ptr.Reallocate(n+1);
3336 IndCol.Reallocate(real_nnz + imag_nnz);
3337 Value.Reallocate(real_nnz + imag_nnz);
3340 for (
int i = 0; i < n; i++)
3343 int size_imag = A.GetImagColumnSize(i);
3344 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
3346 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3349 IndCol(nnz) = A.IndexImag(i, num_i);
3350 Value(nnz) = T(0, A.ValueImag(i, num_i));
3354 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3357 IndCol(nnz) = A.IndexReal(i, j);
3358 Value(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
3364 IndCol(nnz) = A.IndexReal(i, j);
3365 Value(nnz) = T(A.ValueReal(i, j), 0);
3371 for (
int j = num_i; j < size_imag; j++)
3373 IndCol(nnz) = A.IndexImag(i, j);
3374 Value(nnz) = T(0, A.ValueImag(i, j));
3387 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3388 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3396 long nnz = A.GetDataSize();
3401 for (
int i = 0; i < n; i++)
3404 int size_imag = A.GetImagRowSize(i);
3405 for (
int j = 0; j < A.GetRealRowSize(i); j++)
3407 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3410 NumNnzCol(A.IndexImag(i, num_i))++;
3414 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3417 NumNnzCol(A.IndexReal(i, j))++;
3421 NumNnzCol(A.IndexReal(i, j))++;
3425 for (
int j = num_i; j < size_imag; j++)
3426 NumNnzCol(A.IndexImag(i, j))++;
3430 Ptr.Reallocate(m+1);
3432 for (
int i = 0; i < m; i++)
3433 Ptr(i+1) = Ptr(i) + NumNnzCol(i);
3439 IndRow.Reallocate(nnz);
3440 Val.Reallocate(nnz);
3442 for (
int i = 0; i < n; i++)
3444 int num_i = 0, jcol = 0;
3445 int size_imag = A.GetImagRowSize(i);
3446 for (
int j = 0; j < A.GetRealRowSize(i); j++)
3448 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3450 jcol = A.IndexImag(i, num_i);
3452 long num = Ptr(jcol) + NumNnzCol(jcol);
3454 Val(num) = T(0, A.ValueImag(i, num_i));
3459 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3461 jcol = A.IndexReal(i, j);
3462 long num = Ptr(jcol) + NumNnzCol(jcol);
3465 Val(num) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
3471 jcol = A.IndexReal(i, j);
3472 long num = Ptr(jcol) + NumNnzCol(jcol);
3475 Val(num) = T(A.ValueReal(i, j), 0);
3481 for (
int j = num_i; j < size_imag; j++)
3483 jcol = A.IndexImag(i, j);
3484 long num = Ptr(jcol) + NumNnzCol(jcol);
3486 Val(num) = T(0, A.ValueImag(i, j));
3494 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3495 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3506 ConvertMatrix_to_Coordinates(A, IndCol, IndRow, Val, 0,
true);
3509 Ptr.Reallocate(m+1);
3512 for (
long i = 0; i < IndCol.GetM(); i++)
3513 Ptr(IndCol(i) + 1)++;
3516 for (
int i = 2; i <= m; i++)
3523 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3524 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3540 typedef typename ClassComplexType<T>::Treal Treal;
3542 long real_nnz = A.GetRealDataSize();
3543 long imag_nnz = A.GetImagDataSize();
3545 Ptr.Reallocate(n+1);
3546 IndCol.Reallocate(real_nnz + imag_nnz);
3547 Value.Reallocate(real_nnz + imag_nnz);
3550 for (
int i = 0; i < n; i++)
3553 int size_imag = A.GetImagColumnSize(i);
3554 for (
int j = 0; j < A.GetRealColumnSize(i); j++)
3556 while ((num_i < size_imag) && (A.IndexImag(i, num_i) < A.IndexReal(i, j)))
3559 IndCol(nnz) = A.IndexImag(i, num_i);
3560 Value(nnz) = T(0, A.ValueImag(i, num_i));
3564 if ((num_i < size_imag) && (A.IndexImag(i, num_i) == A.IndexReal(i, j)))
3567 IndCol(nnz) = A.IndexReal(i, j);
3568 Value(nnz) = T(A.ValueReal(i, j), A.ValueImag(i, num_i));
3574 IndCol(nnz) = A.IndexReal(i, j);
3575 Value(nnz) = T(A.ValueReal(i, j), 0);
3581 for (
int j = num_i; j < size_imag; j++)
3583 IndCol(nnz) = A.IndexImag(i, j);
3584 Value(nnz) = T(0, A.ValueImag(i, j));
3597 template<
class T,
class Prop,
class Alloc1,
class Tint0,
3598 class Tint1,
class Alloc2,
class Alloc3,
class Alloc4>
3610 ConvertMatrix_to_Coordinates(A, IndRow, IndCol, Val, 0,
true);
3613 Ptr.Reallocate(m + 1);
3617 for (
long i = 0; i < IndRow.GetM(); i++)
3618 Ptr(IndCol(i) + 1)++;
3622 for (
int i = 0; i < m; i++)
3623 Ptr(i + 1) += Ptr(i);
3628 template<
class T0,
class Prop0,
class Allocator0,
3629 class T1,
class Prop1,
class Allocator1>
3638 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3640 int m = mat_array.GetM();
3641 int n = mat_array.GetN();
3642 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3647 template<
class T0,
class Prop0,
class Allocator0,
3648 class T1,
class Prop1,
class Allocator1>
3657 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3659 int m = mat_array.GetM();
3660 int n = mat_array.GetN();
3661 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3666 template<
class T0,
class Prop0,
class Allocator0,
3667 class T1,
class Prop1,
class Allocator1>
3676 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3678 int m = mat_array.GetM();
3679 int n = mat_array.GetN();
3680 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3685 template<
class T0,
class Prop0,
class Allocator0,
3686 class T1,
class Prop1,
class Allocator1>
3695 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3697 int m = mat_array.GetM();
3698 int n = mat_array.GetN();
3699 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3704 template<
class T0,
class Prop0,
class Allocator0,
3705 class T1,
class Prop1,
class Allocator1>
3714 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3716 int m = mat_array.GetM();
3717 int n = mat_array.GetN();
3718 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3723 template<
class T0,
class Prop0,
class Allocator0,
3724 class T1,
class Prop1,
class Allocator1>
3733 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3735 int m = mat_array.GetM();
3736 int n = mat_array.GetN();
3737 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3742 template<
class T0,
class Prop0,
class Allocator0,
3743 class T1,
class Prop1,
class Allocator1>
3752 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3754 int m = mat_array.GetM();
3755 int n = mat_array.GetN();
3756 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3761 template<
class T0,
class Prop0,
class Allocator0,
3762 class T1,
class Prop1,
class Allocator1>
3771 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3773 int m = mat_array.GetM();
3774 int n = mat_array.GetN();
3775 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3780 template<
class T0,
class Prop0,
class Allocator0,
3781 class T1,
class Prop1,
class Allocator1>
3790 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3792 int m = mat_array.GetM();
3793 int n = mat_array.GetN();
3794 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3799 template<
class T0,
class Prop0,
class Allocator0,
3800 class T1,
class Prop1,
class Allocator1>
3809 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3811 int m = mat_array.GetM();
3812 int n = mat_array.GetN();
3813 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3818 template<
class T0,
class Prop0,
class Allocator0,
3819 class T1,
class Prop1,
class Allocator1>
3828 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3830 int m = mat_array.GetM();
3831 int n = mat_array.GetN();
3832 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3837 template<
class T0,
class Prop0,
class Allocator0,
3838 class T1,
class Prop1,
class Allocator1>
3847 ConvertToCSR(mat_array, prop, Ptr, IndCol, Value);
3849 int m = mat_array.GetM();
3850 int n = mat_array.GetN();
3851 mat_csr.SetData(m, n, Value, Ptr, IndCol);
3856 template<
class T0,
class Prop0,
class Allocator0,
3857 class T1,
class Prop1,
class Allocator1>
3866 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3870 B.SetData(m, n, Value, Ptr, IndRow);
3875 template<
class T0,
class Prop0,
class Allocator0,
3876 class T1,
class Prop1,
class Allocator1>
3885 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3889 B.SetData(m, n, Value, Ptr, IndRow);
3894 template<
class T0,
class Prop0,
class Allocator0,
3895 class T1,
class Prop1,
class Allocator1>
3904 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3908 B.SetData(m, n, Value, Ptr, IndRow);
3913 template<
class T0,
class Prop0,
class Allocator0,
3914 class T1,
class Prop1,
class Allocator1>
3923 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3927 B.SetData(m, n, Value, Ptr, IndRow);
3932 template<
class T0,
class Prop0,
class Allocator0,
3933 class T1,
class Prop1,
class Allocator1>
3942 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3946 B.SetData(m, n, Value, Ptr, IndRow);
3951 template<
class T0,
class Prop0,
class Allocator0,
3952 class T1,
class Prop1,
class Allocator1>
3961 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3965 B.SetData(m, n, Value, Ptr, IndRow);
3970 template<
class T0,
class Prop0,
class Allocator0,
3971 class T1,
class Prop1,
class Allocator1>
3980 ConvertToCSC(A, prop, Ptr, IndRow, Value);
3984 B.SetData(m, n, Value, Ptr, IndRow);
3989 template<
class T0,
class Prop0,
class Allocator0,
3990 class T1,
class Prop1,
class Allocator1>
3999 ConvertToCSC(A, prop, Ptr, IndRow, Value);
4003 B.SetData(m, n, Value, Ptr, IndRow);
4008 template<
class T0,
class Prop0,
class Allocator0,
4009 class T1,
class Prop1,
class Allocator1>
4018 ConvertToCSC(A, prop, Ptr, IndRow, Value);
4022 B.SetData(m, n, Value, Ptr, IndRow);
4027 template<
class T0,
class Prop0,
class Allocator0,
4028 class T1,
class Prop1,
class Allocator1>
4037 ConvertToCSC(A, prop, Ptr, IndRow, Value);
4041 B.SetData(m, n, Value, Ptr, IndRow);
4046 template<
class T0,
class Prop0,
class Allocator0,
4047 class T1,
class Prop1,
class Allocator1>
4056 ConvertToCSC(A, prop, Ptr, IndRow, Value);
4060 B.SetData(m, n, Value, Ptr, IndRow);
4065 template<
class T0,
class Prop0,
class Allocator0,
4066 class T1,
class Prop1,
class Allocator1>
4075 ConvertToCSC(A, prop, Ptr, IndRow, Value);
4079 B.SetData(m, n, Value, Ptr, IndRow);
4084 template<
class T,
class Prop,
class Allocator>
4093 template<
class T,
class Prop,
class Allocator>
4102 template<
class T,
class Prop,
class Allocator>
4111 template<
class T,
class Prop,
class Allocator>
4120 template<
class T,
class Prop,
class Allocator>
4129 template<
class T,
class Prop,
class Allocator>
4138 template<
class T,
class Prop,
class Allocator>
4147 template<
class T,
class Prop,
class Allocator>
4156 template<
class T0,
class Prop0,
class Allocator0,
4157 class T1,
class Prop1,
class Allocator1>
4162 int m = A.GetM(), n = A.GetN();
4167 ConvertToCSR(A, sym, Ptr, Ind, Value);
4170 typedef typename ClassComplexType<T1>::Treal Treal;
4171 long imag_nnz = 0, real_nnz = 0;
4173 for (
long i = 0; i < Value.GetM(); i++)
4175 if (real(Value(i)) != zero)
4178 if (imag(Value(i)) != zero)
4183 Vector<int> Ind_real(real_nnz), Ind_imag(imag_nnz);
4187 Ptr_real(0) = 0; Ptr_imag(0) = 0;
4188 real_nnz = 0; imag_nnz = 0;
4189 for (
int i = 0; i < m; i++)
4191 for (
long j = Ptr(i); j < Ptr(i+1); j++)
4193 if (real(Value(j)) != zero)
4195 Ind_real(real_nnz) = Ind(j);
4196 Val_real(real_nnz) = real(Value(j));
4200 if (imag(Value(j)) != zero)
4202 Ind_imag(imag_nnz) = Ind(j);
4203 Val_imag(imag_nnz) = imag(Value(j));
4208 Ptr_real(i+1) = real_nnz;
4209 Ptr_imag(i+1) = imag_nnz;
4214 B.SetData(m, n, Val_real, Ptr_real, Ind_real,
4215 Val_imag, Ptr_imag, Ind_imag);
4220 template<
class T0,
class Prop0,
class Allocator0,
4221 class T1,
class Prop1,
class Allocator1>
4228 long* ptr_ = A.GetPtr();
4229 int* ind_ = A.GetInd();
4230 T0* data_ = A.GetData();
4231 long nnz = A.GetDataSize();
4234 long imag_nnz = 0, real_nnz = 0;
4235 typedef typename ClassComplexType<T1>::Treal Treal;
4237 for (
long i = 0; i < nnz; i++)
4239 if (real(data_[i]) != zero)
4242 if (imag(data_[i]) != zero)
4247 Vector<int> Ind_real(real_nnz), Ind_imag(imag_nnz);
4252 Ptr_real(0) = 0; Ptr_imag(0) = 0;
4253 real_nnz = 0; imag_nnz = 0;
4254 for (
int i = 0; i < n; i++)
4256 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4258 if (real(data_[j]) != zero)
4260 Ind_real(real_nnz) = ind_[j];
4261 Val_real(real_nnz) = real(data_[j]);
4265 if (imag(data_[j]) != zero)
4267 Ind_imag(imag_nnz) = ind_[j];
4268 Val_imag(imag_nnz) = imag(data_[j]);
4273 Ptr_real(i+1) = real_nnz;
4274 Ptr_imag(i+1) = imag_nnz;
4279 B.SetData(m, n, Val_real, Ptr_real, Ind_real,
4280 Val_imag, Ptr_imag, Ind_imag);
4285 template<
class T0,
class Prop0,
class Allocator0,
4286 class T1,
class Prop1,
class Allocator1>
4291 int m = A.GetM(), n = A.GetN();
4296 ConvertToCSC(A, sym, Ptr, Ind, Value);
4299 long imag_nnz = 0, real_nnz = 0;
4300 typedef typename ClassComplexType<T1>::Treal Treal;
4302 for (
long i = 0; i < Value.GetM(); i++)
4304 if (real(Value(i)) != zero)
4307 if (imag(Value(i)) != zero)
4312 Vector<int> Ind_real(real_nnz), Ind_imag(imag_nnz);
4317 Ptr_real(0) = 0; Ptr_imag(0) = 0;
4318 real_nnz = 0; imag_nnz = 0;
4319 for (
int i = 0; i < m; i++)
4321 for (
long j = Ptr(i); j < Ptr(i+1); j++)
4323 if (real(Value(j)) != zero)
4325 Ind_real(real_nnz) = Ind(j);
4326 Val_real(real_nnz) = real(Value(j));
4330 if (imag(Value(j)) != zero)
4332 Ind_imag(imag_nnz) = Ind(j);
4333 Val_imag(imag_nnz) = imag(Value(j));
4338 Ptr_real(i+1) = real_nnz;
4339 Ptr_imag(i+1) = imag_nnz;
4344 B.SetData(m, n, Val_real, Ptr_real, Ind_real,
4345 Val_imag, Ptr_imag, Ind_imag);
4350 template<
class T0,
class Prop0,
class Allocator0,
4351 class T1,
class Prop1,
class Allocator1>
4358 long* ptr_ = A.GetPtr();
4359 int* ind_ = A.GetInd();
4360 T0* data_ = A.GetData();
4361 long nnz = A.GetDataSize();
4364 long imag_nnz = 0, real_nnz = 0;
4365 typedef typename ClassComplexType<T1>::Treal Treal;
4367 for (
long i = 0; i < nnz; i++)
4369 if (real(data_[i]) != zero)
4372 if (imag(data_[i]) != zero)
4377 Vector<int> Ind_real(real_nnz), Ind_imag(imag_nnz);
4382 Ptr_real(0) = 0; Ptr_imag(0) = 0;
4383 real_nnz = 0; imag_nnz = 0;
4384 for (
int i = 0; i < n; i++)
4386 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4388 if (real(data_[j]) != zero)
4390 Ind_real(real_nnz) = ind_[j];
4391 Val_real(real_nnz) = real(data_[j]);
4395 if (imag(data_[j]) != zero)
4397 Ind_imag(imag_nnz) = ind_[j];
4398 Val_imag(imag_nnz) = imag(data_[j]);
4403 Ptr_real(i+1) = real_nnz;
4404 Ptr_imag(i+1) = imag_nnz;
4409 B.SetData(m, n, Val_real, Ptr_real, Ind_real,
4410 Val_imag, Ptr_imag, Ind_imag);
4415 template<
class T0,
class Prop0,
class Allocator0,
4416 class T1,
class Prop1,
class Allocator1>
4421 int m = A.GetM(), n = A.GetN();
4425 typedef typename ClassComplexType<T1>::Treal Treal;
4428 for (
int i = 0; i < m; i++)
4430 int size_real = 0, size_imag = 0;
4431 for (
int j = 0; j < Ar.GetRowSize(i); j++)
4433 if (real(Ar.Value(i, j)) != zero)
4436 if (imag(Ar.Value(i, j)) != zero)
4440 B.ReallocateRealRow(i, size_real);
4441 B.ReallocateImagRow(i, size_imag);
4444 for (
int j = 0; j < Ar.GetRowSize(i); j++)
4446 if (real(Ar.Value(i, j)) != zero)
4448 B.IndexReal(i, size_real) = Ar.Index(i, j);
4449 B.ValueReal(i, size_real) = real(Ar.Value(i, j));
4453 if (imag(Ar.Value(i, j)) != zero)
4455 B.IndexImag(i, size_imag) = Ar.Index(i, j);
4456 B.ValueImag(i, size_imag) = imag(Ar.Value(i, j));
4467 template<
class T0,
class Prop0,
class Allocator0,
4468 class T1,
class Prop1,
class Allocator1>
4475 long* ptr_ = A.GetPtr();
4476 int* ind_ = A.GetInd();
4477 T0* data_ = A.GetData();
4479 typedef typename ClassComplexType<T1>::Treal Treal;
4482 for (
int i = 0; i < n; i++)
4484 int size_real = 0, size_imag = 0;
4485 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4487 if (real(data_[j]) != zero)
4490 if (imag(data_[j]) != zero)
4494 B.ReallocateRealColumn(i, size_real);
4495 B.ReallocateImagColumn(i, size_imag);
4498 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4500 if (real(data_[j]) != zero)
4502 B.IndexReal(i, size_real) = ind_[j];
4503 B.ValueReal(i, size_real) = real(data_[j]);
4507 if (imag(data_[j]) != zero)
4509 B.IndexImag(i, size_imag) = ind_[j];
4510 B.ValueImag(i, size_imag) = imag(data_[j]);
4519 template<
class T0,
class Prop0,
class Allocator0,
4520 class T1,
class Prop1,
class Allocator1>
4525 int m = A.GetM(), n = A.GetN();
4529 typedef typename ClassComplexType<T1>::Treal Treal;
4532 for (
int i = 0; i < m; i++)
4534 int size_real = 0, size_imag = 0;
4535 for (
int j = 0; j < Ar.GetColumnSize(i); j++)
4537 if (real(Ar.Value(i, j)) != zero)
4540 if (imag(Ar.Value(i, j)) != zero)
4544 B.ReallocateRealColumn(i, size_real);
4545 B.ReallocateImagColumn(i, size_imag);
4548 for (
int j = 0; j < Ar.GetColumnSize(i); j++)
4550 if (real(Ar.Value(i, j)) != zero)
4552 B.IndexReal(i, size_real) = Ar.Index(i, j);
4553 B.ValueReal(i, size_real) = real(Ar.Value(i, j));
4557 if (imag(Ar.Value(i, j)) != zero)
4559 B.IndexImag(i, size_imag) = Ar.Index(i, j);
4560 B.ValueImag(i, size_imag) = imag(Ar.Value(i, j));
4571 template<
class T0,
class Prop0,
class Allocator0,
4572 class T1,
class Prop1,
class Allocator1>
4579 long* ptr_ = A.GetPtr();
4580 int* ind_ = A.GetInd();
4581 T0* data_ = A.GetData();
4583 typedef typename ClassComplexType<T1>::Treal Treal;
4586 for (
int i = 0; i < n; i++)
4588 int size_real = 0, size_imag = 0;
4589 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4591 if (real(data_[j]) != zero)
4594 if (imag(data_[j]) != zero)
4598 B.ReallocateRealRow(i, size_real);
4599 B.ReallocateImagRow(i, size_imag);
4602 for (
long j = ptr_[i]; j < ptr_[i+1]; j++)
4604 if (real(data_[j]) != zero)
4606 B.IndexReal(i, size_real) = ind_[j];
4607 B.ValueReal(i, size_real) = real(data_[j]);
4611 if (imag(data_[j]) != zero)
4613 B.IndexImag(i, size_imag) = ind_[j];
4614 B.ValueImag(i, size_imag) = imag(data_[j]);
4623 template<
class T0,
class Prop0,
class Allocator0,
4624 class T1,
class Prop1,
class Allocator1>
4632 long nnz_real = mat_array.GetRealDataSize();
4633 long nnz_imag = mat_array.GetImagDataSize();
4634 int m = mat_array.GetM();
4635 int n = mat_array.GetN();
4638 typedef typename ClassComplexType<T1>::Treal Treal;
4645 long ind_real = 0, ind_imag = 0;
4649 for (i = 0; i < m; i++)
4651 for (k = 0; k < mat_array.GetRealRowSize(i); k++)
4653 IndCol_real(ind_real) = mat_array.IndexReal(i, k);
4654 Val_real(ind_real) = mat_array.ValueReal(i, k);
4658 IndRow_real(i + 1) = ind_real;
4659 for (k = 0; k < mat_array.GetImagRowSize(i); k++)
4661 IndCol_imag(ind_imag) = mat_array.IndexImag(i, k);
4662 Val_imag(ind_imag) = mat_array.ValueImag(i, k);
4666 IndRow_imag(i + 1) = ind_imag;
4669 mat_csr.SetData(m, n, Val_real, IndRow_real, IndCol_real,
4670 Val_imag, IndRow_imag, IndCol_imag);
4675 template<
class T0,
class Prop0,
class Allocator0,
4676 class T1,
class Prop1,
class Allocator1>
4685 long nnz_real = mat_array.GetRealDataSize();
4686 long nnz_imag = mat_array.GetImagDataSize();
4687 int m = mat_array.GetM();
4690 typedef typename ClassComplexType<T1>::Treal Treal;
4697 long ind_real = 0, ind_imag = 0;
4701 for (i = 0; i < m; i++)
4703 for (k = 0; k < mat_array.GetRealRowSize(i); k++)
4705 IndCol_real(ind_real) = mat_array.IndexReal(i, k);
4706 Val_real(ind_real) = mat_array.ValueReal(i, k);
4710 IndRow_real(i + 1) = ind_real;
4711 for (
int k = 0; k < mat_array.GetImagRowSize(i); k++)
4713 IndCol_imag(ind_imag) = mat_array.IndexImag(i, k);
4714 Val_imag(ind_imag) = mat_array.ValueImag(i, k);
4718 IndRow_imag(i + 1) = ind_imag;
4721 mat_csr.SetData(m, m, Val_real, IndRow_real, IndCol_real,
4722 Val_imag, IndRow_imag, IndCol_imag);
4727 template<
class T0,
class Prop0,
class Allocator0,
4728 class T1,
class Prop1,
class Allocator1>
4737 ConvertMatrix_to_Coordinates(mat_array, IndRow, IndCol, Value, 0,
true);
4739 int m = mat_array.GetM();
4740 int n = mat_array.GetN();
4741 mat_csr.Reallocate(m, n);
4743 for (
int i = 0; i < m; i++)
4746 while ((k < IndRow.GetM()) && (IndRow(k) <= i))
4749 int size_row = k - k0;
4752 mat_csr.ReallocateRow(i, size_row);
4753 for (
int j = 0; j < size_row; j++)
4755 mat_csr.Index(i, j) = IndCol(k0 + j);
4756 mat_csr.Value(i, j) = Value(k0 + j);
4760 mat_csr.ClearRow(i);
4767 template<
class T0,
class Prop0,
class Allocator0,
4768 class T1,
class Prop1,
class Allocator1>
4778 for (
int i = 0; i < m; i++)
4780 int size_real = A.GetRealRowSize(i);
4781 int size_imag = A.GetImagRowSize(i);
4784 while (jr < size_real)
4786 int col = A.IndexReal(i, jr);
4787 while ((ji < size_imag) && (A.IndexImag(i, ji) < col))
4789 col_num(size_row) = A.IndexImag(i, ji);
4790 value(size_row) = T0(0, A.ValueImag(i, ji));
4794 if ((ji < size_imag) && (A.IndexImag(i, ji) == col))
4796 col_num(size_row) = col;
4797 value(size_row) = T0(A.ValueReal(i, jr),
4798 A.ValueImag(i, ji));
4803 col_num(size_row) = col;
4804 value(size_row) = T0(A.ValueReal(i, jr), 0);
4811 while (ji < size_imag)
4813 col_num(size_row) = A.IndexImag(i, ji);
4814 value(size_row) = T0(0, A.ValueImag(i, ji));
4818 B.ReallocateRow(i, size_row);
4819 for (
int j = 0; j < size_row; j++)
4821 B.Index(i, j) = col_num(j);
4822 B.Value(i, j) = value(j);
4829 template<
class T0,
class Prop0,
class Allocator0,
4830 class T1,
class Prop1,
class Allocator1>
4840 for (
int i = 0; i < m; i++)
4842 int size_real = A.GetRealRowSize(i);
4843 int size_imag = A.GetImagRowSize(i);
4846 while (jr < size_real)
4848 int col = A.IndexReal(i, jr);
4849 while ((ji < size_imag) && (A.IndexImag(i, ji) < col))
4851 col_num(size_row) = A.IndexImag(i, ji);
4852 value(size_row) = T0(0, A.ValueImag(i, ji));
4856 if ((ji < size_imag) && (A.IndexImag(i, ji) == col))
4858 col_num(size_row) = col;
4859 value(size_row) = T0(A.ValueReal(i, jr),
4860 A.ValueImag(i, ji));
4865 col_num(size_row) = col;
4866 value(size_row) = T0(A.ValueReal(i, jr), 0);
4873 while (ji < size_imag)
4875 col_num(size_row) = A.IndexImag(i, ji);
4876 value(size_row) = T0(0, A.ValueImag(i, ji));
4880 B.ReallocateRow(i, size_row);
4881 for (
int j = 0; j < size_row; j++)
4883 B.Index(i, j) = col_num(j);
4884 B.Value(i, j) = value(j);
4891 template<
class T0,
class Prop0,
class Allocator0,
4892 class T1,
class Prop1,
class Allocator1>
4901 ConvertMatrix_to_Coordinates(mat_array, IndRow, IndCol, Value, 0,
true);
4903 int m = mat_array.GetM();
4904 int n = mat_array.GetN();
4905 mat_csr.Reallocate(m, n);
4907 for (
int i = 0; i < m; i++)
4910 while ((k < IndRow.GetM()) && (IndRow(k) <= i))
4913 int size_row = k - k0;
4916 mat_csr.ReallocateRow(i, size_row);
4917 for (
int j = 0; j < size_row; j++)
4919 mat_csr.Index(i, j) = IndCol(k0 + j);
4920 mat_csr.Value(i, j) = Value(k0 + j);
4924 mat_csr.ClearRow(i);
4930 template<
class T0,
class Prop0,
class Allocator0,
4931 class T1,
class Prop1,
class Allocator1>
4936 typedef typename ClassComplexType<T0>::Treal Treal;
4939 long* ptr_real = A.GetRealPtr();
4940 int* ind_real = A.GetRealInd();
4941 Treal* data_real = A.GetRealData();
4942 long* ptr_imag = A.GetImagPtr();
4943 int* ind_imag = A.GetImagInd();
4944 Treal* data_imag = A.GetImagData();
4948 for (
int i = 0; i < m; i++)
4950 long jr = ptr_real[i], ji = ptr_imag[i];
4952 while (jr < ptr_real[i+1])
4954 int col = ind_real[jr];
4955 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < col))
4957 col_num(size_row) = ind_imag[ji];
4958 value(size_row) = T0(0, data_imag[ji]);
4962 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == col))
4964 col_num(size_row) = col;
4965 value(size_row) = T0(data_real[jr],
4971 col_num(size_row) = col;
4972 value(size_row) = T0(data_real[jr], 0);
4979 while (ji < ptr_imag[i+1])
4981 col_num(size_row) = ind_imag[ji];
4982 value(size_row) = T0(0, data_imag[ji]);
4986 B.ReallocateRow(i, size_row);
4987 for (
int j = 0; j < size_row; j++)
4989 B.Index(i, j) = col_num(j);
4990 B.Value(i, j) = value(j);
4997 template<
class T0,
class Prop0,
class Allocator0,
4998 class T1,
class Prop1,
class Allocator1>
5003 typedef typename ClassComplexType<T0>::Treal Treal;
5006 long* ptr_real = A.GetRealPtr();
5007 int* ind_real = A.GetRealInd();
5008 Treal* data_real = A.GetRealData();
5009 long* ptr_imag = A.GetImagPtr();
5010 int* ind_imag = A.GetImagInd();
5011 Treal* data_imag = A.GetImagData();
5015 for (
int i = 0; i < m; i++)
5017 long jr = ptr_real[i], ji = ptr_imag[i];
5019 while (jr < ptr_real[i+1])
5021 int col = ind_real[jr];
5022 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < col))
5024 col_num(size_row) = ind_imag[ji];
5025 value(size_row) = T0(0, data_imag[ji]);
5029 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == col))
5031 col_num(size_row) = col;
5032 value(size_row) = T0(data_real[jr],
5038 col_num(size_row) = col;
5039 value(size_row) = T0(data_real[jr], 0);
5046 while (ji < ptr_imag[i+1])
5048 col_num(size_row) = ind_imag[ji];
5049 value(size_row) = T0(0, data_imag[ji]);
5053 B.ReallocateRow(i, size_row);
5054 for (
int j = 0; j < size_row; j++)
5056 B.Index(i, j) = col_num(j);
5057 B.Value(i, j) = value(j);
5065 #define SELDON_FILE_MATRIX_COMPLEX_CONVERSIONS_CXX