21 #ifndef SELDON_FILE_FUNCTIONS_MATRIX_COMPLEX_CXX
54 template<
class T0,
class T1,
class Allocator1,
class T2,
class Allocator2>
60 int m = B.GetM(), n, ni;
62 IVect index(2*B.GetN());
63 for (
int i = 0 ; i < m ; i++)
65 n = A.GetRealRowSize(i);
66 ni = A.GetImagRowSize(i);
67 for (
int j = 0; j < n; j++)
69 value(j) = alpha*T2(A.ValueReal(i, j), 0);
70 index(j) = A.IndexReal(i, j);
73 for (
int j = 0; j < ni; j++)
75 value(j+n) = alpha*T2(0, A.ValueImag(i, j));
76 index(j+n) = A.IndexImag(i, j);
79 B.AddInteractionRow(i, n+ni, index, value);
85 template<
class T0,
class T1,
class Allocator1,
class T2,
class Allocator2>
92 for (
int i = 0 ; i < m ; i++)
94 n = A.GetRealRowSize(i);
95 for (
int j = 0; j < n; j++)
96 value(j) = alpha*T1(A.ValueReal(i, j), 0);
98 B.AddInteractionRow(i, n, A.GetRealInd(i), value.GetData());
100 n = A.GetImagRowSize(i);
101 for (
int j = 0; j < n; j++)
102 value(j) = alpha*T1(0, A.ValueImag(i, j));
104 B.AddInteractionRow(i, n, A.GetImagInd(i), value.GetData());
110 template<
class T0,
class T1,
class Allocator1,
111 class T2,
class Allocator2>
118 for (
int i = 0; i < m; i++)
120 n = A.GetRealRowSize(i);
121 for (
int j = 0; j < n; j++)
122 value(j) = alpha*T1(A.ValueReal(i, j), 0);
124 B.AddInteractionRow(i, n, A.GetRealInd(i), value.GetData());
126 n = A.GetImagRowSize(i);
127 for (
int j = 0; j < n; j++)
128 value(j) = alpha*T1(0, A.ValueImag(i, j));
130 B.AddInteractionRow(i, n, A.GetImagInd(i), value.GetData());
136 template<
class T0,
class T1,
class Allocator1,
137 class T2,
class Allocator2>
142 int m = B.GetM(), n, ni;
144 for (
int i = 0 ; i < m ; i++)
146 n = A.GetRealRowSize(i);
147 ni = A.GetImagRowSize(i);
148 for (
int j = 0; j < n; j++)
150 value(j) = alpha*T2(A.ValueReal(i, j), 0);
151 index(j) = A.IndexReal(i, j);
154 for (
int j = 0; j < ni; j++)
156 value(n+j) = alpha*T2(0, A.ValueImag(i, j));
157 index(n+j) = A.IndexImag(i, j);
160 B.AddInteractionRow(i, n+ni, index, value);
166 template<
class T0,
class T1,
class Prop1,
class Allocator1,
167 class T2,
class Prop2,
class Allocator2,
168 class T3,
class Prop3,
class Allocator3>
174 int m = B.GetM(), n, ni;
176 for (
int i = 0 ; i < m ; i++)
179 ni = B.GetRowSize(i);
180 for (
int j = 0; j < n; j++)
182 value(j) = alpha*T3(A.Value(i, j), 0);
183 index(j) = A.Index(i, j);
186 for (
int j = 0; j < ni; j++)
188 value(n+j) = alpha*T3(0, B.Value(i, j));
189 index(n+j) = B.Index(i, j);
192 C.AddInteractionRow(i, n+ni, index, value);
198 template<
class T0,
class T1,
class Prop1,
class Allocator1,
199 class T2,
class Prop2,
class Allocator2,
200 class T3,
class Prop3,
class Allocator3>
206 int m = B.GetM(), n, ni;
208 IVect index(2*B.GetN());
209 for (
int i = 0 ; i < m ; i++)
212 ni = B.GetRowSize(i);
213 for (
int j = 0; j < n; j++)
215 value(j) = alpha*T3(A.Value(i, j), 0);
216 index(j) = A.Index(i, j);
219 for (
int j = 0; j < ni; j++)
221 value(n+j) = alpha*T3(0, B.Value(i, j));
222 index(n+j) = B.Index(i, j);
225 C.AddInteractionRow(i, n+ni, index, value);
230 template<
class T,
class Allocator>
231 void Add_csr_ptr(
const T& alpha,
long* ptr_A,
int* ind_A, T* data_A,
232 long* ptr_B,
int* ind_B, T* data_B,
int m,
235 Vector<T, VectFull, Allocator>& Val)
244 for (i = 0; i < m; i++)
245 if (ptr_A[i + 1] == ptr_B[i + 1])
247 for (j = ptr_A[i]; j < ptr_A[i + 1]; j++)
248 if (ind_A[j] == ind_B[j])
249 data_B[j] += alpha * data_A[j];
252 if (j != ptr_A[i + 1])
265 for (k = ptr_A[i]; k < j; k++)
266 if (ind_A[k] == ind_B[k])
267 data_B[k] -= alpha * data_A[k];
270 long Nnonzero = ptr_A[i];
273 long kb, jb(0), ka, ja(0);
274 for (
int i2 = i; i2 < m; i2++)
278 for (ka = ptr_A[i2]; ka < ptr_A[i2 + 1]; ka++)
281 while (kb < ptr_B[i2 + 1] && ind_B[kb] < ja)
287 if (kb < ptr_B[i2 + 1] && ja == ind_B[kb])
293 while (kb < ptr_B[i2 + 1])
303 Ptr.Reallocate(m+1); Ind.Reallocate(Nnonzero);
304 Val.Reallocate(Nnonzero);
305 for (
int i2 = 0; i2 <= i; i2++)
308 for (j = 0; j < ptr_B[i]; j++)
319 if (kb < ptr_B[i + 1])
321 for (ka = ptr_A[i]; ka < ptr_A[i + 1]; ka++)
324 while (kb < ptr_B[i + 1] && jb < ja)
328 Val(Nnonzero) = data_B[kb];
330 if (kb < ptr_B[i + 1])
335 if (kb < ptr_B[i + 1] && ja == jb)
339 Val(Nnonzero) = data_B[kb] + alpha * data_A[ka];
341 if (kb < ptr_B[i + 1])
347 Val(Nnonzero) = alpha * data_A[ka];
353 while (kb < ptr_B[i + 1])
356 Val(Nnonzero) = data_B[kb];
358 if (kb < ptr_B[i + 1])
363 Ptr(i + 1) = Nnonzero;
369 template<
class T0,
class T1,
class Allocator1,
370 class T2,
class Allocator2>
379 VectFull, Allocator2> DataReal, DataImag;
381 Add_csr_ptr(alpha, A.GetRealPtr(), A.GetRealInd(), A.GetRealData(),
382 B.GetRealPtr(), B.GetRealInd(), B.GetRealData(), B.GetM(),
383 PtrReal, IndReal, DataReal);
385 Add_csr_ptr(alpha, A.GetImagPtr(), A.GetImagInd(), A.GetImagData(),
386 B.GetImagPtr(), B.GetImagInd(), B.GetImagData(), B.GetM(),
387 PtrImag, IndImag, DataImag);
389 B.SetData(B.GetM(), B.GetN(), DataReal, PtrReal, IndReal,
390 DataImag, PtrImag, IndImag);
395 template<
class T0,
class T1,
class Allocator1,
396 class T2,
class Allocator2>
405 VectFull, Allocator2> DataReal, DataImag;
407 Add_csr_ptr(alpha, A.GetRealPtr(), A.GetRealInd(), A.GetRealData(),
408 B.GetRealPtr(), B.GetRealInd(), B.GetRealData(), B.GetM(),
409 PtrReal, IndReal, DataReal);
411 Add_csr_ptr(alpha, A.GetImagPtr(), A.GetImagInd(), A.GetImagData(),
412 B.GetImagPtr(), B.GetImagInd(), B.GetImagData(), B.GetM(),
413 PtrImag, IndImag, DataImag);
415 B.SetData(B.GetM(), B.GetN(), DataReal, PtrReal, IndReal,
416 DataImag, PtrImag, IndImag);
421 template<
class T0,
class T1,
class Allocator1,
422 class T2,
class Allocator2>
427 if (imag(alpha) != T0(0))
428 throw Undefined(
"Add(Matrix<RowSymComplexSparse>)",
429 "Function not implemented for complex scalars");
435 VectFull, Allocator2> DataReal, DataImag;
437 Add_csr_ptr(real(alpha), A.GetRealPtr(), A.GetRealInd(), A.GetRealData(),
438 B.GetRealPtr(), B.GetRealInd(), B.GetRealData(), B.GetM(),
439 PtrReal, IndReal, DataReal);
441 Add_csr_ptr(real(alpha), A.GetImagPtr(), A.GetImagInd(), A.GetImagData(),
442 B.GetImagPtr(), B.GetImagInd(), B.GetImagData(), B.GetM(),
443 PtrImag, IndImag, DataImag);
445 B.SetData(B.GetM(), B.GetN(), DataReal, PtrReal, IndReal,
446 DataImag, PtrImag, IndImag);
451 template<
class T0,
class T1,
class Allocator1,
452 class T2,
class Allocator2>
457 if (imag(alpha) != T0(0))
458 throw Undefined(
"Add(Matrix<RowComplexSparse>)",
459 "Function not implemented for complex scalars");
465 VectFull, Allocator2> DataReal, DataImag;
467 Add_csr_ptr(real(alpha), A.GetRealPtr(), A.GetRealInd(), A.GetRealData(),
468 B.GetRealPtr(), B.GetRealInd(), B.GetRealData(), B.GetM(),
469 PtrReal, IndReal, DataReal);
471 Add_csr_ptr(real(alpha), A.GetImagPtr(), A.GetImagInd(), A.GetImagData(),
472 B.GetImagPtr(), B.GetImagInd(), B.GetImagData(), B.GetM(),
473 PtrImag, IndImag, DataImag);
475 B.SetData(B.GetM(), B.GetN(), DataReal, PtrReal, IndReal,
476 DataImag, PtrImag, IndImag);
481 template<
class T0,
class T,
class Prop,
class Allocator>
485 for (
int i = 0; i < A.
GetM(); i++)
498 template<
class T0,
class T,
class Prop,
class Allocator>
502 if (imag(alpha) != T0(0))
503 throw Undefined(
"Mlt(Matrix<ArrayRowComplexSparse>)",
504 "Function not implemented for complex scalars");
506 for (
int i = 0; i < A.
GetM(); i++)
518 template<
class T0,
class T,
class Prop,
class Allocator>
522 for (
int i = 0; i < A.
GetM(); i++)
534 template<
class T0,
class T,
class Prop,
class Allocator>
538 if (imag(alpha) != T0(0))
539 throw Undefined(
"Mlt(Matrix<ArrayRowComplexSparse>)",
540 "Function not implemented for complex scalars");
542 for (
int i = 0; i < A.
GetM(); i++)
554 template<
class T0,
class T,
class Prop,
class Allocator>
558 typename ClassComplexType<T>::Treal* data_A = A.
GetRealData();
569 template<
class T0,
class T,
class Prop,
class Allocator>
573 if (imag(alpha) != T0(0))
574 throw Undefined(
"Mlt(Matrix<RowComplexSparse>)",
575 "Function not implemented for complex scalars");
577 typename ClassComplexType<T>::Treal* data_A = A.
GetRealData();
578 T0 alpha_r = real(alpha);
580 data_A[i] *= alpha_r;
584 data_A[i] *= alpha_r;
589 template<
class T0,
class T,
class Prop,
class Allocator>
593 typename ClassComplexType<T>::Treal* data_A = A.
GetRealData();
604 template<
class T0,
class T,
class Prop,
class Allocator>
608 if (imag(alpha) != T0(0))
609 throw Undefined(
"Mlt(Matrix<RowSymComplexSparse>)",
610 "Function not implemented for complex scalars");
612 typename ClassComplexType<T>::Treal* data_A = A.
GetRealData();
613 T0 alpha_r = real(alpha);
615 data_A[i] *= alpha_r;
619 data_A[i] *= alpha_r;
628 template<
class T,
class Prop,
class Allocator>
629 void ApplyInversePermutation(
Matrix<T, Prop,
634 IVect ind_tmp, iperm(m), rperm(m);
635 for (
int i = 0; i < m; i++)
644 for (
int i = 0; i < m; i++)
649 int i_ = row_perm(i);
652 int nr = A.GetRealRowSize(i2);
653 ind_tmp.Reallocate(nr);
654 for (
int j = 0; j < nr; j++)
655 ind_tmp(j) = col_perm(A.IndexReal(i2, j));
658 A.SwapRealRow(i2, i_);
659 A.ReplaceRealIndexRow(i_, ind_tmp);
661 int ni = A.GetImagRowSize(i2);
662 ind_tmp.Reallocate(ni);
663 for (
int j = 0; j < ni; j++)
664 ind_tmp(j) = col_perm(A.IndexImag(i2, j));
666 A.SwapImagRow(i2, i_);
667 A.ReplaceImagIndexRow(i_, ind_tmp);
671 int i_tmp = iperm(i_);
672 iperm(i_) = iperm(i2);
674 rperm(iperm(i_)) = i_;
675 rperm(iperm(i2)) = i2;
678 A.AssembleRealRow(i_);
679 A.AssembleImagRow(i_);
689 template<
class T,
class Prop,
class Allocator>
690 void ApplyInversePermutation(
Matrix<T, Prop,
697 long nnz_real = A.GetRealDataSize(), nnz_imag = A.GetImagDataSize();
698 IVect IndRow(nnz_real), IndCol(nnz_real);
707 for (
int i = 0; i < m; i++)
709 for (
int j = 0; j < A.GetRealRowSize(i); j++)
711 IndRow(k) = row_perm(i);
712 Val(k) = A.ValueReal(i,j);
713 IndCol(k) = col_perm(A.IndexReal(i, j));
714 if (IndCol(k) <= IndRow(k))
717 int ind_tmp = IndRow(k);
718 IndRow(k) = IndCol(k);
726 Sort(nnz_real, IndRow, IndCol, Val);
730 for (
int i = 0; i < m; i++)
732 long first_index = k;
734 while (k < nnz_real && IndRow(k) <= i)
737 int size_row = k - first_index;
741 A.ReallocateRealRow(i, size_row);
743 Sort(k, k+size_row-1, IndCol, Val);
744 for (
int j = 0; j < size_row; j++)
746 A.IndexReal(i,j) = IndCol(k);
747 A.ValueReal(i,j) = Val(k);
757 IndRow.Reallocate(nnz_imag);
758 IndCol.Reallocate(nnz_imag);
759 Val.Reallocate(nnz_imag);
766 for (
int i = 0; i < m; i++)
768 for (
int j = 0; j < A.GetImagRowSize(i); j++)
770 IndRow(k) = row_perm(i);
771 Val(k) = A.ValueImag(i,j);
772 IndCol(k) = col_perm(A.IndexImag(i,j));
773 if (IndCol(k) <= IndRow(k))
776 int ind_tmp = IndRow(k);
777 IndRow(k) = IndCol(k);
784 Sort(nnz_imag, IndRow, IndCol, Val);
788 for (
int i = 0; i < m; i++)
790 long first_index = k;
792 while (k < nnz_imag && IndRow(k) <= i)
794 int size_row = k - first_index;
798 A.ReallocateImagRow(i, size_row);
800 Sort(k, k+size_row-1, IndCol, Val);
801 for (
int j = 0; j < size_row; j++)
803 A.IndexImag(i,j) = IndCol(k);
804 A.ValueImag(i,j) = Val(k);
819 template<
class T,
class Prop,
class Allocator>
826 for (
int i = 0; i < row_perm.GetM(); i++)
827 inv_row_perm(row_perm(i)) = i;
829 for (
int i = 0; i < col_perm.GetM(); i++)
830 inv_col_perm(col_perm(i)) = i;
832 ApplyInversePermutation(A, inv_row_perm, inv_col_perm);
841 template<
class T,
class Prop,
class Allocator>
void
847 for (
int i = 0; i < row_perm.GetM(); i++)
848 inv_row_perm(row_perm(i)) = i;
850 ApplyInversePermutation(A, inv_row_perm, inv_row_perm);
858 template<
class Prop,
class T1,
class Allocator1,
859 class T2,
class Allocator2,
class T3,
class Allocator3>
866 for (
int i = 0; i < m; i++ )
868 for (
int j = 0; j < A.GetRealRowSize(i); j++ )
869 A.ValueReal(i,j) *= scale_left(i) * scale_right(A.IndexReal(i, j));
871 for (
int j = 0; j < A.GetImagRowSize(i); j++ )
872 A.ValueImag(i,j) *= scale_left(i) * scale_right(A.IndexImag(i, j));
881 template<
class Prop,
class T1,
class Allocator1,
882 class T2,
class Allocator2,
class T3,
class Allocator3>
888 for (
int i = 0; i < m; i++ )
890 for (
int j = 0; j < A.GetRealRowSize(i); j++ )
891 A.ValueReal(i,j) *= scale_left(i) * scale_right(A.IndexReal(i, j));
893 for (
int j = 0; j < A.GetImagRowSize(i); j++ )
894 A.ValueImag(i,j) *= scale_left(i) * scale_right(A.IndexImag(i, j));
903 template<
class T1,
class Allocator1,
904 class Prop,
class T2,
class Allocator2>
909 for (
int i = 0; i < m; i++ )
911 for (
int j = 0; j < A.GetRealRowSize(i); j++ )
912 A.ValueReal(i,j) *= scale(i);
914 for (
int j = 0; j < A.GetImagRowSize(i); j++ )
915 A.ValueImag(i,j) *= scale(i);
924 template<
class T1,
class Allocator1,
925 class Prop,
class T2,
class Allocator2>
931 for (
int i = 0; i < m; i++ )
933 for (
int j = 0; j < A.GetRealRowSize(i); j++ )
934 A.ValueReal(i,j) *= scale(A.IndexReal(i, j));
936 for (
int j = 0; j < A.GetImagRowSize(i); j++ )
937 A.ValueImag(i,j) *= scale(A.IndexImag(i, j));
946 template<
class Prop,
class T1,
class Allocator1,
947 class T2,
class Allocator2,
class T3,
class Allocator3>
953 long* ptr_real = A.GetRealPtr();
954 int* ind_real = A.GetRealInd();
955 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
956 long* ptr_imag = A.GetImagPtr();
957 int* ind_imag = A.GetImagInd();
958 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
959 for (
int i = 0; i < m; i++ )
961 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
962 data_real[j] *= scale_left(i) * scale_right(ind_real[j]);
964 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
965 data_imag[j] *= scale_left(i) * scale_right(ind_imag[j]);
974 template<
class Prop,
class T1,
class Allocator1,
975 class T2,
class Allocator2,
class T3,
class Allocator3>
981 long* ptr_real = A.GetRealPtr();
982 int* ind_real = A.GetRealInd();
983 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
984 long* ptr_imag = A.GetImagPtr();
985 int* ind_imag = A.GetImagInd();
986 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
987 for (
int i = 0; i < m; i++ )
989 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++ )
990 data_real[j] *= scale_left(i) * scale_right(ind_real[j]);
992 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++ )
993 data_imag[j] *= scale_left(i) * scale_right(ind_imag[j]);
1002 template<
class T1,
class Allocator1,
1003 class Prop,
class T2,
class Allocator2>
1008 long* ptr_real = A.GetRealPtr();
1009 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
1010 long* ptr_imag = A.GetImagPtr();
1011 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
1012 for (
int i = 0; i < m; i++ )
1014 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++ )
1015 data_real[j] *= scale(i);
1017 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++ )
1018 data_imag[j] *= scale(i);
1027 template<
class T1,
class Allocator1,
1028 class Prop,
class T2,
class Allocator2>
1033 long* ptr_real = A.GetRealPtr();
1034 int* ind_real = A.GetRealInd();
1035 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
1036 long* ptr_imag = A.GetImagPtr();
1037 int* ind_imag = A.GetImagInd();
1038 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
1039 for (
int i = 0; i < m; i++ )
1041 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++ )
1042 data_real[j] *= scale(ind_real[j]);
1044 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++ )
1045 data_imag[j] *= scale(ind_imag[j]);
1051 template<
class T,
class Allocator>
1067 for (
int i = 0; i < m; i++)
1068 for (
int j = 0; j < A.GetRealRowSize(i); j++)
1069 ptr_r(A.IndexReal(i, j))++;
1072 for (
int i = 0; i < m; i++)
1073 for (
int j = 0; j < A.GetImagRowSize(i); j++)
1074 ptr_i(A.IndexImag(i, j))++;
1076 for (
int i = 0; i < n; i++)
1078 B.ReallocateRealRow(i, ptr_r(i));
1079 B.ReallocateImagRow(i, ptr_i(i));
1085 for (
int i = 0; i < m; i++)
1087 for (
int jp = 0; jp < A.GetRealRowSize(i); jp++)
1089 int j = A.IndexReal(i, jp);
1092 B.ValueReal(j, k) = A.ValueReal(i, jp);
1093 B.IndexReal(j, k) = i;
1096 for (
int jp = 0; jp < A.GetImagRowSize(i); jp++)
1098 int j = A.IndexImag(i, jp);
1101 B.ValueImag(j, k) = A.ValueImag(i, jp);
1102 B.IndexImag(j, k) = i;
1112 template<
class T,
class Allocator>
1120 long* ptr_real = A.GetRealPtr();
1121 int* ind_real = A.GetRealInd();
1122 typename ClassComplexType<T>::Treal* data_real = A.GetRealData();
1123 long* ptr_imag = A.GetImagPtr();
1124 int* ind_imag = A.GetImagInd();
1125 typename ClassComplexType<T>::Treal* data_imag = A.GetImagData();
1131 for (
int i = 0; i < m; i++)
1132 for (
int j = ptr_real[i]; j < ptr_real[i+1]; j++)
1133 ptr_r(ind_real[j])++;
1136 for (
int i = 0; i < m; i++)
1137 for (
int j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
1138 ptr_i(ind_imag[j])++;
1140 typedef typename ClassComplexType<T>::Treal Treal;
1144 Vector<int> IndReal(A.GetRealDataSize()), IndImag(A.GetImagDataSize());
1146 PtrReal(0) = 0; PtrImag(0) = 0;
1147 for (
int i = 0; i < n; i++)
1149 PtrReal(i+1) = PtrReal(i) + ptr_r(i);
1150 PtrImag(i+1) = PtrImag(i) + ptr_i(i);
1156 for (
int i = 0; i < m; i++)
1158 for (
long jp = ptr_real[i]; jp < ptr_real[i+1]; jp++)
1160 int j = ind_real[jp];
1162 ValReal(PtrReal(j) + k) = data_real[jp];
1163 IndReal(PtrReal(j) + k) = i;
1167 for (
long jp = ptr_imag[i]; jp < ptr_imag[i+1]; jp++)
1169 int j = ind_imag[jp];
1171 ValImag(PtrImag(j) + k) = data_imag[jp];
1172 IndImag(PtrImag(j) + k) = i;
1178 for (
int i = 0; i < n; i++)
1180 Sort(PtrReal(i), PtrReal(i+1)-1, IndReal, ValReal);
1181 Sort(PtrImag(i), PtrImag(i+1)-1, IndImag, ValImag);
1184 B.SetData(n, m, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
1193 template <
class T,
class Prop,
class Allocator>
1194 typename ClassComplexType<T>::Treal
1197 typename ClassComplexType<T>::Treal res(0);
1198 for (
int i = 0; i < A.
GetM(); i++)
1205 while ( ji < size_imag && A.
IndexImag(i, ji) < k)
1207 res = max(res, abs(A.
ValueImag(i, ji)));
1211 if ( ji < size_imag && (A.
IndexImag(i, ji) == k))
1221 while (ji < size_imag)
1223 res = max(res, abs(A.
ValueImag(i, ji)));
1237 template <
class T,
class Prop,
class Allocator>
1238 typename ClassComplexType<T>::Treal
1241 typename ClassComplexType<T>::Treal res(0);
1244 typename ClassComplexType<T>::Treal* data_real = A.
GetRealData();
1247 typename ClassComplexType<T>::Treal* data_imag = A.
GetImagData();
1248 for (
int i = 0; i < A.
GetM(); i++)
1250 long ji = ptr_imag[i];
1251 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
1253 int k = ind_real[j];
1254 while ( ji < ptr_imag[i+1] && ind_imag[ji] < k)
1256 res = max(res, abs(data_imag[ji]));
1260 if ( ji < ptr_imag[i+1] && (ind_imag[ji] == k))
1267 res = max(res, abs(data_real[j]));
1270 while (ji < ptr_imag[i+1])
1272 res = max(res, abs(data_imag[ji]));
1286 template <
class T,
class Prop,
class Allocator>
1287 typename ClassComplexType<T>::Treal
1292 for (
int i = 0; i < A.
GetM(); i++)
1299 while ( ji < size_imag && A.
IndexImag(i, ji) < k)
1305 if ( ji < size_imag && (A.
IndexImag(i, ji) == k))
1315 while (ji < size_imag)
1322 return sum.GetNormInf();
1331 template <
class T,
class Prop,
class Allocator>
1332 typename ClassComplexType<T>::Treal
1338 typename ClassComplexType<T>::Treal* data_real = A.
GetRealData();
1341 typename ClassComplexType<T>::Treal* data_imag = A.
GetImagData();
1343 for (
int i = 0; i < A.
GetM(); i++)
1345 long ji = ptr_imag[i];
1346 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
1348 int k = ind_real[j];
1349 while ( ji < ptr_imag[i+1] && ind_imag[ji] < k)
1351 sum(ind_imag[ji]) += abs(data_imag[ji]);
1355 if ( ji < ptr_imag[i+1] && (ind_imag[ji] == k))
1362 sum(k) += abs(data_real[j]);
1365 while (ji < ptr_imag[i+1])
1367 sum(ind_imag[ji]) += abs(data_imag[ji]);
1372 return sum.GetNormInf();
1381 template <
class T,
class Prop,
class Allocator>
1382 typename ClassComplexType<T>::Treal
1385 typename ClassComplexType<T>::Treal res(0), sum;
1386 for (
int i = 0; i < A.
GetM(); i++)
1394 while ( ji < size_imag && A.
IndexImag(i, ji) < k)
1400 if ( ji < size_imag && (A.
IndexImag(i, ji) == k))
1410 while (ji < size_imag)
1416 res = max(res, sum);
1428 template <
class T,
class Prop,
class Allocator>
1429 typename ClassComplexType<T>::Treal
1432 typename ClassComplexType<T>::Treal res(0), sum;
1435 typename ClassComplexType<T>::Treal* data_real = A.
GetRealData();
1438 typename ClassComplexType<T>::Treal* data_imag = A.
GetImagData();
1439 for (
int i = 0; i < A.
GetM(); i++)
1442 long ji = ptr_imag[i];
1443 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
1445 int k = ind_real[j];
1446 while ( ji < ptr_imag[i+1] && ind_imag[ji] < k)
1448 sum += abs(data_imag[ji]);
1452 if ( ji < ptr_imag[i+1] && (ind_imag[ji] == k))
1459 sum += abs(data_real[j]);
1462 while (ji < ptr_imag[i+1])
1464 sum += abs(data_imag[ji]);
1468 res = max(res, sum);
1480 template <
class T,
class Prop,
class Allocator>
1481 typename ClassComplexType<T>::Treal
1484 typename ClassComplexType<T>::Treal res(0);
1485 for (
int i = 0; i < A.
GetM(); i++)
1492 while ( ji < size_imag && A.
IndexImag(i, ji) < k)
1494 res = max(res, abs(A.
ValueImag(i, ji)));
1498 if ( ji < size_imag && (A.
IndexImag(i, ji) == k))
1508 while (ji < size_imag)
1510 res = max(res, abs(A.
ValueImag(i, ji)));
1524 template <
class T,
class Prop,
class Allocator>
1525 typename ClassComplexType<T>::Treal
1528 typename ClassComplexType<T>::Treal res(0);
1531 typename ClassComplexType<T>::Treal* data_real = A.
GetRealData();
1534 typename ClassComplexType<T>::Treal* data_imag = A.
GetImagData();
1535 for (
int i = 0; i < A.
GetM(); i++)
1537 long ji = ptr_imag[i];
1538 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
1540 int k = ind_real[j];
1541 while ( ji < ptr_imag[i+1] && ind_imag[ji] < k)
1543 res = max(res, abs(data_imag[ji]));
1547 if ( ji < ptr_imag[i+1] && (ind_imag[ji] == k))
1554 res = max(res, abs(data_real[j]));
1557 while (ji < ptr_imag[i+1])
1559 res = max(res, abs(data_imag[ji]));
1573 template <
class T,
class Prop,
class Allocator>
1574 typename ClassComplexType<T>::Treal
1577 typename ClassComplexType<T>::Treal val;
1580 for (
int i = 0; i < A.
GetM(); i++)
1587 while ( ji < size_imag && A.
IndexImag(i, ji) < k)
1597 if ( ji < size_imag && (A.
IndexImag(i, ji) == k))
1616 while (ji < size_imag)
1627 return sum.GetNormInf();
1636 template <
class T,
class Prop,
class Allocator>
1637 typename ClassComplexType<T>::Treal
1643 typename ClassComplexType<T>::Treal* data_real = A.
GetRealData();
1646 typename ClassComplexType<T>::Treal* data_imag = A.
GetImagData();
1648 typename ClassComplexType<T>::Treal val;
1649 for (
int i = 0; i < A.
GetM(); i++)
1651 long ji = ptr_imag[i];
1652 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
1654 int k = ind_real[j];
1655 while ( ji < ptr_imag[i+1] && ind_imag[ji] < k)
1657 val = abs(data_imag[ji]);
1658 sum(ind_imag[ji]) += val;
1659 if (ind_imag[ji] != i)
1665 if ( ji < ptr_imag[i+1] && (ind_imag[ji] == k))
1677 val = abs(data_real[j]);
1684 while (ji < ptr_imag[i+1])
1686 val = abs(data_imag[ji]);
1687 sum(ind_imag[ji]) += val;
1688 if (ind_imag[ji] != i)
1695 return sum.GetNormInf();
1704 template <
class T,
class Prop,
class Allocator>
1705 typename ClassComplexType<T>::Treal
1717 template <
class T,
class Prop,
class Allocator>
1718 typename ClassComplexType<T>::Treal
1726 template<
class T,
class Prop,
class Allocator>
1727 typename ClassComplexType<T>::Treal
1730 typename ClassComplexType<T>::Treal res(0);
1731 for (
int i = 0; i < A.
GetM(); i++)
1746 template<
class T,
class Prop,
class Allocator>
1747 typename ClassComplexType<T>::Treal
1750 typename ClassComplexType<T>::Treal res(0);
1751 for (
int i = 0; i < A.
GetM(); i++)
1776 template<
class T,
class Prop,
class Allocator>
1779 for (
int i = 0; i < A.
GetM(); i++)
1786 template<
class T,
class Prop,
class Allocator>
1789 for (
int i = 0; i < A.
GetM(); i++)
1796 template<
class T,
class Prop,
class Allocator>
1799 typename ClassComplexType<T>::Treal* data = A.
GetImagData();
1806 template<
class T,
class Prop,
class Allocator>
1809 typename ClassComplexType<T>::Treal* data = A.
GetImagData();
1816 template<
class T,
class Allocator>
1827 template<
class T,
class Allocator>
1836 template<
class T,
class Allocator>
1843 template<
class T,
class Allocator>
1854 template<
class T,
class Allocator>
1863 template<
class T,
class Allocator>
1870 template<
class T,
class Prop,
class Allocator,
class T0>
1879 template<
class T,
class Prop,
class Allocator,
class T0>
1892 template<
class T1,
class Prop,
class Allocator>
1896 int m = col_number.GetM();
1898 IVect index(A.GetM()); index.Fill(-1);
1899 for (
int i = 0; i < m; i++)
1900 index(col_number(i)) = i;
1903 for (
int i = 0; i < A.GetM(); i++)
1914 for (
int i = 0; i < A.GetM(); i++)
1916 bool something_to_remove =
false;
1917 for (
int j = 0; j < A.GetRealRowSize(i); j++)
1918 if (index(A.IndexReal(i,j)) != -1)
1919 something_to_remove =
true;
1921 if (something_to_remove)
1924 for (
int j = 0; j < A.GetRealRowSize(i); j++)
1925 if (index(A.IndexReal(i,j)) == -1)
1927 A.IndexReal(i, nb) = A.IndexReal(i, j);
1928 A.ValueReal(i, nb) = A.ValueReal(i, j);
1932 A.ResizeRealRow(i, nb);
1935 something_to_remove =
false;
1936 for (
int j = 0; j < A.GetImagRowSize(i); j++)
1937 if (index(A.IndexImag(i,j)) != -1)
1938 something_to_remove =
true;
1940 if (something_to_remove)
1943 for (
int j = 0; j < A.GetImagRowSize(i); j++)
1944 if (index(A.IndexImag(i,j)) == -1)
1946 A.IndexImag(i, nb) = A.IndexImag(i, j);
1947 A.ValueImag(i, nb) = A.ValueImag(i, j);
1951 A.ResizeImagRow(i, nb);
1962 template<
class T1,
class Prop,
class Allocator>
1966 int m = col_number.GetM();
1968 IVect index(A.GetM()); index.Fill(-1);
1969 for (
int i = 0; i < m; i++)
1970 index(col_number(i)) = i;
1972 for (
int i = 0; i < A.GetM(); i++)
1974 bool something_to_remove =
false;
1975 for (
int j = 0; j < A.GetRealRowSize(i); j++)
1976 if (index(A.IndexReal(i,j)) != -1)
1977 something_to_remove =
true;
1979 if (something_to_remove)
1982 for (
int j = 0; j < A.GetRealRowSize(i); j++)
1983 if (index(A.IndexReal(i,j)) == -1)
1985 A.IndexReal(i, nb) = A.IndexReal(i, j);
1986 A.ValueReal(i, nb) = A.ValueReal(i, j);
1990 A.ResizeRealRow(i, nb);
1993 something_to_remove =
false;
1994 for (
int j = 0; j < A.GetImagRowSize(i); j++)
1995 if (index(A.IndexImag(i,j)) != -1)
1996 something_to_remove =
true;
1998 if (something_to_remove)
2001 for (
int j = 0; j < A.GetImagRowSize(i); j++)
2002 if (index(A.IndexImag(i,j)) == -1)
2004 A.IndexImag(i, nb) = A.IndexImag(i, j);
2005 A.ValueImag(i, nb) = A.ValueImag(i, j);
2009 A.ResizeImagRow(i, nb);
2020 template<
class T1,
class Prop,
class Allocator>
2024 int m = A.GetM(), n = A.GetN();
2025 long nnz_real = A.GetRealIndSize();
2026 long nnz_imag = A.GetImagIndSize();
2027 long* ptr_real = A.GetRealPtr();
2028 int* ind_real = A.GetRealInd();
2029 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
2030 long* ptr_imag = A.GetImagPtr();
2031 int* ind_imag = A.GetImagInd();
2032 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
2034 ColToKeep.Fill(
true);
2035 for (
int i = 0; i < col_number.GetM(); i++)
2036 ColToKeep(col_number(i)) =
false;
2038 for (
long i = 0; i < A.GetRealIndSize(); i++)
2039 if (!ColToKeep(ind_real[i]))
2042 for (
long i = 0; i < A.GetImagIndSize(); i++)
2043 if (!ColToKeep(ind_imag[i]))
2046 if ((nnz_real == A.GetRealIndSize()) && (nnz_imag == A.GetImagIndSize()))
2052 VectFull, Allocator> ValReal(nnz_real), ValImag(nnz_imag);
2054 PtrReal(0) = 0; PtrImag(0) = 0;
2055 for (
int i = 0; i < m; i++)
2057 long jA = PtrReal(i);
int size_row = 0;
2058 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2059 if (ColToKeep(ind_real[j]))
2061 IndReal(jA) = ind_real[j];
2062 ValReal(jA) = data_real[j];
2066 PtrReal(i+1) = PtrReal(i) + size_row;
2068 jA = PtrImag(i); size_row = 0;
2069 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2070 if (ColToKeep(ind_imag[j]))
2072 IndImag(jA) = ind_imag[j];
2073 ValImag(jA) = data_imag[j];
2077 PtrImag(i+1) = PtrImag(i) + size_row;
2080 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
2089 template<
class T1,
class Prop,
class Allocator>
2093 int m = A.GetM(), n = A.GetN();
2094 long nnz_real = A.GetRealIndSize();
2095 long* ptr_real = A.GetRealPtr();
2096 int* ind_real = A.GetRealInd();
2097 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
2098 long nnz_imag = A.GetImagIndSize();
2099 long* ptr_imag = A.GetImagPtr();
2100 int* ind_imag = A.GetImagInd();
2101 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
2103 ColToKeep.Fill(
true);
2104 for (
int i = 0; i < col_number.GetM(); i++)
2105 ColToKeep(col_number(i)) =
false;
2107 for (
int i = 0; i < m; i++)
2111 nnz_real -= ptr_real[i+1] - ptr_real[i];
2112 nnz_imag -= ptr_imag[i+1] - ptr_imag[i];
2116 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2117 if (!ColToKeep(ind_real[j]))
2120 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2121 if (!ColToKeep(ind_imag[j]))
2126 if ((nnz_real == A.GetRealIndSize()) && (nnz_imag == A.GetImagIndSize()))
2132 VectFull, Allocator> ValReal(nnz_real), ValImag(nnz_imag);
2134 PtrReal(0) = 0; PtrImag(0) = 0;
2135 for (
int i = 0; i < m; i++)
2137 long jA = PtrReal(i), size_row = 0;
2139 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2140 if (ColToKeep(ind_real[j]))
2142 IndReal(jA) = ind_real[j];
2143 ValReal(jA) = data_real[j];
2147 PtrReal(i+1) = PtrReal(i) + size_row;
2149 jA = PtrImag(i); size_row = 0;
2151 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2152 if (ColToKeep(ind_imag[j]))
2154 IndImag(jA) = ind_imag[j];
2155 ValImag(jA) = data_imag[j];
2159 PtrImag(i+1) = PtrImag(i) + size_row;
2162 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
2171 template<
class T1,
class Prop,
class Allocator>
2175 EraseCol(col_number, A);
2184 template<
class T1,
class Prop,
class Allocator>
2188 for (
int i = 0; i < col_number.GetM(); i++)
2190 A.ClearRealRow(col_number(i));
2191 A.ClearImagRow(col_number(i));
2201 template<
class T1,
class Prop,
class Allocator>
2205 int m = A.GetM(), n = A.GetN();
2206 long nnz_real = A.GetRealIndSize();
2207 long* ptr_real = A.GetRealPtr();
2208 int* ind_real = A.GetRealInd();
2209 typename ClassComplexType<T1>::Treal* data_real = A.GetRealData();
2210 long nnz_imag = A.GetImagIndSize();
2211 long* ptr_imag = A.GetImagPtr();
2212 int* ind_imag = A.GetImagInd();
2213 typename ClassComplexType<T1>::Treal* data_imag = A.GetImagData();
2215 RowToKeep.Fill(
true);
2216 for (
int i = 0; i < col_number.GetM(); i++)
2217 RowToKeep(col_number(i)) =
false;
2219 for (
int i = 0; i < m; i++)
2222 nnz_real -= ptr_real[i+1] - ptr_real[i];
2223 nnz_imag -= ptr_imag[i+1] - ptr_imag[i];
2229 VectFull, Allocator> ValReal(nnz_real), ValImag(nnz_imag);
2231 PtrReal(0) = 0; PtrImag(0) = 0;
2232 for (
int i = 0; i < m; i++)
2236 int size_row = ptr_real[i+1] - ptr_real[i];
2237 for (
int j = 0; j < size_row; j++)
2239 IndReal(PtrReal(i) + j) = ind_real[ptr_real[i] + j];
2240 ValReal(PtrReal(i) + j) = data_real[ptr_real[i] + j];
2243 PtrReal(i+1) = PtrReal(i) + size_row;
2245 size_row = ptr_imag[i+1] - ptr_imag[i];
2246 for (
int j = 0; j < size_row; j++)
2248 IndImag(PtrImag(i) + j) = ind_imag[ptr_imag[i] + j];
2249 ValImag(PtrImag(i) + j) = data_imag[ptr_imag[i] + j];
2252 PtrImag(i+1) = PtrImag(i) + size_row;
2256 PtrReal(i+1) = PtrReal(i);
2257 PtrImag(i+1) = PtrImag(i);
2261 A.SetData(m, n, ValReal, PtrReal, IndReal, ValImag, PtrImag, IndImag);
2270 template<
class T1,
class Prop,
class Allocator>
2274 EraseCol(col_number, A);
2285 void GetRowSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale_left,
2289 diagonal_scale_left.Reallocate(n);
2290 diagonal_scale_left.Fill(0);
2291 for (
int i = 0; i < n; i++)
2293 for (
int j = 0; j < mat.GetRealRowSize(i); j++)
2295 diagonal_scale_left(i) += abs(mat.ValueReal(i,j));
2296 if (i != mat.IndexReal(i,j))
2297 diagonal_scale_left(mat.IndexReal(i,j))
2298 += abs(mat.ValueReal(i,j));
2301 for (
int j = 0; j < mat.GetImagRowSize(i); j++)
2303 diagonal_scale_left(i) += abs(mat.ValueImag(i,j));
2304 if (i != mat.IndexImag(i,j))
2305 diagonal_scale_left(mat.IndexImag(i,j))
2306 += abs(mat.ValueImag(i,j));
2319 void GetRowSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale_left,
2323 diagonal_scale_left.Reallocate(n);
2324 diagonal_scale_left.Fill(0);
2325 for (
int i = 0; i < n; i++)
2327 for (
int j = 0; j < mat.GetRealRowSize(i); j++)
2328 diagonal_scale_left(i) += abs(mat.ValueReal(i,j));
2330 for (
int j = 0; j < mat.GetImagRowSize(i); j++)
2331 diagonal_scale_left(i) += abs(mat.ValueImag(i,j));
2343 void GetRowSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale_left,
2347 diagonal_scale_left.Reallocate(n);
2348 diagonal_scale_left.Fill(0);
2349 long* ptr_real = mat.GetRealPtr();
2350 int* ind_real = mat.GetRealInd();
2351 typename ClassComplexType<T>::Treal* data_real = mat.GetRealData();
2352 long* ptr_imag = mat.GetImagPtr();
2353 int* ind_imag = mat.GetImagInd();
2354 typename ClassComplexType<T>::Treal* data_imag = mat.GetImagData();
2355 for (
int i = 0; i < n; i++)
2357 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2359 diagonal_scale_left(i) += abs(data_real[j]);
2360 if (i != ind_real[j])
2361 diagonal_scale_left(ind_real[j]) += abs(data_real[j]);
2364 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2366 diagonal_scale_left(i) += abs(data_imag[j]);
2367 if (i != ind_imag[j])
2368 diagonal_scale_left(ind_imag[j]) += abs(data_imag[j]);
2381 void GetRowSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale_left,
2385 diagonal_scale_left.Reallocate(n);
2386 diagonal_scale_left.Fill(0);
2387 long* ptr_real = mat.GetRealPtr();
2388 typename ClassComplexType<T>::Treal* data_real = mat.GetRealData();
2389 long* ptr_imag = mat.GetImagPtr();
2390 typename ClassComplexType<T>::Treal* data_imag = mat.GetImagData();
2391 for (
int i = 0; i < n; i++)
2393 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2394 diagonal_scale_left(i) += abs(data_real[j]);
2396 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2397 diagonal_scale_left(i) += abs(data_imag[j]);
2409 void GetColSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale,
2412 GetRowSum(diagonal_scale, mat);
2423 void GetColSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale,
2427 diagonal_scale.Reallocate(mat.GetN());
2428 diagonal_scale.Fill(0);
2429 for (
int i = 0; i < n; i++)
2431 for (
int j = 0; j < mat.GetRealRowSize(i); j++)
2432 diagonal_scale(mat.IndexReal(i, j)) += abs(mat.ValueReal(i,j));
2434 for (
int j = 0; j < mat.GetImagRowSize(i); j++)
2435 diagonal_scale(mat.IndexImag(i, j)) += abs(mat.ValueImag(i,j));
2447 void GetColSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale,
2450 GetRowSum(diagonal_scale, mat);
2461 void GetColSum(
Vector<
typename ClassComplexType<T>::Treal>& diagonal_scale,
2465 diagonal_scale.Reallocate(mat.GetN());
2466 diagonal_scale.Fill(0);
2467 long* ptr_real = mat.GetRealPtr();
2468 int* ind_real = mat.GetRealInd();
2469 typename ClassComplexType<T>::Treal* data_real = mat.GetRealData();
2470 long* ptr_imag = mat.GetImagPtr();
2471 int* ind_imag = mat.GetImagInd();
2472 typename ClassComplexType<T>::Treal* data_imag = mat.GetImagData();
2473 for (
int i = 0; i < n; i++)
2475 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2476 diagonal_scale(ind_real[j]) += abs(data_real[j]);
2478 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2479 diagonal_scale(ind_imag[j]) += abs(data_imag[j]);
2494 void GetRowColSum(
Vector<
typename ClassComplexType<T>::Treal>& sum_row,
2495 Vector<
typename ClassComplexType<T>::Treal>& sum_col,
2498 GetRowSum(sum_row, mat);
2513 void GetRowColSum(
Vector<
typename ClassComplexType<T>::Treal>& sum_row,
2514 Vector<
typename ClassComplexType<T>::Treal>& sum_col,
2518 sum_row.Reallocate(n);
2519 sum_col.Reallocate(mat.GetN());
2522 for (
int i = 0; i < n; i++)
2524 for (
int j = 0; j < mat.GetRealRowSize(i); j++)
2526 sum_row(i) += abs(mat.ValueReal(i,j));
2527 sum_col(mat.IndexReal(i, j)) += abs(mat.ValueReal(i,j));
2530 for (
int j = 0; j < mat.GetImagRowSize(i); j++)
2532 sum_row(i) += abs(mat.ValueImag(i,j));
2533 sum_col(mat.IndexImag(i, j)) += abs(mat.ValueImag(i,j));
2549 void GetRowColSum(
Vector<
typename ClassComplexType<T>::Treal>& sum_row,
2550 Vector<
typename ClassComplexType<T>::Treal>& sum_col,
2553 GetRowSum(sum_row, mat);
2568 void GetRowColSum(
Vector<
typename ClassComplexType<T>::Treal>& sum_row,
2569 Vector<
typename ClassComplexType<T>::Treal>& sum_col,
2573 sum_row.Reallocate(n);
2574 sum_col.Reallocate(mat.GetN());
2577 long* ptr_real = mat.GetRealPtr();
2578 int* ind_real = mat.GetRealInd();
2579 typename ClassComplexType<T>::Treal* data_real = mat.GetRealData();
2580 long* ptr_imag = mat.GetImagPtr();
2581 int* ind_imag = mat.GetImagInd();
2582 typename ClassComplexType<T>::Treal* data_imag = mat.GetImagData();
2583 for (
int i = 0; i < n; i++)
2585 for (
long j = ptr_real[i]; j < ptr_real[i+1]; j++)
2587 sum_row(i) += abs(data_real[j]);
2588 sum_col(ind_real[j]) += abs(data_real[j]);
2591 for (
long j = ptr_imag[i]; j < ptr_imag[i+1]; j++)
2593 sum_row(i) += abs(data_imag[j]);
2594 sum_col(ind_imag[j]) += abs(data_imag[j]);
2601 template<
class T0,
class Prop0,
class Allocator0,
2602 class T1,
class Allocator1>
2610 int m = A.GetM(), n = A.GetN();
2611 if ((m <= 0) || (n <= 0) || (row.GetM() <= 0) || (col.GetM() <= 0))
2613 RowNum.Clear(); ColNum.Clear(); Value.Clear();
2618 RowKept.Fill(
false); ColKept.Fill(
false);
2619 for (
int i = 0; i < row.GetM(); i++)
2620 RowKept(row(i)) =
true;
2622 for (
int i = 0; i < col.GetM(); i++)
2623 ColKept(col(i)) =
true;
2627 for (
int i = 0; i < A.GetM(); i++)
2631 int size_imag = A.GetImagRowSize(i);
2632 for (
int jr = 0; jr < A.GetRealRowSize(i); jr++)
2634 int jcol = A.IndexReal(i, jr);
2635 while ((ji < size_imag) && (A.IndexImag(i, ji) < jcol))
2637 if (ColKept(A.IndexImag(i, ji)))
2643 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2650 while (ji < size_imag)
2652 if (ColKept(A.IndexImag(i, ji)))
2659 RowNum.Reallocate(nnz);
2660 ColNum.Reallocate(nnz);
2661 Value.Reallocate(nnz);
2664 for (
int i = 0; i < A.GetM(); i++)
2668 int size_imag = A.GetImagRowSize(i);
2669 for (
int jr = 0; jr < A.GetRealRowSize(i); jr++)
2671 int jcol = A.IndexReal(i, jr);
2672 while ((ji < size_imag) && (A.IndexImag(i, ji) < jcol))
2674 if (ColKept(A.IndexImag(i, ji)))
2677 ColNum(nnz) = A.IndexImag(i, ji);
2678 Value(nnz) = T0(0, A.ValueImag(i, ji));
2685 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2692 = T0(A.ValueReal(i, jr), A.ValueImag(i, ji));
2704 Value(nnz) = T0(A.ValueReal(i, jr), 0);
2710 while (ji < size_imag)
2712 if (ColKept(A.IndexImag(i, ji)))
2715 ColNum(nnz) = A.IndexImag(i, ji);
2716 Value(nnz) = T0(0, A.ValueImag(i, ji));
2727 template<
class T0,
class Prop0,
class Allocator0,
2728 class T1,
class Allocator1>
2736 int m = A.GetM(), n = A.GetN();
2737 if ((m <= 0) || (n <= 0) || (row.GetM() <= 0) || (col.GetM() <= 0))
2739 RowNum.Clear(); ColNum.Clear(); Value.Clear();
2744 RowKept.Fill(
false); ColKept.Fill(
false);
2745 for (
int i = 0; i < row.GetM(); i++)
2746 RowKept(row(i)) =
true;
2748 for (
int i = 0; i < col.GetM(); i++)
2749 ColKept(col(i)) =
true;
2753 for (
int i = 0; i < A.GetM(); i++)
2756 int size_imag = A.GetImagRowSize(i);
2757 for (
int jr = 0; jr < A.GetRealRowSize(i); jr++)
2759 int jcol = A.IndexReal(i, jr);
2760 while ((ji < size_imag) && (A.IndexImag(i, ji) < jcol))
2762 if (ColKept(A.IndexImag(i, ji)) && RowKept(i))
2765 if (A.IndexImag(i, ji) != i)
2766 if (RowKept(A.IndexImag(i, ji)) && ColKept(i))
2772 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2775 if (ColKept(jcol) && RowKept(i))
2779 if (RowKept(jcol) && ColKept(i))
2783 while (ji < size_imag)
2785 if (ColKept(A.IndexImag(i, ji)) && RowKept(i))
2788 if (A.IndexImag(i, ji) != i)
2789 if (RowKept(A.IndexImag(i, ji)) && ColKept(i))
2796 RowNum.Reallocate(nnz);
2797 ColNum.Reallocate(nnz);
2798 Value.Reallocate(nnz);
2800 for (
int i = 0; i < A.GetM(); i++)
2803 int size_imag = A.GetImagRowSize(i);
2804 for (
int jr = 0; jr < A.GetRealRowSize(i); jr++)
2806 int jcol = A.IndexReal(i, jr);
2807 while ((ji < size_imag) && (A.IndexImag(i, ji) < jcol))
2809 if (ColKept(A.IndexImag(i, ji)) && RowKept(i))
2812 ColNum(nnz) = A.IndexImag(i, ji);
2813 Value(nnz) = T0(0, A.ValueImag(i, ji));
2817 if (A.IndexImag(i, ji) != i)
2818 if (RowKept(A.IndexImag(i, ji)) && ColKept(i))
2820 RowNum(nnz) = A.IndexImag(i, ji);
2822 Value(nnz) = T0(0, A.ValueImag(i, ji));
2829 if (ColKept(jcol) && RowKept(i))
2833 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2835 = T0(A.ValueReal(i, jr), A.ValueImag(i, ji));
2837 Value(nnz) = T0(A.ValueReal(i, jr), 0);
2843 if (RowKept(jcol) && ColKept(i))
2847 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2849 = T0(A.ValueReal(i, jr), A.ValueImag(i, ji));
2851 Value(nnz) = T0(A.ValueReal(i, jr), 0);
2856 if ((ji < size_imag) && (A.IndexImag(i, ji) == jcol))
2860 while (ji < size_imag)
2862 if (ColKept(A.IndexImag(i, ji)) && RowKept(i))
2865 ColNum(nnz) = A.IndexImag(i, ji);
2866 Value(nnz) = T0(0, A.ValueImag(i, ji));
2870 if (A.IndexImag(i, ji) != i)
2871 if (RowKept(A.IndexImag(i, ji)) && ColKept(i))
2873 RowNum(nnz) = A.IndexImag(i, ji);
2875 Value(nnz) = T0(0, A.ValueImag(i, ji));
2886 template<
class T0,
class Prop0,
class Allocator0,
2887 class T1,
class Allocator1>
2894 int m = A.GetM(), n = A.GetN();
2895 if ((m <= 0) || (n <= 0) || (row.GetM() <= 0) || (col.GetM() <= 0))
2897 RowNum.Clear(); ColNum.Clear(); Value.Clear();
2901 long* ptr_real = A.GetRealPtr();
2902 int* ind_real = A.GetRealInd();
2903 typename ClassComplexType<T0>::Treal* data_real = A.GetRealData();
2904 long* ptr_imag = A.GetImagPtr();
2905 int* ind_imag = A.GetImagInd();
2906 typename ClassComplexType<T0>::Treal* data_imag = A.GetImagData();
2909 RowKept.Fill(
false); ColKept.Fill(
false);
2910 for (
int i = 0; i < row.GetM(); i++)
2911 RowKept(row(i)) =
true;
2913 for (
int i = 0; i < col.GetM(); i++)
2914 ColKept(col(i)) =
true;
2918 for (
int i = 0; i < m; i++)
2921 long ji = ptr_imag[i];
2922 for (
long jr = ptr_real[i]; jr < ptr_real[i+1]; jr++)
2924 int jcol = ind_real[jr];
2925 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < jcol))
2927 if (ColKept(ind_imag[ji]))
2933 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
2940 while (ji < ptr_imag[i+1])
2942 if (ColKept(ind_imag[ji]))
2949 RowNum.Reallocate(nnz);
2950 ColNum.Reallocate(nnz);
2951 Value.Reallocate(nnz);
2954 for (
int i = 0; i < A.GetM(); i++)
2957 long ji = ptr_imag[i];
2958 for (
long jr = ptr_real[i]; jr < ptr_real[i+1]; jr++)
2960 int jcol = ind_real[jr];
2961 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < jcol))
2963 if (ColKept(ind_imag[ji]))
2966 ColNum(nnz) = ind_imag[ji];
2967 Value(nnz) = T0(0, data_imag[ji]);
2974 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
2980 Value(nnz) = T0(data_real[jr], data_imag[ji]);
2992 Value(nnz) = T0(data_real[jr], 0);
2998 while (ji < ptr_imag[i+1])
3000 if (ColKept(ind_imag[ji]))
3003 ColNum(nnz) = ind_imag[ji];
3004 Value(nnz) = T0(0, data_imag[ji]);
3015 template<
class T0,
class Prop0,
class Allocator0,
3016 class T1,
class Allocator1>
3024 int m = A.GetM(), n = A.GetN();
3025 if ((m <= 0) || (n <= 0) || (row.GetM() <= 0) || (col.GetM() <= 0))
3027 RowNum.Clear(); ColNum.Clear(); Value.Clear();
3031 long* ptr_real = A.GetRealPtr();
3032 int* ind_real = A.GetRealInd();
3033 typename ClassComplexType<T0>::Treal* data_real = A.GetRealData();
3034 long* ptr_imag = A.GetImagPtr();
3035 int* ind_imag = A.GetImagInd();
3036 typename ClassComplexType<T0>::Treal* data_imag = A.GetImagData();
3039 RowKept.Fill(
false); ColKept.Fill(
false);
3040 for (
int i = 0; i < row.GetM(); i++)
3041 RowKept(row(i)) =
true;
3043 for (
int i = 0; i < col.GetM(); i++)
3044 ColKept(col(i)) =
true;
3048 for (
int i = 0; i < m; i++)
3050 long ji = ptr_imag[i];
3051 for (
long jr = ptr_real[i]; jr < ptr_real[i+1]; jr++)
3053 int jcol = ind_real[jr];
3054 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < jcol))
3056 if (ColKept(ind_imag[ji]) && RowKept(i))
3059 if (ind_imag[ji] != i)
3060 if (RowKept(ind_imag[ji]) && ColKept(i))
3066 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
3069 if (ColKept(jcol) && RowKept(i))
3073 if (RowKept(jcol) && ColKept(i))
3077 while (ji < ptr_imag[i+1])
3079 if (ColKept(ind_imag[ji]) && RowKept(i))
3082 if (ind_imag[ji] != i)
3083 if (RowKept(ind_imag[ji]) && ColKept(i))
3090 RowNum.Reallocate(nnz);
3091 ColNum.Reallocate(nnz);
3092 Value.Reallocate(nnz);
3094 for (
int i = 0; i < m; i++)
3096 long ji = ptr_imag[i];
3097 for (
long jr = ptr_real[i]; jr < ptr_real[i+1]; jr++)
3099 int jcol = ind_real[jr];
3100 while ((ji < ptr_imag[i+1]) && (ind_imag[ji] < jcol))
3102 if (ColKept(ind_imag[ji]) && RowKept(i))
3105 ColNum(nnz) = ind_imag[ji];
3106 Value(nnz) = T0(0, data_imag[ji]);
3110 if (ind_imag[ji] != i)
3111 if (RowKept(ind_imag[ji]) && ColKept(i))
3113 RowNum(nnz) = ind_imag[ji];
3115 Value(nnz) = T0(0, data_imag[ji]);
3122 if (ColKept(jcol) && RowKept(i))
3126 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
3127 Value(nnz) = T0(data_real[jr], data_imag[ji]);
3129 Value(nnz) = T0(data_real[jr], 0);
3135 if (RowKept(jcol) && ColKept(i))
3139 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
3140 Value(nnz) = T0(data_real[jr], data_imag[ji]);
3142 Value(nnz) = T0(data_real[jr], 0);
3147 if ((ji < ptr_imag[i+1]) && (ind_imag[ji] == jcol))
3151 while (ji < ptr_imag[i+1])
3153 if (ColKept(ind_imag[ji]) && RowKept(i))
3156 ColNum(nnz) = ind_imag[ji];
3157 Value(nnz) = T0(0, data_imag[ji]);
3161 if (ind_imag[ji] != i)
3162 if (RowKept(ind_imag[ji]) && ColKept(i))
3164 RowNum(nnz) = ind_imag[ji];
3166 Value(nnz) = T0(0, data_imag[ji]);
3177 #define SELDON_FILE_FUNCTIONS_MATRIX_COMPLEX_CXX