1 #ifndef NPSTAT_ARRAYND_HH_ 2 #define NPSTAT_ARRAYND_HH_ 16 #include "Alignment/Geners/interface/ClassId.hh" 47 template <
typename Numeric,
unsigned StackLen=1U,
unsigned StackDim=10U>
50 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
97 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
104 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
108 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
113 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
128 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
130 const unsigned *indices,
unsigned nIndices);
133 template <
typename Num1,
unsigned Len1,
unsigned Dim1,
134 typename Num2,
unsigned Len2,
unsigned Dim2>
145 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2);
146 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3);
147 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
149 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
150 unsigned n4,
unsigned n5);
151 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
152 unsigned n4,
unsigned n5,
unsigned n6);
153 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
154 unsigned n4,
unsigned n5,
unsigned n6,
unsigned n7);
155 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
156 unsigned n4,
unsigned n5,
unsigned n6,
unsigned n7,
158 ArrayND(
unsigned n0,
unsigned n1,
unsigned n2,
unsigned n3,
159 unsigned n4,
unsigned n5,
unsigned n6,
unsigned n7,
160 unsigned n8,
unsigned n9);
177 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
181 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
197 Numeric&
value(
const unsigned *
index,
unsigned indexLen);
198 const Numeric&
value(
const unsigned *
index,
unsigned indexLen)
const;
206 Numeric&
valueAt(
const unsigned *
index,
unsigned indexLen);
207 const Numeric&
valueAt(
const unsigned *
index,
unsigned indexLen)
const;
224 unsigned indexLen)
const;
227 unsigned long linearIndex(
const unsigned*
idx,
unsigned idxLen)
const;
252 unsigned span(
unsigned dim)
const;
274 template <
typename Num2>
278 template <
unsigned Len2,
unsigned Dim2>
282 template <
unsigned Len2,
unsigned Dim2>
286 template <
unsigned Len2,
unsigned Dim2>
296 template <
unsigned Len2,
unsigned Dim2>
300 template <
unsigned Len2,
unsigned Dim2>
304 template <
typename Num2>
308 template <
typename Num2>
316 template <
typename Num2>
319 template <
typename Num2>
322 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
325 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
330 template <
typename Num3,
typename Num2,
unsigned Len2,
unsigned Dim2>
334 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
348 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
365 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
367 const unsigned* indexMap,
unsigned mapLen)
const;
381 template <
typename Num2>
388 template <
typename Num2>
399 template <
typename Num2>
406 template <
typename Num2>
413 template <
typename Num2>
414 Num2
cdfValue(
const unsigned *
index,
unsigned indexLen)
const;
427 template <
typename Num2>
434 Numeric
min(
unsigned *index,
unsigned indexLen)
const;
440 Numeric
max(
unsigned *index,
unsigned indexLen)
const;
451 Numeric&
closest(
const double *
x,
unsigned xDim);
452 const Numeric&
closest(
const double *x,
unsigned xDim)
const;
463 Numeric
interpolate1(
const double *x,
unsigned xDim)
const;
471 Numeric
interpolate3(
const double *x,
unsigned xDim)
const;
482 template <
class Functor>
492 template <
class Functor>
515 template <
class Functor>
544 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
549 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
574 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
576 const unsigned* thisCorner,
577 const unsigned* range,
578 const unsigned* otherCorner,
580 Functor binaryFunct);
587 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
589 const unsigned* thisCorner,
590 const unsigned* range,
591 const unsigned* otherCorner,
593 Functor binaryFunct);
599 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
601 const unsigned* thisCorner,
602 const unsigned* range,
603 const unsigned* otherCorner,
605 Functor binaryFunct);
611 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
613 const unsigned* thisCorner,
614 const unsigned* range,
615 const unsigned* otherCorner,
617 Functor binaryFunct);
625 template <
typename Num2,
typename Integer>
636 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
637 void exportSubrange(
const unsigned* fromCorner,
unsigned lenCorner,
641 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
642 void importSubrange(
const unsigned* fromCorner,
unsigned lenCorner,
650 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
660 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
672 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
674 const unsigned *fixedIndices,
675 const unsigned *fixedIndexValues,
676 unsigned nFixedIndices,
677 Functor binaryFunct);
687 template <
typename Num2,
class Functor>
689 const unsigned *fixedIndices,
690 const unsigned *fixedIndexValues,
691 unsigned nFixedIndices,
692 Functor binaryFunct);
696 unsigned nFixedIndices)
const;
699 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
701 const unsigned *fixedIndices,
702 const unsigned *fixedIndexValues,
703 unsigned nFixedIndices)
const 706 (
const_cast<ArrayND*
>(
this))->jointSliceScan(
707 *slice, fixedIndices, fixedIndexValues, nFixedIndices,
715 template <
typename Num2>
717 const unsigned *fixedIndices,
718 const unsigned *fixedIndexValues,
719 unsigned nFixedIndices)
const 721 (
const_cast<ArrayND*
>(
this))->jointMemSliceScan(
722 buffer, bufLen, fixedIndices, fixedIndexValues,
727 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
729 const unsigned *fixedIndices,
730 const unsigned *fixedIndexValues,
731 unsigned nFixedIndices)
734 fixedIndices, fixedIndexValues, nFixedIndices,
742 template <
typename Num2>
744 const unsigned *fixedIndices,
745 const unsigned *fixedIndexValues,
746 unsigned nFixedIndices)
749 fixedIndices, fixedIndexValues, nFixedIndices,
759 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
761 const unsigned *fixedIndices,
unsigned nFixedIndices,
762 Functor binaryFunct);
768 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
770 const unsigned *fixedIndices,
771 unsigned nFixedIndices)
774 fixedIndices, nFixedIndices,
787 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
790 const unsigned *projectedIndices,
791 unsigned nProjectedIndices)
const;
793 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
796 const unsigned *projectedIndices,
797 unsigned nProjectedIndices)
const;
806 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
809 const unsigned *projectedIndices,
810 unsigned nProjectedIndices)
const;
812 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
815 const unsigned *projectedIndices,
816 unsigned nProjectedIndices)
const;
818 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
821 const unsigned *projectedIndices,
822 unsigned nProjectedIndices)
const;
824 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
827 const unsigned *projectedIndices,
828 unsigned nProjectedIndices)
const;
836 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
837 void rotate(
const unsigned* shifts,
unsigned lenShifts,
845 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
859 Numeric&
operator()(
unsigned i0,
unsigned i1);
860 const Numeric&
operator()(
unsigned i0,
unsigned i1)
const;
862 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2);
863 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2)
const;
866 unsigned i2,
unsigned i3);
867 const Numeric&
operator()(
unsigned i0,
unsigned i1,
868 unsigned i2,
unsigned i3)
const;
871 unsigned i2,
unsigned i3,
unsigned i4);
872 const Numeric&
operator()(
unsigned i0,
unsigned i1,
873 unsigned i2,
unsigned i3,
unsigned i4)
const;
875 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
876 unsigned i3,
unsigned i4,
unsigned i5);
877 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
878 unsigned i3,
unsigned i4,
unsigned i5)
const;
880 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
881 unsigned i3,
unsigned i4,
unsigned i5,
883 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
884 unsigned i3,
unsigned i4,
unsigned i5,
887 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
888 unsigned i3,
unsigned i4,
unsigned i5,
889 unsigned i6,
unsigned i7);
890 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
891 unsigned i3,
unsigned i4,
unsigned i5,
892 unsigned i6,
unsigned i7)
const;
894 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
895 unsigned i3,
unsigned i4,
unsigned i5,
896 unsigned i6,
unsigned i7,
unsigned i8);
897 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
898 unsigned i3,
unsigned i4,
unsigned i5,
899 unsigned i6,
unsigned i7,
unsigned i8)
const;
901 Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
902 unsigned i3,
unsigned i4,
unsigned i5,
903 unsigned i6,
unsigned i7,
unsigned i8,
905 const Numeric&
operator()(
unsigned i0,
unsigned i1,
unsigned i2,
906 unsigned i3,
unsigned i4,
unsigned i5,
907 unsigned i6,
unsigned i7,
unsigned i8,
917 const Numeric&
at()
const;
919 Numeric&
at(
unsigned i0);
920 const Numeric&
at(
unsigned i0)
const;
922 Numeric&
at(
unsigned i0,
unsigned i1);
923 const Numeric&
at(
unsigned i0,
unsigned i1)
const;
925 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2);
926 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2)
const;
928 Numeric&
at(
unsigned i0,
unsigned i1,
929 unsigned i2,
unsigned i3);
930 const Numeric&
at(
unsigned i0,
unsigned i1,
931 unsigned i2,
unsigned i3)
const;
933 Numeric&
at(
unsigned i0,
unsigned i1,
934 unsigned i2,
unsigned i3,
unsigned i4);
935 const Numeric&
at(
unsigned i0,
unsigned i1,
936 unsigned i2,
unsigned i3,
unsigned i4)
const;
938 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
939 unsigned i3,
unsigned i4,
unsigned i5);
940 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
941 unsigned i3,
unsigned i4,
unsigned i5)
const;
943 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
944 unsigned i3,
unsigned i4,
unsigned i5,
946 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
947 unsigned i3,
unsigned i4,
unsigned i5,
950 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
951 unsigned i3,
unsigned i4,
unsigned i5,
952 unsigned i6,
unsigned i7);
953 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
954 unsigned i3,
unsigned i4,
unsigned i5,
955 unsigned i6,
unsigned i7)
const;
957 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
958 unsigned i3,
unsigned i4,
unsigned i5,
959 unsigned i6,
unsigned i7,
unsigned i8);
960 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
961 unsigned i3,
unsigned i4,
unsigned i5,
962 unsigned i6,
unsigned i7,
unsigned i8)
const;
964 Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
965 unsigned i3,
unsigned i4,
unsigned i5,
966 unsigned i6,
unsigned i7,
unsigned i8,
968 const Numeric&
at(
unsigned i0,
unsigned i1,
unsigned i2,
969 unsigned i3,
unsigned i4,
unsigned i5,
970 unsigned i6,
unsigned i7,
unsigned i8,
980 const Numeric&
cl()
const;
982 Numeric&
cl(
double x0);
983 const Numeric&
cl(
double x0)
const;
985 Numeric&
cl(
double x0,
double x1);
986 const Numeric&
cl(
double x0,
double x1)
const;
988 Numeric&
cl(
double x0,
double x1,
double x2);
989 const Numeric&
cl(
double x0,
double x1,
double x2)
const;
991 Numeric&
cl(
double x0,
double x1,
992 double x2,
double x3);
993 const Numeric&
cl(
double x0,
double x1,
994 double x2,
double x3)
const;
996 Numeric&
cl(
double x0,
double x1,
997 double x2,
double x3,
double x4);
998 const Numeric&
cl(
double x0,
double x1,
999 double x2,
double x3,
double x4)
const;
1001 Numeric&
cl(
double x0,
double x1,
double x2,
1002 double x3,
double x4,
double x5);
1003 const Numeric&
cl(
double x0,
double x1,
double x2,
1004 double x3,
double x4,
double x5)
const;
1006 Numeric&
cl(
double x0,
double x1,
double x2,
1007 double x3,
double x4,
double x5,
1009 const Numeric&
cl(
double x0,
double x1,
double x2,
1010 double x3,
double x4,
double x5,
1013 Numeric&
cl(
double x0,
double x1,
double x2,
1014 double x3,
double x4,
double x5,
1015 double x6,
double x7);
1016 const Numeric&
cl(
double x0,
double x1,
double x2,
1017 double x3,
double x4,
double x5,
1018 double x6,
double x7)
const;
1020 Numeric&
cl(
double x0,
double x1,
double x2,
1021 double x3,
double x4,
double x5,
1022 double x6,
double x7,
double x8);
1023 const Numeric&
cl(
double x0,
double x1,
double x2,
1024 double x3,
double x4,
double x5,
1025 double x6,
double x7,
double x8)
const;
1027 Numeric&
cl(
double x0,
double x1,
double x2,
1028 double x3,
double x4,
double x5,
1029 double x6,
double x7,
double x8,
1031 const Numeric&
cl(
double x0,
double x1,
double x2,
1032 double x3,
double x4,
double x5,
1033 double x6,
double x7,
double x8,
1039 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
1040 bool write(std::ostream& of)
const;
1045 static void restore(
const gs::ClassId&
id, std::istream&
in,
1071 const double* coeffs);
1074 template <
class Functor>
1076 Functor f,
unsigned*
farg);
1080 const Numeric*
base)
const;
1083 template <
typename Num1,
unsigned Len1,
unsigned Dim1,
1084 typename Num2,
unsigned Len2,
unsigned Dim2>
1086 unsigned long idx1,
unsigned long idx2,
1091 void contractLoop(
unsigned thisLevel,
unsigned resLevel,
1092 unsigned pos1,
unsigned pos2,
1093 unsigned long idxThis,
unsigned long idxRes,
1098 unsigned long idxThis,
unsigned long idxRes,
1102 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1104 unsigned long idx1,
unsigned long idx2,
1109 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1111 unsigned levelPr,
unsigned long idxPr,
1113 const unsigned* indexMap)
const;
1114 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1116 unsigned levelRes,
unsigned long idxRes,
1118 const unsigned* indexMap,
ArrayND&
res)
const;
1122 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1131 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1134 const unsigned* thisCorner,
1135 const unsigned* range,
1136 const unsigned* otherCorner,
1138 Functor binaryFunct);
1142 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1145 const unsigned* thisCorner,
1146 const unsigned* range,
1147 const unsigned* otherCorner,
1149 Functor binaryFunct);
1155 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1158 const unsigned* thisCorner,
1159 const unsigned* range,
1160 const unsigned* otherCorner,
1162 Functor binaryFunct);
1167 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1170 const unsigned* thisCorner,
1171 const unsigned* range,
1172 const unsigned* otherCorner,
1174 Functor binaryFunct);
1177 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1180 const unsigned *fixedIndices,
1181 const unsigned *fixedIndexValues,
1182 unsigned nFixedIndices)
const;
1186 unsigned long bufLen,
1187 const unsigned *fixedIndices,
1188 const unsigned *fixedIndexValues,
1189 unsigned nFixedIndices,
1190 unsigned long* sliceStrides)
const;
1193 template <
typename Num2,
class Functor>
1195 unsigned level1,
unsigned long idx1,
1196 Num2* sliceData,
const unsigned long* sliceStrides,
1197 const unsigned *fixedIndices,
1198 const unsigned *fixedIndexValues,
1199 unsigned nFixedIndices, Functor binaryFunctor);
1202 template <
typename Num2,
class Functor>
1205 const unsigned* projectedIndices,
1206 unsigned nProjectedIndices,
1207 Functor binaryFunct);
1209 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1211 unsigned level1,
unsigned long idx1,
1213 const unsigned *fixedIndices,
1214 unsigned nFixedIndices,
1215 Functor binaryFunct);
1218 template <
typename Num2>
1220 unsigned* currentIndex,
1222 const unsigned* projectedIndices,
1223 unsigned nProjectedIndices)
const;
1225 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
1226 typename Num3,
class Op>
1228 unsigned level1,
unsigned long idx1,
1229 unsigned* currentIndex,
1232 const unsigned* projectedIndices,
1233 unsigned nProjectedIndices, Op
fcn)
const;
1245 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
1246 typename Num3,
class Op>
1248 unsigned level1,
unsigned long idx1,
1251 const unsigned* projectedIndices,
1252 unsigned nProjectedIndices, Op
fcn)
const;
1254 template <
typename Num2>
1257 const unsigned* projectedIndices,
1258 unsigned nProjectedIndices)
const;
1260 template <
typename Num2,
typename Integer>
1262 unsigned* currentIndex,
1267 template <
typename Accumulator>
1269 const unsigned*
limit)
const;
1272 template <
typename Accumulator>
1275 unsigned long idxSlice,
1276 bool useTrapezoids);
1280 unsigned coordToIndex(
double coord,
unsigned idim)
const;
1283 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1286 const unsigned *projectedIndices,
1287 unsigned nProjectedIndices)
const;
1294 #include <algorithm> 1298 #include "Alignment/Geners/interface/GenericIO.hh" 1299 #include "Alignment/Geners/interface/IOIsUnsigned.hh" 1308 #define me_macro_check_loop_prerequisites(METHOD, INNERLOOP) \ 1309 template<typename Numeric, unsigned Len, unsigned Dim> \ 1310 template <typename Num2, unsigned Len2, unsigned Dim2, class Functor> \ 1311 void ArrayND<Numeric,Len,Dim>:: METHOD ( \ 1312 ArrayND<Num2, Len2, Dim2>& other, \ 1313 const unsigned* thisCorner, \ 1314 const unsigned* range, \ 1315 const unsigned* otherCorner, \ 1316 const unsigned arrLen, \ 1317 Functor binaryFunct) \ 1319 if (!shapeIsKnown_) throw npstat::NpstatInvalidArgument( \ 1320 "Initialize npstat::ArrayND before calling method \"" \ 1322 if (!other.shapeIsKnown_) throw npstat::NpstatInvalidArgument( \ 1323 "In npstat::ArrayND::" #METHOD ": uninitialized argument array");\ 1324 if (dim_ != other.dim_) throw npstat::NpstatInvalidArgument( \ 1325 "In npstat::ArrayND::" #METHOD ": incompatible argument array rank");\ 1326 if (arrLen != dim_) throw npstat::NpstatInvalidArgument( \ 1327 "In npstat::ArrayND::" #METHOD ": incompatible index length"); \ 1330 assert(thisCorner); \ 1332 assert(otherCorner); \ 1333 INNERLOOP (0U, 0UL, 0UL, thisCorner, range, \ 1334 otherCorner, other, binaryFunct); \ 1337 binaryFunct(localData_[0], other.localData_[0]); \ 1341 template<
typename Numeric,
unsigned Len,
unsigned Dim>
1342 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1344 unsigned level,
unsigned long idx0,
1346 const unsigned* thisCorner,
1347 const unsigned* range,
1348 const unsigned* otherCorner,
1350 Functor binaryFunct)
1352 const unsigned imax = range[
level];
1354 if (level ==
dim_ - 1)
1356 Numeric* left =
data_ + (idx0 + thisCorner[
level]);
1358 Num2* right = r.
data_ + (idx1 + otherCorner[
level]);
1361 for (
unsigned i=0;
i<imax && left<lMax && right<
rMax; ++
i)
1362 binaryFunct(*left++, *right++);
1367 const unsigned long leftMax = idx0 +
shape_[
level]*leftStride;
1368 idx0 += thisCorner[
level]*leftStride;
1370 const unsigned long rightMax = idx1 + r.
shape_[
level]*rightStride;
1371 idx1 += otherCorner[
level]*rightStride;
1373 for (
unsigned i=0;
i<imax && idx0 < leftMax && idx1 < rightMax;
1374 ++
i, idx0 += leftStride, idx1 += rightStride)
1376 otherCorner, r, binaryFunct);
1380 template<
typename Numeric,
unsigned Len,
unsigned Dim>
1381 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1383 unsigned level,
unsigned long idx0,
1385 const unsigned* thisCorner,
1386 const unsigned* range,
1387 const unsigned* otherCorner,
1389 Functor binaryFunct)
1391 const unsigned imax = range[
level];
1392 const unsigned leftShift = thisCorner[
level];
1394 const unsigned rightShift = otherCorner[
level];
1397 if (level ==
dim_ - 1)
1399 Numeric* left =
data_ + idx0;
1400 Num2* right = r.
data_ + idx1;
1401 for (
unsigned i=0;
i<imax; ++
i)
1402 binaryFunct(left[(
i+leftShift)%leftPeriod],
1403 right[(
i+rightShift)%rightPeriod]);
1409 for (
unsigned i=0;
i<imax; ++
i)
1411 level+1, idx0+((
i+leftShift)%leftPeriod)*leftStride,
1412 idx1+((
i+rightShift)%rightPeriod)*rightStride,
1413 thisCorner, range, otherCorner, r, binaryFunct);
1417 template<
typename Numeric,
unsigned Len,
unsigned Dim>
1418 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1420 unsigned level,
unsigned long idx0,
1422 const unsigned* thisCorner,
1423 const unsigned* range,
1424 const unsigned* otherCorner,
1426 Functor binaryFunct)
1428 const unsigned imax = range[
level];
1429 const unsigned rightShift = otherCorner[
level];
1432 if (level ==
dim_ - 1)
1434 Numeric* left =
data_ + (idx0 + thisCorner[
level]);
1436 Num2* right = r.
data_ + idx1;
1438 for (
unsigned i=0;
i<imax && left<lMax; ++
i)
1439 binaryFunct(*left++, right[(
i+rightShift)%rightPeriod]);
1444 const unsigned long leftMax = idx0 +
shape_[
level]*leftStride;
1445 idx0 += thisCorner[
level]*leftStride;
1448 for (
unsigned i=0;
i<imax && idx0 < leftMax; ++
i, idx0+=leftStride)
1451 idx1+((
i+rightShift)%rightPeriod)*rightStride,
1452 thisCorner, range, otherCorner, r, binaryFunct);
1456 template<
typename Numeric,
unsigned Len,
unsigned Dim>
1457 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1459 unsigned level,
unsigned long idx0,
1461 const unsigned* thisCorner,
1462 const unsigned* range,
1463 const unsigned* otherCorner,
1465 Functor binaryFunct)
1467 const unsigned imax = range[
level];
1468 const unsigned leftShift = thisCorner[
level];
1471 if (level ==
dim_ - 1)
1473 Numeric* left =
data_ + idx0;
1474 Num2* right = r.
data_ + (idx1 + otherCorner[
level]);
1477 for (
unsigned i=0;
i<imax && right<
rMax; ++
i)
1478 binaryFunct(left[(
i+leftShift)%leftPeriod], *right++);
1484 const unsigned long rightMax = idx1 + r.
shape_[
level]*rightStride;
1485 idx1 += otherCorner[
level]*rightStride;
1487 for (
unsigned i=0;
i<imax && idx1<rightMax; ++
i, idx1+=rightStride)
1489 level+1, idx0+((
i+leftShift)%leftPeriod)*leftStride,
1490 idx1, thisCorner, range, otherCorner, r, binaryFunct);
1499 template <typename Numeric,
unsigned StackLen,
unsigned StackDim>
1500 template <typename Num2,
unsigned Len2,
unsigned Dim2>
1502 unsigned long idx, const
unsigned levelPr,
unsigned long idxPr,
1504 const
unsigned* indexMap)
const 1506 Numeric
sum = Numeric();
1507 const unsigned long myStride =
strides_[indexMap[levelPr]];
1508 const unsigned imax = prior.shape_[levelPr];
1509 assert(imax ==
shape_[indexMap[levelPr]]);
1510 if (levelPr == prior.dim_ - 1)
1512 for (
unsigned i=0;
i<imax; ++
i)
1513 sum +=
data_[idx+
i*myStride]*prior.data_[idxPr++];
1517 const unsigned long priorStride = prior.strides_[levelPr];
1518 for (
unsigned i=0;
i<imax; ++
i)
1523 idxPr += priorStride;
1529 template <
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1530 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1532 const unsigned level,
unsigned long idx,
1533 const unsigned levelRes,
unsigned long idxRes,
1540 idx, 0
U, 0UL, prior, indexMap);
1542 result.
data_[idxRes] = res;
1549 bool mapped =
false;
1550 for (
unsigned i=0;
i<prior.
dim_; ++
i)
1551 if (level == indexMap[
i])
1558 prior, indexMap, result);
1563 const unsigned long resStride = result.
strides_[levelRes];
1564 for (
unsigned i=0; i<imax; ++
i)
1567 prior, indexMap, result);
1569 idxRes += resStride;
1575 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1576 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1580 const unsigned* indexMap,
const unsigned mapLen)
const 1583 "Initialize npstat::ArrayND before calling method \"marginalize\"");
1585 "In npstat::ArrayND::marginalize: incompatible argument array rank");
1586 const unsigned resultDim =
dim_ - prior.
dim_;
1590 "In npstat::ArrayND::marginalize: incompatible index map length");
1592 for (
unsigned i=0;
i<mapLen; ++
i)
1594 const unsigned thisInd = indexMap[
i];
1596 "In npstat::ArrayND::marginalize: " 1597 "incompatible argument array dimensions");
1599 "In npstat::ArrayND::marginalize: index map entry out of range");
1600 for (
unsigned j=0; j<
i; ++j)
1602 "In npstat::ArrayND::marginalize: " 1603 "duplicate entry in the index map");
1608 newShape.reserve(resultDim);
1609 for (
unsigned i=0;
i<
dim_; ++
i)
1611 bool mapped =
false;
1612 for (
unsigned j=0; j<mapLen; ++j)
1613 if (indexMap[j] ==
i)
1619 newShape.push_back(
shape_[
i]);
1623 assert(result.
dim_ == resultDim);
1624 bool calculated =
false;
1628 for (
unsigned i=0;
i<
dim_; ++
i)
1629 if (indexMap[
i] !=
i)
1636 Numeric
sum = Numeric();
1637 for (
unsigned long i=0;
i<
len_; ++
i)
1649 template<
typename Numeric,
unsigned Len,
unsigned Dim>
1651 const unsigned* sizes,
const unsigned dim)
1657 for (
unsigned i=0;
i<
dim_; ++
i)
1660 "In npstat::ArrayND::buildFromShapePtr: " 1661 "detected span of zero");
1665 for (
unsigned i=0;
i<
dim_; ++
i)
1684 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1685 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1688 const unsigned *fixedIndices,
const unsigned nFixedIndices)
1695 assert(fixedIndices);
1697 "In npstat::ArrayND slicing constructor: too many fixed indices");
1699 "In npstat::ArrayND slicing constructor: " 1700 "uninitialized argument array");
1703 for (
unsigned j=0; j<nFixedIndices; ++j)
1704 if (fixedIndices[j] >= slicedArray.
dim_)
1706 "constructor: fixed index out of range");
1711 for (
unsigned i=0;
i<slicedArray.
dim_; ++
i)
1714 for (
unsigned j=0; j<nFixedIndices; ++j)
1715 if (fixedIndices[j] ==
i)
1722 assert(idim <
dim_);
1726 assert(idim ==
dim_);
1731 for (
unsigned i=0;
i<
dim_; ++
i)
1748 new (
this)
ArrayND(slicedArray);
1752 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1754 const unsigned *fixedIndices,
const unsigned nFixedIndices)
const 1757 "Initialize npstat::ArrayND before calling method \"sliceShape\"");
1760 assert(fixedIndices);
1761 if (nFixedIndices >
dim_)
1763 "In npstat::ArrayND::sliceShape: too many fixed indices");
1764 for (
unsigned j=0; j<nFixedIndices; ++j)
1765 if (fixedIndices[j] >=
dim_)
1767 "fixed index out of range");
1769 sh.reserve(
dim_ - nFixedIndices);
1770 for (
unsigned i=0;
i<
dim_; ++
i)
1773 for (
unsigned j=0; j<nFixedIndices; ++j)
1774 if (fixedIndices[j] ==
i)
1788 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1789 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
1792 const unsigned *fixedIndices,
1793 const unsigned *fixedIndexValues,
1794 const unsigned nFixedIndices)
const 1796 if (!(nFixedIndices && nFixedIndices <=
dim_))
1798 "In npstat::ArrayND::verifySliceCompatibility: " 1799 "invalid number of fixed indices");
1801 "Initialize npstat::ArrayND before calling " 1802 "method \"verifySliceCompatibility\"");
1804 "In npstat::ArrayND::verifySliceCompatibility: " 1805 "uninitialized argument array");
1807 "In npstat::ArrayND::verifySliceCompatibility: " 1808 "incompatible argument array rank");
1809 assert(fixedIndices);
1810 assert(fixedIndexValues);
1812 for (
unsigned j=0; j<nFixedIndices; ++j)
1814 "In npstat::ArrayND::verifySliceCompatibility: " 1815 "fixed index out of range");
1818 unsigned long idx = 0UL;
1819 unsigned sliceDim = 0
U;
1820 for (
unsigned i=0;
i<
dim_; ++
i)
1823 for (
unsigned j=0; j<nFixedIndices; ++j)
1824 if (fixedIndices[j] ==
i)
1827 if (fixedIndexValues[j] >=
shape_[
i])
1829 "In npstat::ArrayND::verifySliceCompatibility: " 1830 "fixed index value out of range");
1838 "In npstat::ArrayND::verifySliceCompatibility: " 1839 "incompatible argument array dimensions");
1843 assert(sliceDim == slice.
dim_);
1847 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1850 const unsigned long bufLen,
1851 const unsigned *fixedIndices,
1852 const unsigned *fixedIndexValues,
1853 const unsigned nFixedIndices,
1854 unsigned long* sliceStrides)
const 1856 if (!(nFixedIndices && nFixedIndices <=
dim_))
1858 "In npstat::ArrayND::verifyBufferSliceCompatibility: " 1859 "invalid number of fixed indices");
1861 "Initialize npstat::ArrayND before calling " 1862 "method \"verifyBufferSliceCompatibility\"");
1863 assert(fixedIndices);
1864 assert(fixedIndexValues);
1866 for (
unsigned j=0; j<nFixedIndices; ++j)
1868 "In npstat::ArrayND::verifyBufferSliceCompatibility: " 1869 "fixed index out of range");
1872 unsigned long idx = 0UL;
1873 unsigned sliceDim = 0
U;
1874 for (
unsigned i=0;
i<
dim_; ++
i)
1877 for (
unsigned j=0; j<nFixedIndices; ++j)
1878 if (fixedIndices[j] ==
i)
1881 if (fixedIndexValues[j] >=
shape_[
i])
1883 "In npstat::ArrayND::verifyBufferSliceCompatibility:" 1884 " fixed index value out of range");
1889 sliceStrides[sliceDim++] =
shape_[
i];
1891 assert(sliceDim + nFixedIndices == dim_);
1894 unsigned long expectedBufLen = 1UL;
1897 unsigned long shapeJ = sliceStrides[sliceDim - 1];
1898 sliceStrides[sliceDim - 1] = 1UL;
1899 for (
unsigned j=sliceDim - 1; j>0; --j)
1901 const unsigned long nextStride = sliceStrides[j]*shapeJ;
1902 shapeJ = sliceStrides[j - 1];
1903 sliceStrides[j - 1] = nextStride;
1905 expectedBufLen = sliceStrides[0]*shapeJ;
1907 if (expectedBufLen != bufLen)
1909 "In npstat::ArrayND::verifyBufferSliceCompatibility: " 1910 "invalid memory buffer length");
1915 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1916 template <
typename Num2,
class Op>
1918 const unsigned level,
const unsigned long idx0,
1919 const unsigned level1,
const unsigned long idx1,
1920 Num2* sliceData,
const unsigned long* sliceStrides,
1921 const unsigned *fixedIndices,
1922 const unsigned *fixedIndexValues,
1923 const unsigned nFixedIndices,
1927 for (
unsigned j=0; j<nFixedIndices; ++j)
1928 if (fixedIndices[j] == level)
1935 sliceData, sliceStrides, fixedIndices,
1936 fixedIndexValues, nFixedIndices, fcn);
1942 if (level1 ==
dim_ - nFixedIndices - 1)
1945 Numeric* localData =
data_ + idx0;
1946 for (
unsigned i = 0;
i<imax; ++
i)
1947 fcn(localData[
i*stride], sliceData[
i]);
1951 const unsigned long stride2 = sliceStrides[level1];
1952 for (
unsigned i = 0;
i<imax; ++
i)
1954 level1+1, idx1+
i*stride2,
1955 sliceData, sliceStrides, fixedIndices,
1956 fixedIndexValues, nFixedIndices, fcn);
1961 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1962 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
1965 const unsigned *fixedIndices,
1966 const unsigned *fixedIndexValues,
1967 const unsigned nFixedIndices,
1968 Functor binaryFunct)
1971 slice, fixedIndices, fixedIndexValues, nFixedIndices);
1974 fixedIndices, fixedIndexValues,
1975 nFixedIndices, binaryFunct);
1980 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
1981 template <
typename Num2,
class Functor>
1983 Num2* slice,
const unsigned long len,
1984 const unsigned *fixedIndices,
const unsigned *fixedIndexValues,
1985 unsigned nFixedIndices, Functor binaryFunct)
1988 if (
dim_ > CHAR_BIT*
sizeof(
unsigned long))
1990 "In npstat::ArrayND::jointMemSliceScan: " 1991 "rank of this array is too large");
1992 unsigned long sliceStrides[CHAR_BIT*
sizeof(
unsigned long)];
1994 len, fixedIndices, fixedIndexValues, nFixedIndices, sliceStrides);
1995 if (
dim_ > nFixedIndices)
1997 fixedIndices, fixedIndexValues,
1998 nFixedIndices, binaryFunct);
2000 binaryFunct(
data_[idx], *slice);
2003 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2004 template <
typename Num2>
2006 const unsigned level,
unsigned long idx0,
2007 unsigned* currentIndex,
2009 const unsigned *projectedIndices,
2010 const unsigned nProjectedIndices)
const 2013 const unsigned idx = projectedIndices[
level];
2016 const bool last = (level == nProjectedIndices - 1);
2018 for (
unsigned i = 0;
i<imax; ++
i)
2020 currentIndex[
idx] =
i;
2025 projectedIndices, nProjectedIndices);
2030 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2031 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
2032 typename Num3,
class Op>
2034 const unsigned level,
const unsigned long idx0,
2035 const unsigned level1,
const unsigned long idx1,
2036 unsigned* currentIndex,
2039 const unsigned *projectedIndices,
2040 const unsigned nProjectedIndices, Op
fcn)
const 2051 assert(level1 == projection->
dim_);
2054 projectedIndices, nProjectedIndices);
2055 if (projection->
dim_)
2062 bool iterated =
false;
2063 for (
unsigned j=0; j<nProjectedIndices; ++j)
2064 if (projectedIndices[j] == level)
2073 currentIndex, projection, projector,
2074 projectedIndices, nProjectedIndices, fcn);
2082 const unsigned long stride2 = projection->
strides_[level1];
2083 for (
unsigned i = 0;
i<imax; ++
i)
2087 level1+1, idx1+
i*stride2,
2088 currentIndex, projection, projector,
2089 projectedIndices, nProjectedIndices, fcn);
2095 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2096 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
2099 const unsigned *projectedIndices,
2100 const unsigned nProjectedIndices)
const 2102 if (!(nProjectedIndices && nProjectedIndices <=
dim_))
2104 "In npstat::ArrayND::verifyProjectionCompatibility: " 2105 "invalid number of projected indices");
2107 "Initialize npstat::ArrayND before calling " 2108 "method \"verifyProjectionCompatibility\"");
2110 "In npstat::ArrayND::verifyProjectionCompatibility: " 2111 "uninitialized argument array");
2112 if (projection.
dim_ !=
dim_ - nProjectedIndices)
2114 "In npstat::ArrayND::verifyProjectionCompatibility: " 2115 "incompatible argument array rank");
2116 assert(projectedIndices);
2118 for (
unsigned j=0; j<nProjectedIndices; ++j)
2120 "In npstat::ArrayND::verifyProjectionCompatibility: " 2121 "projected index out of range");
2124 unsigned sliceDim = 0
U;
2125 for (
unsigned i=0;
i<
dim_; ++
i)
2128 for (
unsigned j=0; j<nProjectedIndices; ++j)
2129 if (projectedIndices[j] ==
i)
2138 "In npstat::ArrayND::verifyProjectionCompatibility: " 2139 "incompatible argument array dimensions");
2143 assert(sliceDim == projection.
dim_);
2146 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2147 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2151 const unsigned *projectedIndices,
2152 const unsigned nProjectedIndices)
const 2157 unsigned ibuf[StackDim];
2159 for (
unsigned i=0;
i<
dim_; ++
i)
2162 projector, projectedIndices, nProjectedIndices,
2167 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2168 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2172 const unsigned *projectedIndices,
2173 const unsigned nProjectedIndices)
const 2178 unsigned ibuf[StackDim];
2180 for (
unsigned i=0;
i<
dim_; ++
i)
2183 projector, projectedIndices, nProjectedIndices,
2188 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2189 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2193 const unsigned *projectedIndices,
2194 const unsigned nProjectedIndices)
const 2199 unsigned ibuf[StackDim];
2201 for (
unsigned i=0;
i<
dim_; ++
i)
2204 projector, projectedIndices, nProjectedIndices,
2209 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2210 template <
typename Num2>
2212 const unsigned level,
const unsigned long idx0,
2214 const unsigned *projectedIndices,
2215 const unsigned nProjectedIndices)
const 2217 const unsigned idx = projectedIndices[
level];
2220 const bool last = (level == nProjectedIndices - 1);
2222 for (
unsigned i = 0;
i<imax; ++
i)
2228 projectedIndices, nProjectedIndices);
2232 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2233 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
2234 typename Num3,
class Op>
2236 const unsigned level,
const unsigned long idx0,
2237 const unsigned level1,
const unsigned long idx1,
2240 const unsigned *projectedIndices,
2241 const unsigned nProjectedIndices, Op
fcn)
const 2245 assert(level1 == projection->
dim_);
2248 projectedIndices, nProjectedIndices);
2249 if (projection->
dim_)
2257 for (
unsigned j=0; j<nProjectedIndices; ++j)
2258 if (projectedIndices[j] == level)
2266 projection, projector,
2267 projectedIndices, nProjectedIndices, fcn);
2273 const unsigned long stride2 = projection->
strides_[level1];
2274 for (
unsigned i = 0;
i<imax; ++
i)
2276 level1+1, idx1+
i*stride2,
2277 projection, projector,
2278 projectedIndices, nProjectedIndices, fcn);
2283 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2284 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2288 const unsigned *projectedIndices,
2289 const unsigned nProjectedIndices)
const 2295 projector, projectedIndices, nProjectedIndices,
2299 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2300 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2304 const unsigned *projectedIndices,
2305 const unsigned nProjectedIndices)
const 2311 projector, projectedIndices, nProjectedIndices,
2315 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2316 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
typename Num3>
2320 const unsigned *projectedIndices,
2321 const unsigned nProjectedIndices)
const 2327 projector, projectedIndices, nProjectedIndices,
2331 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2332 template <
typename Num2,
class Functor>
2334 const unsigned level,
const unsigned long idx0,
2335 Num2&
scale,
const unsigned *projectedIndices,
2336 const unsigned nProjectedIndices, Functor binaryFunct)
2338 const unsigned idx = projectedIndices[
level];
2342 if (level == nProjectedIndices - 1)
2345 for (
unsigned i = 0;
i<imax; ++
i)
2346 binaryFunct(data[
i*stride], scale);
2349 for (
unsigned i = 0;
i<imax; ++
i)
2351 projectedIndices, nProjectedIndices,
2355 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2356 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2358 unsigned level,
unsigned long idx0,
2359 unsigned level1,
unsigned long idx1,
2361 const unsigned *projectedIndices,
2362 const unsigned nProjectedIndices,
2363 Functor binaryFunct)
2367 assert(level1 == slice.
dim_);
2371 nProjectedIndices, binaryFunct);
2376 for (
unsigned j=0; j<nProjectedIndices; ++j)
2377 if (projectedIndices[j] == level)
2385 projectedIndices, nProjectedIndices,
2392 const unsigned long stride2 = slice.
strides_[level1];
2393 for (
unsigned i = 0;
i<imax; ++
i)
2395 idx1+
i*stride2, slice, projectedIndices,
2396 nProjectedIndices, binaryFunct);
2401 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2402 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2407 "In npstat::ArrayND::jointScan: incompatible argument array shape");
2409 for (
unsigned long i=0;
i<
len_; ++
i)
2415 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2416 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2419 const unsigned *fixedIndices,
const unsigned nFixedIndices,
2420 Functor binaryFunct)
2425 if (slice.
dim_ == 0
U)
2426 for (
unsigned long i=0;
i<
len_; ++
i)
2430 fixedIndices, nFixedIndices, binaryFunct);
2436 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2442 if (
dim_ != shape.size())
2446 for (
unsigned i=0;
i<
dim_; ++
i)
2451 assert(
len_ == 1UL);
2455 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2456 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
2472 for (
unsigned i=0;
i<
dim_; ++
i)
2477 assert(
len_ == 1UL);
2481 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2482 template<
typename Num2,
typename Integer>
2484 const unsigned level,
unsigned long idx0,
2485 unsigned* currentIndex,
2491 long long int iminl =
static_cast<long long int>(levelRange.
min());
2492 if (iminl < 0LL) iminl = 0LL;
2493 long long int imaxl =
static_cast<long long int>(levelRange.
max());
2494 if (imaxl < 0LL) imaxl = 0LL;
2497 const unsigned imin =
static_cast<unsigned>(iminl);
2498 unsigned imax =
static_cast<unsigned>(imaxl);
2499 if (imax >
shape_[level])
2502 if (level ==
dim_ - 1)
2505 for (
unsigned i=imin;
i<imax; ++
i, ++idx0)
2514 idx0 += imin*stride;
2515 for (
unsigned i=imin;
i<imax; ++
i)
2524 template<
typename Numeric,
unsigned Len,
unsigned StackDim>
2525 template <
typename Num2,
typename Integer>
2531 "Initialize npstat::ArrayND before calling method \"processSubrange\"");
2533 "npstat::ArrayND::processSubrange method " 2534 "can not be used with array of 0 rank");
2536 "In npstat::ArrayND::processSubrange: incompatible subrange rank");
2537 unsigned ibuf[StackDim];
2539 for (
unsigned i=0;
i<
dim_; ++
i)
2545 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2546 template<
typename Num2>
2548 const Num2*
data,
const unsigned long dataLength)
2551 "Initialize npstat::ArrayND before calling method \"setData\"");
2553 "In npstat::ArrayND::setData: incompatible input data length");
2558 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2565 for (
unsigned j=
dim_ - 1; j>0; --j)
2569 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
2578 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2599 assert(
len_ == 1UL);
2605 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2606 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
2627 assert(
len_ == 1UL);
2633 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2634 template<
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2652 for (
unsigned long i=0;
i<
len_; ++
i)
2657 assert(
len_ == 1UL);
2663 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2664 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2666 const unsigned level,
unsigned long idx0,
2672 if (level ==
dim_ - 1)
2675 const Num2* from = r.
data_ + (idx1 + range[
level].min());
2676 for (
unsigned i=0;
i<imax; ++
i)
2677 *to++ = static_cast<Numeric>(
f(*from++));
2683 idx1 += range[
level].min()*fromstride;
2684 for (
unsigned i=0;
i<imax; ++
i)
2693 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2694 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
2702 "In npstat::ArrayND subrange constructor: invalid subrange");
2708 "In npstat::ArrayND subrange constructor: empty subrange");
2721 if (
dim_ > CHAR_BIT*
sizeof(
unsigned long))
2723 "In npstat::ArrayND subrange constructor: " 2724 "input array rank is too large");
2725 unsigned lolim[CHAR_BIT*
sizeof(
unsigned long)];
2727 unsigned toBuf[CHAR_BIT*
sizeof(
unsigned long)];
2730 0
U, 0UL, 0UL, lolim,
shape_, toBuf, *
this,
2735 assert(
len_ == 1UL);
2741 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2742 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
2751 "In npstat::ArrayND transforming subrange constructor: " 2752 "incompatible subrange");
2758 "In npstat::ArrayND transforming subrange constructor: " 2763 for (
unsigned i=0;
i<
dim_; ++
i)
2777 assert(
len_ == 1UL);
2783 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2787 const unsigned sz = sh.size();
2791 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2799 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2803 const unsigned dim = 1
U;
2804 unsigned sizes[dim];
2809 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2814 const unsigned dim = 2
U;
2815 unsigned sizes[dim];
2821 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2827 const unsigned dim = 3
U;
2828 unsigned sizes[dim];
2835 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2842 const unsigned dim = 4
U;
2843 unsigned sizes[dim];
2851 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2859 const unsigned dim = 5
U;
2860 unsigned sizes[dim];
2869 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2878 const unsigned dim = 6
U;
2879 unsigned sizes[dim];
2889 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2899 const unsigned dim = 7
U;
2900 unsigned sizes[dim];
2911 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2922 const unsigned dim = 8
U;
2923 unsigned sizes[dim];
2935 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2947 const unsigned dim = 9
U;
2948 unsigned sizes[dim];
2961 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2974 const unsigned dim = 10
U;
2975 unsigned sizes[dim];
2989 template<
typename Numeric,
unsigned Len,
unsigned Dim>
2990 template<
typename Num1,
unsigned Len1,
unsigned Dim1,
2991 typename Num2,
unsigned Len2,
unsigned Dim2>
2993 const unsigned level,
unsigned long idx0,
2994 unsigned long idx1,
unsigned long idx2,
2999 if (level ==
dim_ - 1)
3001 for (
unsigned i=0;
i<imax; ++
i)
3006 for (
unsigned i=0;
i<imax; ++
i)
3010 if (level < a1.
dim_)
3018 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3019 template<
typename Num1,
unsigned Len1,
unsigned Dim1,
3020 typename Num2,
unsigned Len2,
unsigned Dim2>
3028 "In npstat::ArrayND outer product constructor: " 3029 "uninitialized argument array");
3036 for (
unsigned i=0;
i<
dim_; ++
i)
3051 for (
unsigned long i=0;
i<
len_; ++
i)
3054 else if (a2.
dim_ == 0)
3056 for (
unsigned long i=0;
i<
len_; ++
i)
3069 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3077 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3086 "In npstat::ArrayND assignment operator: " 3087 "uninitialized argument array");
3089 "In npstat::ArrayND assignment operator: " 3090 "incompatible argument array shape");
3106 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3107 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
3111 if ((
void*)
this == (
void*)(&r))
3116 "In npstat::ArrayND assignment operator: " 3117 "uninitialized argument array");
3119 "In npstat::ArrayND assignment operator: " 3120 "incompatible argument array shape");
3136 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3137 template <
typename Num2,
unsigned Len2,
unsigned Dim2,
class Functor>
3145 "In npstat::ArrayND::assign: uninitialized argument array");
3147 "In npstat::ArrayND::assign: incompatible argument array shape");
3149 for (
unsigned long i=0;
i<
len_; ++
i)
3164 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3168 "Initialize npstat::ArrayND before calling method \"shape\"");
3172 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3176 "Initialize npstat::ArrayND before calling method \"fullRange\"");
3180 range.reserve(
dim_);
3181 for (
unsigned i=0;
i<
dim_; ++
i)
3187 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3191 "Initialize npstat::ArrayND before calling method \"isDensity\"");
3192 const Numeric zero = Numeric();
3193 bool hasPositive =
false;
3195 for (
unsigned long i=0;
i<
len_; ++
i)
3215 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3219 "Initialize npstat::ArrayND before calling method \"isZero\"");
3220 const Numeric zero = Numeric();
3223 for (
unsigned long i=0;
i<
len_; ++
i)
3233 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3235 unsigned long l,
unsigned*
idx,
const unsigned idxLen)
const 3238 "Initialize npstat::ArrayND before calling " 3239 "method \"convertLinearIndex\"");
3241 "npstat::ArrayND::convertLinearIndex method " 3242 "can not be used with array of 0 rank");
3244 "In npstat::ArrayND::convertLinearIndex: incompatible index length");
3246 "In npstat::ArrayND::convertLinearIndex: linear index out of range");
3249 for (
unsigned i=0;
i<
dim_; ++
i)
3256 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3258 const unsigned*
index,
unsigned idxLen)
const 3261 "Initialize npstat::ArrayND before calling method \"linearIndex\"");
3263 "npstat::ArrayND::linearIndex method " 3264 "can not be used with array of 0 rank");
3266 "In npstat::ArrayND::linearIndex: incompatible index length");
3269 unsigned long idx = 0UL;
3270 for (
unsigned i=0;
i<
dim_; ++
i)
3274 "In npstat::ArrayND::linearIndex: index out of range");
3280 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3282 const unsigned *
index,
const unsigned dim)
3285 "Initialize npstat::ArrayND before calling method \"value\"");
3287 "In npstat::ArrayND::value: incompatible index length");
3291 unsigned long idx = 0UL;
3292 for (
unsigned i=0;
i<
dim_; ++
i)
3300 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3302 const unsigned *
index,
const unsigned dim)
const 3305 "Initialize npstat::ArrayND before calling method \"value\"");
3307 "In npstat::ArrayND::value: incompatible index length");
3311 unsigned long idx = 0UL;
3312 for (
unsigned i=0;
i<
dim_; ++
i)
3320 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3322 const unsigned long index)
3327 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3329 const unsigned long index)
const 3334 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3336 const unsigned long index)
3340 "In npstat::ArrayND::linearValueAt: linear index out of range");
3344 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3346 const unsigned long index)
const 3350 "In npstat::ArrayND::linearValueAt: linear index out of range");
3354 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3356 const double x,
const unsigned idim)
const 3360 else if (x >= static_cast<double>(
shape_[idim] - 1))
3363 return static_cast<unsigned>(std::floor(x + 0.5));
3366 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3368 const double *x,
const unsigned dim)
const 3371 "Initialize npstat::ArrayND before calling method \"closest\"");
3373 "In npstat::ArrayND::closest: incompatible data length");
3377 unsigned long idx = 0UL;
3378 for (
unsigned i=0;
i<
dim_; ++
i)
3386 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3388 const double *x,
const unsigned dim)
3391 "Initialize npstat::ArrayND before calling method \"closest\"");
3393 "In npstat::ArrayND::closest: incompatible data length");
3397 unsigned long idx = 0UL;
3398 for (
unsigned i=0;
i<
dim_; ++
i)
3406 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3408 const unsigned *
index,
const unsigned dim)
const 3411 "Initialize npstat::ArrayND before calling method \"valueAt\"");
3413 "In npstat::ArrayND::valueAt: incompatible index length");
3417 unsigned long idx = 0UL;
3418 for (
unsigned i=0;
i<
dim_; ++
i)
3421 "In npstat::ArrayND::valueAt: index out of range");
3430 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3432 const unsigned *
index,
const unsigned dim)
3435 "Initialize npstat::ArrayND before calling method \"valueAt\"");
3437 "In npstat::ArrayND::valueAt: incompatible index length");
3441 unsigned long idx = 0UL;
3442 for (
unsigned i=0;
i<
dim_; ++
i)
3445 "In npstat::ArrayND::valueAt: index out of range");
3454 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3458 "Initialize npstat::ArrayND before calling method \"operator()\"");
3460 "In npstat::ArrayND::operator(): wrong # of args (not rank 0 array)");
3464 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3468 "Initialize npstat::ArrayND before calling method \"operator()\"");
3470 "In npstat::ArrayND::operator(): wrong # of args (not rank 0 array)");
3474 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3479 "In npstat::ArrayND::operator(): wrong # of args (not rank 1 array)");
3483 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3485 const unsigned i)
const 3488 "In npstat::ArrayND::operator(): wrong # of args (not rank 1 array)");
3492 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3496 "Initialize npstat::ArrayND before calling method \"at\"");
3498 "In npstat::ArrayND::at: wrong # of args (not rank 0 array)");
3502 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3506 "Initialize npstat::ArrayND before calling method \"at\"");
3508 "In npstat::ArrayND::at: wrong # of args (not rank 0 array)");
3512 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3514 const unsigned i0)
const 3517 "In npstat::ArrayND::at: wrong # of args (not rank 1 array)");
3519 "In npstat::ArrayND::at: index 0 out of range (rank 1)");
3523 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3528 "In npstat::ArrayND::at: wrong # of args (not rank 1 array)");
3530 "In npstat::ArrayND::at: index 0 out of range (rank 1)");
3534 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3540 "In npstat::ArrayND::operator(): wrong # of args (not rank 2 array)");
3544 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3547 const unsigned i1)
const 3550 "In npstat::ArrayND::operator(): wrong # of args (not rank 2 array)");
3554 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3557 const unsigned i1)
const 3560 "In npstat::ArrayND::at: wrong # of args (not rank 2 array)");
3562 "In npstat::ArrayND::at: index 0 out of range (rank 2)");
3564 "In npstat::ArrayND::at: index 1 out of range (rank 2)");
3568 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3574 "In npstat::ArrayND::at: wrong # of args (not rank 2 array)");
3576 "In npstat::ArrayND::at: index 0 out of range (rank 2)");
3578 "In npstat::ArrayND::at: index 1 out of range (rank 2)");
3582 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3586 const unsigned i2)
const 3589 "In npstat::ArrayND::operator(): wrong # of args (not rank 3 array)");
3593 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3598 const unsigned i3)
const 3601 "In npstat::ArrayND::operator(): wrong # of args (not rank 4 array)");
3605 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3611 const unsigned i4)
const 3614 "In npstat::ArrayND::operator(): wrong # of args (not rank 5 array)");
3619 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3626 const unsigned i5)
const 3629 "In npstat::ArrayND::operator(): wrong # of args (not rank 6 array)");
3634 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3642 const unsigned i6)
const 3645 "In npstat::ArrayND::operator(): wrong # of args (not rank 7 array)");
3650 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3659 const unsigned i7)
const 3662 "In npstat::ArrayND::operator(): wrong # of args (not rank 8 array)");
3668 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3678 const unsigned i8)
const 3681 "In npstat::ArrayND::operator(): wrong # of args (not rank 9 array)");
3687 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3698 const unsigned i9)
const 3701 "In npstat::ArrayND::operator(): wrong # of args (not rank 10 array)");
3707 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3714 "In npstat::ArrayND::operator(): wrong # of args (not rank 3 array)");
3718 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3726 "In npstat::ArrayND::operator(): wrong # of args (not rank 4 array)");
3730 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3739 "In npstat::ArrayND::operator(): wrong # of args (not rank 5 array)");
3744 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3754 "In npstat::ArrayND::operator(): wrong # of args (not rank 6 array)");
3759 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3770 "In npstat::ArrayND::operator(): wrong # of args (not rank 7 array)");
3775 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3787 "In npstat::ArrayND::operator(): wrong # of args (not rank 8 array)");
3793 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3806 "In npstat::ArrayND::operator(): wrong # of args (not rank 9 array)");
3812 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3826 "In npstat::ArrayND::operator(): wrong # of args (not rank 10 array)");
3832 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3836 const unsigned i2)
const 3839 "In npstat::ArrayND::at: wrong # of args (not rank 3 array)");
3841 "In npstat::ArrayND::at: index 0 out of range (rank 3)");
3843 "In npstat::ArrayND::at: index 1 out of range (rank 3)");
3845 "In npstat::ArrayND::at: index 2 out of range (rank 3)");
3849 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3854 const unsigned i3)
const 3857 "In npstat::ArrayND::at: wrong # of args (not rank 4 array)");
3859 "In npstat::ArrayND::at: index 0 out of range (rank 4)");
3861 "In npstat::ArrayND::at: index 1 out of range (rank 4)");
3863 "In npstat::ArrayND::at: index 2 out of range (rank 4)");
3865 "In npstat::ArrayND::at: index 3 out of range (rank 4)");
3869 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3875 const unsigned i4)
const 3878 "In npstat::ArrayND::at: wrong # of args (not rank 5 array)");
3880 "In npstat::ArrayND::at: index 0 out of range (rank 5)");
3882 "In npstat::ArrayND::at: index 1 out of range (rank 5)");
3884 "In npstat::ArrayND::at: index 2 out of range (rank 5)");
3886 "In npstat::ArrayND::at: index 3 out of range (rank 5)");
3888 "In npstat::ArrayND::at: index 4 out of range (rank 5)");
3893 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3900 const unsigned i5)
const 3903 "In npstat::ArrayND::at: wrong # of args (not rank 6 array)");
3905 "In npstat::ArrayND::at: index 0 out of range (rank 6)");
3907 "In npstat::ArrayND::at: index 1 out of range (rank 6)");
3909 "In npstat::ArrayND::at: index 2 out of range (rank 6)");
3911 "In npstat::ArrayND::at: index 3 out of range (rank 6)");
3913 "In npstat::ArrayND::at: index 4 out of range (rank 6)");
3915 "In npstat::ArrayND::at: index 5 out of range (rank 6)");
3920 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3928 const unsigned i6)
const 3931 "In npstat::ArrayND::at: wrong # of args (not rank 7 array)");
3933 "In npstat::ArrayND::at: index 0 out of range (rank 7)");
3935 "In npstat::ArrayND::at: index 1 out of range (rank 7)");
3937 "In npstat::ArrayND::at: index 2 out of range (rank 7)");
3939 "In npstat::ArrayND::at: index 3 out of range (rank 7)");
3941 "In npstat::ArrayND::at: index 4 out of range (rank 7)");
3943 "In npstat::ArrayND::at: index 5 out of range (rank 7)");
3945 "In npstat::ArrayND::at: index 6 out of range (rank 7)");
3950 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3959 const unsigned i7)
const 3962 "In npstat::ArrayND::at: wrong # of args (not rank 8 array)");
3964 "In npstat::ArrayND::at: index 0 out of range (rank 8)");
3966 "In npstat::ArrayND::at: index 1 out of range (rank 8)");
3968 "In npstat::ArrayND::at: index 2 out of range (rank 8)");
3970 "In npstat::ArrayND::at: index 3 out of range (rank 8)");
3972 "In npstat::ArrayND::at: index 4 out of range (rank 8)");
3974 "In npstat::ArrayND::at: index 5 out of range (rank 8)");
3976 "In npstat::ArrayND::at: index 6 out of range (rank 8)");
3978 "In npstat::ArrayND::at: index 7 out of range (rank 8)");
3984 template<
typename Numeric,
unsigned Len,
unsigned Dim>
3994 const unsigned i8)
const 3997 "In npstat::ArrayND::at: wrong # of args (not rank 9 array)");
3999 "In npstat::ArrayND::at: index 0 out of range (rank 9)");
4001 "In npstat::ArrayND::at: index 1 out of range (rank 9)");
4003 "In npstat::ArrayND::at: index 2 out of range (rank 9)");
4005 "In npstat::ArrayND::at: index 3 out of range (rank 9)");
4007 "In npstat::ArrayND::at: index 4 out of range (rank 9)");
4009 "In npstat::ArrayND::at: index 5 out of range (rank 9)");
4011 "In npstat::ArrayND::at: index 6 out of range (rank 9)");
4013 "In npstat::ArrayND::at: index 7 out of range (rank 9)");
4015 "In npstat::ArrayND::at: index 8 out of range (rank 9)");
4021 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4032 const unsigned i9)
const 4035 "In npstat::ArrayND::at: wrong # of args (not rank 10 array)");
4037 "In npstat::ArrayND::at: index 0 out of range (rank 10)");
4039 "In npstat::ArrayND::at: index 1 out of range (rank 10)");
4041 "In npstat::ArrayND::at: index 2 out of range (rank 10)");
4043 "In npstat::ArrayND::at: index 3 out of range (rank 10)");
4045 "In npstat::ArrayND::at: index 4 out of range (rank 10)");
4047 "In npstat::ArrayND::at: index 5 out of range (rank 10)");
4049 "In npstat::ArrayND::at: index 6 out of range (rank 10)");
4051 "In npstat::ArrayND::at: index 7 out of range (rank 10)");
4053 "In npstat::ArrayND::at: index 8 out of range (rank 10)");
4055 "In npstat::ArrayND::at: index 9 out of range (rank 10)");
4061 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4068 "In npstat::ArrayND::at: wrong # of args (not rank 3 array)");
4070 "In npstat::ArrayND::at: index 0 out of range (rank 3)");
4072 "In npstat::ArrayND::at: index 1 out of range (rank 3)");
4074 "In npstat::ArrayND::at: index 2 out of range (rank 3)");
4078 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4086 "In npstat::ArrayND::at: wrong # of args (not rank 4 array)");
4088 "In npstat::ArrayND::at: index 0 out of range (rank 4)");
4090 "In npstat::ArrayND::at: index 1 out of range (rank 4)");
4092 "In npstat::ArrayND::at: index 2 out of range (rank 4)");
4094 "In npstat::ArrayND::at: index 3 out of range (rank 4)");
4098 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4107 "In npstat::ArrayND::at: wrong # of args (not rank 5 array)");
4109 "In npstat::ArrayND::at: index 0 out of range (rank 5)");
4111 "In npstat::ArrayND::at: index 1 out of range (rank 5)");
4113 "In npstat::ArrayND::at: index 2 out of range (rank 5)");
4115 "In npstat::ArrayND::at: index 3 out of range (rank 5)");
4117 "In npstat::ArrayND::at: index 4 out of range (rank 5)");
4122 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4132 "In npstat::ArrayND::at: wrong # of args (not rank 6 array)");
4134 "In npstat::ArrayND::at: index 0 out of range (rank 6)");
4136 "In npstat::ArrayND::at: index 1 out of range (rank 6)");
4138 "In npstat::ArrayND::at: index 2 out of range (rank 6)");
4140 "In npstat::ArrayND::at: index 3 out of range (rank 6)");
4142 "In npstat::ArrayND::at: index 4 out of range (rank 6)");
4144 "In npstat::ArrayND::at: index 5 out of range (rank 6)");
4149 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4160 "In npstat::ArrayND::at: wrong # of args (not rank 7 array)");
4162 "In npstat::ArrayND::at: index 0 out of range (rank 7)");
4164 "In npstat::ArrayND::at: index 1 out of range (rank 7)");
4166 "In npstat::ArrayND::at: index 2 out of range (rank 7)");
4168 "In npstat::ArrayND::at: index 3 out of range (rank 7)");
4170 "In npstat::ArrayND::at: index 4 out of range (rank 7)");
4172 "In npstat::ArrayND::at: index 5 out of range (rank 7)");
4174 "In npstat::ArrayND::at: index 6 out of range (rank 7)");
4179 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4191 "In npstat::ArrayND::at: wrong # of args (not rank 8 array)");
4193 "In npstat::ArrayND::at: index 0 out of range (rank 8)");
4195 "In npstat::ArrayND::at: index 1 out of range (rank 8)");
4197 "In npstat::ArrayND::at: index 2 out of range (rank 8)");
4199 "In npstat::ArrayND::at: index 3 out of range (rank 8)");
4201 "In npstat::ArrayND::at: index 4 out of range (rank 8)");
4203 "In npstat::ArrayND::at: index 5 out of range (rank 8)");
4205 "In npstat::ArrayND::at: index 6 out of range (rank 8)");
4207 "In npstat::ArrayND::at: index 7 out of range (rank 8)");
4213 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4226 "In npstat::ArrayND::at: wrong # of args (not rank 9 array)");
4228 "In npstat::ArrayND::at: index 0 out of range (rank 9)");
4230 "In npstat::ArrayND::at: index 1 out of range (rank 9)");
4232 "In npstat::ArrayND::at: index 2 out of range (rank 9)");
4234 "In npstat::ArrayND::at: index 3 out of range (rank 9)");
4236 "In npstat::ArrayND::at: index 4 out of range (rank 9)");
4238 "In npstat::ArrayND::at: index 5 out of range (rank 9)");
4240 "In npstat::ArrayND::at: index 6 out of range (rank 9)");
4242 "In npstat::ArrayND::at: index 7 out of range (rank 9)");
4244 "In npstat::ArrayND::at: index 8 out of range (rank 9)");
4250 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4264 "In npstat::ArrayND::at: wrong # of args (not rank 10 array)");
4266 "In npstat::ArrayND::at: index 0 out of range (rank 10)");
4268 "In npstat::ArrayND::at: index 1 out of range (rank 10)");
4270 "In npstat::ArrayND::at: index 2 out of range (rank 10)");
4272 "In npstat::ArrayND::at: index 3 out of range (rank 10)");
4274 "In npstat::ArrayND::at: index 4 out of range (rank 10)");
4276 "In npstat::ArrayND::at: index 5 out of range (rank 10)");
4278 "In npstat::ArrayND::at: index 6 out of range (rank 10)");
4280 "In npstat::ArrayND::at: index 7 out of range (rank 10)");
4282 "In npstat::ArrayND::at: index 8 out of range (rank 10)");
4284 "In npstat::ArrayND::at: index 9 out of range (rank 10)");
4290 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4291 template<
unsigned Len2,
unsigned Dim2>
4296 "In npstat::ArrayND::maxAbsDifference: " 4297 "incompatible argument array shape");
4301 for (
unsigned long i=0;
i<
len_; ++
i)
4317 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4318 template<
unsigned Len2,
unsigned Dim2>
4328 for (
unsigned i=0;
i<
dim_; ++
i)
4331 for (
unsigned i=0;
i<
dim_; ++
i)
4333 for (
unsigned long j=0; j<
len_; ++j)
4339 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4340 template<
unsigned Len2,
unsigned Dim2>
4344 return !(*
this ==
r);
4347 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4348 template<
typename Num2>
4353 "Initialize npstat::ArrayND before calling method \"operator*\"");
4355 for (
unsigned long i=0;
i<
len_; ++
i)
4360 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4361 template<
typename Num2>
4366 "Initialize npstat::ArrayND before calling method \"operator/\"");
4368 "In npstat::ArrayND::operator/: division by zero");
4370 for (
unsigned long i=0;
i<
len_; ++
i)
4375 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4376 template <
unsigned Len2,
unsigned Dim2>
4382 "In npstat::ArrayND::operator+: " 4383 "incompatible argument array shape");
4385 for (
unsigned long i=0;
i<
len_; ++
i)
4390 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4391 template <
unsigned Len2,
unsigned Dim2>
4397 "In npstat::ArrayND::operator-: " 4398 "incompatible argument array shape");
4400 for (
unsigned long i=0;
i<
len_; ++
i)
4405 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4409 "Initialize npstat::ArrayND before calling method \"operator+\"");
4413 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4417 "Initialize npstat::ArrayND before calling method \"operator-\"");
4419 for (
unsigned long i=0;
i<
len_; ++
i)
4424 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4425 template <
typename Num2>
4430 "Initialize npstat::ArrayND before calling method \"operator*=\"");
4431 for (
unsigned long i=0;
i<
len_; ++
i)
4436 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4441 "Initialize npstat::ArrayND before calling method \"makeNonNegative\"");
4442 const Numeric zero = Numeric();
4445 for (
unsigned long i=0;
i<
len_; ++
i)
4455 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4457 const double tolerance,
const unsigned nCycles)
4460 "Initialize npstat::ArrayND before calling method \"makeCopulaSteps\"");
4464 "npstat::ArrayND::makeCopulaSteps method " 4465 "can not be used with array of 0 rank");
4467 const Numeric zero = Numeric();
4468 for (
unsigned long i=0;
i<
len_; ++
i)
4472 std::vector<Numeric*> axesPtrBuf(
dim_);
4473 Numeric** axes = &axesPtrBuf[0];
4474 const Numeric
one =
static_cast<Numeric
>(1);
4477 unsigned idxSum = 0;
4478 for (
unsigned i=0; i<
dim_; ++
i)
4480 std::vector<Numeric> axesBuf(idxSum);
4481 axes[0] = &axesBuf[0];
4482 for (
unsigned i=1; i<
dim_; ++
i)
4483 axes[i] = axes[i-1] +
shape_[i-1];
4486 unsigned icycle = 0;
4487 for (; icycle<nCycles; ++icycle)
4489 for (
unsigned i=0; i<idxSum; ++
i)
4493 for (
unsigned long idat=0; idat<
len_; ++idat)
4495 unsigned long l = idat;
4496 for (
unsigned i=0; i<
dim_; ++
i)
4505 bool withinTolerance =
true;
4506 Numeric totalSum = zero;
4507 for (
unsigned i=0; i<
dim_; ++
i)
4509 Numeric axisSum = zero;
4510 const unsigned amax =
shape_[
i];
4511 for (
unsigned a=0;
a<amax; ++
a)
4513 if (axes[i][
a] == zero)
4515 "In npstat::ArrayND::makeCopulaSteps: " 4516 "marginal density is zero");
4517 axisSum += axes[
i][
a];
4519 totalSum += axisSum;
4520 const Numeric axisAverage = axisSum/
static_cast<Numeric
>(amax);
4521 for (
unsigned a=0;
a<amax; ++
a)
4522 axes[i][
a] /= axisAverage;
4523 for (
unsigned a=0;
a<amax && withinTolerance; ++
a)
4526 if (adelta > tolerance)
4527 withinTolerance =
false;
4531 if (withinTolerance)
4534 const Numeric totalAverage = totalSum/
4535 static_cast<Numeric
>(
len_)/static_cast<Numeric>(dim_);
4539 for (
unsigned long idat=0; idat<
len_; ++idat)
4541 unsigned long l = idat;
4542 for (
unsigned i=0; i<
dim_; ++
i)
4548 data_[idat] /= totalAverage;
4555 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4556 template <
typename Num2>
4561 "Initialize npstat::ArrayND before calling method \"operator/=\"");
4563 "In npstat::ArrayND::operator/=: division by zero");
4564 for (
unsigned long i=0;
i<
len_; ++
i)
4569 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4570 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
4575 "In npstat::ArrayND::operator+=: " 4576 "incompatible argument array shape");
4577 for (
unsigned long i=0;
i<
len_; ++
i)
4582 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4583 template <
typename Num3,
typename Num2,
unsigned Len2,
unsigned Dim2>
4589 "In npstat::ArrayND::addmul: " 4590 "incompatible argument array shape");
4591 for (
unsigned long i=0;
i<
len_; ++
i)
4596 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4597 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
4602 "In npstat::ArrayND::operator-=: " 4603 "incompatible argument array shape");
4604 for (
unsigned long i=0;
i<
len_; ++
i)
4609 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4611 const double *coords,
const unsigned dim)
const 4614 "Initialize npstat::ArrayND before calling method \"interpolate1\"");
4616 "In npstat::ArrayND::interpolate1: incompatible coordinate length");
4619 const unsigned maxdim = CHAR_BIT*
sizeof(
unsigned long);
4622 "In npstat::ArrayND::interpolate1: array rank is too large");
4625 unsigned ix[maxdim];
4626 for (
unsigned i=0;
i<dim; ++
i)
4628 const double x = coords[
i];
4634 else if (x >= static_cast<double>(
shape_[
i] - 1))
4641 ix[
i] =
static_cast<unsigned>(std::floor(x));
4646 Numeric
sum = Numeric();
4647 const unsigned long maxcycle = 1UL << dim;
4648 for (
unsigned long icycle=0UL; icycle<maxcycle; ++icycle)
4651 unsigned long icell = 0UL;
4652 for (
unsigned i=0;
i<dim; ++
i)
4654 if (icycle & (1UL <<
i))
4674 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4676 const unsigned level,
const double* coords,
const Numeric*
base)
const 4679 const double x = coords[
level];
4681 unsigned ix, npt = 1;
4685 else if (x > static_cast<double>(npoints - 1))
4689 ix =
static_cast<unsigned>(std::floor(x));
4691 unsigned imax = ix + 3;
4692 while (imax >= npoints)
4698 npt = imax + 1 - ix;
4700 assert(npt >= 1 && npt <= 4);
4703 if (level <
dim_ - 1)
4704 for (
unsigned ipt=0; ipt<npt; ++ipt)
4706 base + (ix + ipt)*
strides_[level]);
4708 const Numeric*
const v = (level ==
dim_ - 1 ? base + ix :
fit);
4725 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4727 const double* coords,
const unsigned dim)
const 4730 "Initialize npstat::ArrayND before calling method \"interpolate3\"");
4732 "In npstat::ArrayND::interpolate3: incompatible coordinate length");
4742 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4743 template<
class Functor>
4747 "Initialize npstat::ArrayND before calling method \"apply\"");
4748 for (
unsigned long i=0;
i<
len_; ++
i)
4753 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4754 template<
class Functor>
4759 "Initialize npstat::ArrayND before calling method \"scanInPlace\"");
4760 for (
unsigned long i=0;
i<
len_; ++
i)
4765 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4770 "Initialize npstat::ArrayND before calling method \"constFill\"");
4771 for (
unsigned long i=0;
i<
len_; ++
i)
4776 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4782 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4798 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4802 "Initialize npstat::ArrayND before calling method \"makeUnit\"");
4804 "npstat::ArrayND::makeUnit method " 4805 "can not be used with arrays of rank less than 2");
4807 unsigned long stride = 0UL;
4808 const unsigned dimlen =
shape_[0];
4809 for (
unsigned i=0;
i<
dim_; ++
i)
4812 "npstat::ArrayND::makeUnit method needs " 4813 "the array span to be the same in ech dimension");
4816 const Numeric
one(static_cast<Numeric>(1));
4817 for (
unsigned i=0;
i<dimlen; ++
i)
4822 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4824 const unsigned level,
const double s0,
const unsigned long idx,
4825 const double shift,
const double* coeffs)
4828 const double c = coeffs[
level];
4829 if (level ==
dim_ - 1)
4832 for (
unsigned i=0;
i<imax; ++
i)
4838 d[
i] =
static_cast<Numeric
>(
sum);
4844 for (
unsigned i=0;
i<imax; ++
i)
4850 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4852 const double* coeffs,
const unsigned dimCoeffs,
const double shift)
4856 "Initialize npstat::ArrayND before calling method \"linearFill\"");
4858 "In npstat::ArrayND::linearFill: incompatible number of coefficients");
4869 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4870 template<
class Functor>
4872 const unsigned level,
const unsigned long idx,
4873 Functor
f,
unsigned*
farg)
4876 if (level ==
dim_ - 1)
4879 const unsigned* myarg =
farg;
4880 for (
unsigned i = 0;
i<imax; ++
i)
4883 d[
i] =
static_cast<Numeric
>(
f(myarg,
dim_));
4889 for (
unsigned i = 0;
i<imax; ++
i)
4897 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4898 template <
typename Accumulator>
4900 ArrayND* sumSlice,
const unsigned level,
unsigned long idx0,
4901 unsigned long idxSlice,
const bool useTrapezoids)
4905 if (level ==
dim_ - 1)
4911 Numeric oldval = Numeric();
4912 for (
unsigned i = 0;
i<imax; ++
i)
4914 acc += (data[
i] + oldval)*half;
4916 data[
i] =
static_cast<Numeric
>(acc);
4921 for (
unsigned i = 0;
i<imax; ++
i)
4924 data[
i] =
static_cast<Numeric
>(acc);
4927 sumSlice->
data_[idxSlice] =
static_cast<Numeric
>(acc);
4929 sumSlice->
localData_[0] =
static_cast<Numeric
>(acc);
4934 unsigned long sumStride = 0UL;
4937 for (
unsigned i = 0;
i<imax; ++
i)
4939 convertToLastDimCdfLoop<Accumulator>(
4940 sumSlice, level+1, idx0, idxSlice, useTrapezoids);
4942 idxSlice += sumStride;
4947 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4948 template <
typename Accumulator>
4950 ArrayND* sumSlice,
const bool useTrapezoids)
4953 "Initialize npstat::ArrayND before calling " 4954 "method \"convertToLastDimCdf\"");
4956 "npstat::ArrayND::convertToLastDimCdf method " 4957 "can not be used with array of 0 rank");
4960 "In npstat::ArrayND::convertToLastDimCdf: " 4961 "uninitialized argument array");
4962 convertToLastDimCdfLoop<Accumulator>(sumSlice, 0
U, 0UL, 0UL,
4966 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4967 template<
class Functor>
4971 "Initialize npstat::ArrayND before calling method \"functorFill\"");
4974 unsigned localIndex[Dim];
4981 f(static_cast<unsigned*>(0), 0
U));
4985 template<
typename Numeric,
unsigned Len,
unsigned Dim>
4986 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
4991 "In npstat::ArrayND::isClose: tolerance must not be negative");
4993 "In npstat::ArrayND::isClose: incompatible argument array shape");
4996 for (
unsigned long i=0;
i<
len_; ++
i)
5012 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5013 template<
typename Num2,
unsigned Len2,
unsigned Dim2>
5020 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5022 unsigned thisLevel,
const unsigned resLevel,
5023 const unsigned pos1,
const unsigned pos2,
5024 unsigned long idxThis,
unsigned long idxRes,
ArrayND&
result)
const 5026 while (thisLevel == pos1 || thisLevel == pos2)
5028 assert(thisLevel <
dim_);
5030 if (resLevel == result.
dim_ - 1)
5032 const unsigned ncontract =
shape_[pos1];
5033 const unsigned imax = result.
shape_[resLevel];
5035 for (
unsigned i=0;
i<imax; ++
i)
5037 const Numeric*
tmp =
data_ + (idxThis +
i*strides_[thisLevel]);
5038 Numeric
sum = Numeric();
5039 for (
unsigned j=0; j<ncontract; ++j)
5040 sum += tmp[j*stride];
5046 const unsigned imax = result.
shape_[resLevel];
5047 assert(imax ==
shape_[thisLevel]);
5048 for (
unsigned i=0;
i<imax; ++
i)
5051 idxThis, idxRes, result);
5053 idxRes += result.
strides_[resLevel];
5058 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5060 const unsigned pos1,
const unsigned pos2)
const 5063 "Initialize npstat::ArrayND before calling method \"contract\"");
5064 if (!(pos1 <
dim_ && pos2 <
dim_ && pos1 != pos2))
5066 "incompatible contraction indices");
5069 "In npstat::ArrayND::contract: incompatible " 5070 "length of contracted dimensions");
5073 unsigned newshapeBuf[Dim];
5076 for (
unsigned i=0;
i<
dim_; ++
i)
5077 if (
i != pos1 &&
i != pos2)
5078 newshape[ishap++] =
shape_[
i];
5087 Numeric
sum = Numeric();
5088 const unsigned imax =
shape_[0];
5090 for (
unsigned i=0;
i<imax; ++
i)
5099 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5101 const unsigned level,
const unsigned pos1,
const unsigned pos2,
5102 unsigned long idxThis,
unsigned long idxRes,
ArrayND&
result)
const 5106 const unsigned relevel = level == pos1 ? pos2 :
5107 (level == pos2 ? pos1 :
level);
5108 const unsigned long restride = result.
strides_[relevel];
5109 const bool ready = (level ==
dim_ - 1);
5110 for (
unsigned i=0;
i<imax; ++
i)
5115 transposeLoop(level+1, pos1, pos2, idxThis, idxRes, result);
5116 idxThis += mystride;
5121 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5122 template<
typename Num2>
5126 "Initialize npstat::ArrayND before calling method \"sum\"");
5128 for (
unsigned long i=0;
i<
len_; ++
i)
5133 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5134 template<
typename Num2>
5138 "Initialize npstat::ArrayND before calling method \"sumsq\"");
5140 for (
unsigned long i=0;
i<
len_; ++
i)
5143 sum += absval*absval;
5148 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5152 "Initialize npstat::ArrayND before calling method \"min\"");
5155 Numeric minval(
data_[0]);
5156 for (
unsigned long i=1UL;
i<
len_; ++
i)
5165 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5167 unsigned *
index,
const unsigned indexLen)
const 5170 "Initialize npstat::ArrayND before calling method \"min\"");
5172 "In npstat::ArrayND::min: incompatible index length");
5175 unsigned long minind = 0UL;
5176 Numeric minval(
data_[0]);
5177 for (
unsigned long i=1UL;
i<
len_; ++
i)
5190 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5194 "Initialize npstat::ArrayND before calling method \"max\"");
5197 Numeric maxval(
data_[0]);
5198 for (
unsigned long i=1UL;
i<
len_; ++
i)
5207 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5209 unsigned *
index,
const unsigned indexLen)
const 5212 "Initialize npstat::ArrayND before calling method \"max\"");
5214 "In npstat::ArrayND::max: incompatible index length");
5217 unsigned long maxind = 0UL;
5218 Numeric maxval(
data_[0]);
5219 for (
unsigned long i=1UL;
i<
len_; ++
i)
5233 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5237 "npstat::ArrayND::transpose method " 5238 "can not be used with arrays of rank other than 2");
5239 unsigned newshape[2];
5243 const unsigned imax =
shape_[0];
5244 const unsigned jmax =
shape_[1];
5245 for (
unsigned i=0;
i<imax; ++
i)
5246 for (
unsigned j=0; j<jmax; ++j)
5251 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5252 template <
typename Accumulator>
5254 const double inscale)
const 5257 "Initialize npstat::ArrayND before calling method \"derivative\"");
5259 "npstat::ArrayND::derivative method " 5260 "can not be used with array of 0 rank");
5263 const unsigned maxdim = CHAR_BIT*
sizeof(
unsigned long);
5265 "In npstat::ArrayND::derivative: array rank is too large");
5266 const unsigned long maxcycle = 1UL <<
dim_;
5270 for (
unsigned i=0;
i<
dim_; ++
i)
5274 "In npstat::ArrayND::derivative: in some dimendions " 5275 "array size is too small");
5280 const unsigned long rLen = result.
length();
5281 for (
unsigned long ilin=0; ilin<rLen; ++ilin)
5286 for (
unsigned long icycle=0UL; icycle<maxcycle; ++icycle)
5288 unsigned long icell = 0UL;
5290 for (
unsigned i=0;
i<
dim_; ++
i)
5292 if (icycle & (1UL <<
i))
5300 if ((dim_ - n1) % 2
U)
5301 deriv -=
data_[icell];
5303 deriv +=
data_[icell];
5305 result.
data_[ilin] =
static_cast<Numeric
>(deriv*
scale);
5311 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5312 template <
typename Accumulator>
5314 const unsigned level,
unsigned long idx0,
5315 const unsigned*
limit)
const 5318 const unsigned imax = limit[
level] + 1
U;
5319 if (level ==
dim_ - 1)
5322 for (
unsigned i=0;
i<imax; ++
i)
5328 for (
unsigned i=0;
i<imax; ++
i, idx0+=stride)
5329 cdf += sumBelowLoop<Accumulator>(level+1, idx0, limit);
5334 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5335 template <
typename Accumulator>
5337 const unsigned *
index,
const unsigned indexLen)
const 5340 "Initialize npstat::ArrayND before calling method \"cdfValue\"");
5342 "npstat::ArrayND::cdfValue method " 5343 "can not be used with array of 0 rank");
5345 "In npstat::ArrayND::cdfValue: incompatible index length");
5346 for (
unsigned i=0;
i<indexLen; ++
i)
5349 "In npstat::ArrayND::cdfValue: index out of range");
5350 return sumBelowLoop<Accumulator>(0, 0
U,
index);
5353 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5354 template <
typename Accumulator>
5356 const double inscale)
const 5359 "Initialize npstat::ArrayND before calling method \"cdfArray\"");
5361 "npstat::ArrayND::cdfArray method " 5362 "can not be used with array of 0 rank");
5365 const unsigned maxdim = CHAR_BIT*
sizeof(
unsigned long);
5368 "In npstat::ArrayND::cdfArray: array rank is too large");
5369 const unsigned long maxcycle = 1UL <<
dim_;
5373 for (
unsigned i=0;
i<
dim_; ++
i)
5378 unsigned* psh = &sh[0];
5379 const unsigned long len = result.
length();
5380 for (
unsigned long ipre=0; ipre<len; ++ipre)
5385 for (
unsigned i=0;
i<
dim_; ++
i)
5393 for (
unsigned long icycle=0UL; icycle<maxcycle; ++icycle)
5395 unsigned long icell = 0UL;
5397 for (
unsigned i=0;
i<
dim_; ++
i)
5399 if (icycle & (1UL <<
i))
5409 if ((dim_ - n1) % 2
U)
5410 deriv += result.
data_[icell];
5412 deriv -= result.
data_[icell];
5417 result.
data_[ipre] = deriv;
5424 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5426 const unsigned pos1,
const unsigned pos2)
const 5429 "Initialize npstat::ArrayND before calling method \"transpose\"");
5430 if (!(pos1 <
dim_ && pos2 <
dim_ && pos1 != pos2))
5432 "incompatible transposition indices");
5438 unsigned newshapeBuf[Dim];
5441 std::swap(newshape[pos1], newshape[pos2]);
5454 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5455 template<
typename Num2,
unsigned Len2,
unsigned Dim2>
5461 "Initialize npstat::ArrayND before calling method \"multiMirror\"");
5465 "In npstat::ArrayND::multiMirror: incompatible argument array rank");
5469 const unsigned *dshape = out->
shape_;
5470 for (
unsigned i=0;
i<
dim_; ++
i)
5472 "In npstat::ArrayND::multiMirror: " 5473 "incompatible argument array shape");
5475 if (dim_ >= CHAR_BIT*
sizeof(
unsigned long))
5477 "In npstat::ArrayND::multiMirror: " 5478 "array rank is too large");
5479 const unsigned long maxcycle = 1UL <<
dim_;
5480 std::vector<unsigned> indexbuf(dim_*2U);
5481 unsigned*
idx = &indexbuf[0];
5484 for (
unsigned long ipt=0; ipt<
len_; ++ipt)
5486 unsigned long l = ipt;
5487 for (
unsigned i=0;
i<
dim_; ++
i)
5492 for (
unsigned long icycle=0UL; icycle<maxcycle; ++icycle)
5494 for (
unsigned i=0;
i<
dim_; ++
i)
5496 if (icycle & (1UL <<
i))
5497 mirror[
i] = dshape[
i] - idx[
i] - 1U;
5509 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5510 template<
typename Num2,
unsigned Len2,
unsigned Dim2>
5512 const unsigned* shifts,
const unsigned lenShifts,
5517 "Initialize npstat::ArrayND before calling method \"rotate\"");
5520 "In npstat::ArrayND::rotate: can not rotate array into itself");
5524 "In npstat::ArrayND::rotate: incompatible argument array rank");
5526 "In npstat::ArrayND::rotate: incompatible dimensionality of shifts");
5531 if (
dim_ > CHAR_BIT*
sizeof(
unsigned long))
5533 "In npstat::ArrayND::rotate: array rank is too large");
5534 unsigned buf[CHAR_BIT*
sizeof(
unsigned long)];
5536 (
const_cast<ArrayND*
>(
this))->flatCircularLoop(
5537 0
U, 0UL, 0UL, buf,
shape_, shifts,
5544 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5545 template<
typename Num2,
unsigned Len2,
unsigned Dim2>
5547 const unsigned level,
unsigned long idx0,
5548 unsigned long idx1,
unsigned long idx2,
5555 if (level == result.
dim_)
5557 Numeric
sum = Numeric();
5558 const unsigned imax = r.
shape_[0];
5559 const unsigned rstride = r.
strides_[0];
5560 const Numeric*
l =
data_ + idx0;
5561 const Num2* ri = r.
data_ + idx1;
5562 for (
unsigned i=0;
i<imax; ++
i)
5563 sum += l[
i]*ri[
i*rstride];
5569 for (
unsigned i=0;
i<imax; ++
i)
5573 if (level <
dim_ - 1)
5581 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5582 template<
typename Num2,
unsigned Len2,
unsigned Dim2>
5587 "npstat::ArrayND::dot method " 5588 "can not be used with array of 0 rank");
5590 "npstat::ArrayND::dot method " 5591 "can not be used with argument array of 0 rank");
5593 "In npstat::ArrayND::dot: incompatible argument array shape");
5599 Numeric
sum = Numeric();
5600 const unsigned imax =
shape_[0];
5601 for (
unsigned i=0;
i<imax; ++
i)
5608 unsigned newshapeBuf[2*Dim];
5621 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5626 "In npstat::ArrayND::span: dimension number is out of range");
5630 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5633 unsigned maxspan = 0;
5634 for (
unsigned i=0;
i<
dim_; ++
i)
5640 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5645 unsigned minspan =
shape_[0];
5646 for (
unsigned i=1;
i<
dim_; ++
i)
5652 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5656 "Initialize npstat::ArrayND before calling method \"cl\"");
5658 "In npstat::ArrayND::cl: wrong # of args (not rank 0 array)");
5662 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5664 const double i0)
const 5667 "In npstat::ArrayND::cl: wrong # of args (not rank 1 array)");
5671 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5674 const double i1)
const 5677 "In npstat::ArrayND::cl: wrong # of args (not rank 2 array)");
5682 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5686 const double i2)
const 5689 "In npstat::ArrayND::cl: wrong # of args (not rank 3 array)");
5695 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5700 const double i3)
const 5703 "In npstat::ArrayND::cl: wrong # of args (not rank 4 array)");
5710 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5716 const double i4)
const 5719 "In npstat::ArrayND::cl: wrong # of args (not rank 5 array)");
5727 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5734 const double i5)
const 5737 "In npstat::ArrayND::cl: wrong # of args (not rank 6 array)");
5746 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5754 const double i6)
const 5757 "In npstat::ArrayND::cl: wrong # of args (not rank 7 array)");
5767 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5776 const double i7)
const 5779 "In npstat::ArrayND::cl: wrong # of args (not rank 8 array)");
5790 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5800 const double i8)
const 5803 "In npstat::ArrayND::cl: wrong # of args (not rank 9 array)");
5815 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5826 const double i9)
const 5829 "In npstat::ArrayND::cl: wrong # of args (not rank 10 array)");
5842 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5846 "Initialize npstat::ArrayND before calling method \"cl\"");
5848 "In npstat::ArrayND::cl: wrong # of args (not rank 0 array)");
5852 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5857 "In npstat::ArrayND::cl: wrong # of args (not rank 1 array)");
5861 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5867 "In npstat::ArrayND::cl: wrong # of args (not rank 2 array)");
5872 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5879 "In npstat::ArrayND::cl: wrong # of args (not rank 3 array)");
5885 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5893 "In npstat::ArrayND::cl: wrong # of args (not rank 4 array)");
5900 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5909 "In npstat::ArrayND::cl: wrong # of args (not rank 5 array)");
5917 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5927 "In npstat::ArrayND::cl: wrong # of args (not rank 6 array)");
5936 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5947 "In npstat::ArrayND::cl: wrong # of args (not rank 7 array)");
5957 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5969 "In npstat::ArrayND::cl: wrong # of args (not rank 8 array)");
5980 template<
typename Numeric,
unsigned Len,
unsigned Dim>
5993 "In npstat::ArrayND::cl: wrong # of args (not rank 9 array)");
6005 template<
typename Numeric,
unsigned Len,
unsigned Dim>
6019 "In npstat::ArrayND::cl: wrong # of args (not rank 10 array)");
6032 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
6036 gs::template_class_name<Numeric>(
"npstat::ArrayND"));
6037 return name.c_str();
6040 template<
typename Numeric,
unsigned StackLen,
unsigned StackDim>
6044 "Initialize npstat::ArrayND before calling method \"write\"");
6045 gs::write_pod_vector(os,
shape());
6046 return !os.fail() &&
6051 template<
typename Numeric,
unsigned Len,
unsigned Dim>
6056 current.ensureSameId(
id);
6059 gs::read_pod_vector(in, &rshape);
6060 if (in.fail())
throw gs::IOReadFailure(
6061 "In npstat::ArrayND::restore: input stream failure (checkpoint 0)");
6065 array->
dim_ = rshape.size();
6071 for (
unsigned i=0;
i<array->
dim_; ++
i)
6079 gs::read_array(in, array->
data_, array->
len_);
6082 gs::restore_item(in, array->
localData_,
false);
6083 if (in.fail())
throw gs::IOReadFailure(
6084 "In npstat::ArrayND::restore: input stream failure (checkpoint 1)");
6087 template<
typename Numeric,
unsigned Len,
unsigned StackDim>
6088 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
6090 const unsigned*
corner,
const unsigned lenCorner,
6094 "Initialize npstat::ArrayND before calling method \"exportSubrange\"");
6096 "In npstat::ArrayND::exportSubrange: incompatible corner index length");
6099 "In npstat::ArrayND::exportSubrange: uninitialized argument array");
6101 "In npstat::ArrayND::exportSubrange: incompatible argument array rank");
6106 if (
dim_ > CHAR_BIT*
sizeof(
unsigned long))
6108 "In npstat::ArrayND::exportSubrange: " 6109 "array rank is too large");
6110 unsigned toBuf[CHAR_BIT*
sizeof(
unsigned long)];
6112 (
const_cast<ArrayND*
>(
this))->commonSubrangeLoop(
6113 0
U, 0UL, 0UL, corner, out->
shape_, toBuf, *out,
6120 template<
typename Numeric,
unsigned Len,
unsigned StackDim>
6121 template <
typename Num2,
unsigned Len2,
unsigned Dim2>
6123 const unsigned*
corner,
const unsigned lenCorner,
6127 "Initialize npstat::ArrayND before calling method \"importSubrange\"");
6129 "In npstat::ArrayND::importSubrange: incompatible corner index length");
6131 "In npstat::ArrayND::importSubrange: uninitialized argument array");
6133 "In npstat::ArrayND::importSubrange: incompatible argument array rank");
6138 if (
dim_ > CHAR_BIT*
sizeof(
unsigned long))
6140 "In npstat::ArrayND::importSubrange: " 6141 "array rank is too large");
6142 unsigned toBuf[CHAR_BIT*
sizeof(
unsigned long)];
6154 #endif // NPSTAT_ARRAYND_HH_
void marginalizeLoop(unsigned level, unsigned long idx, unsigned levelRes, unsigned long idxRes, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, ArrayND &res) const
void copyBuffer(T1 *dest, const T2 *source, const unsigned long len)
unsigned long verifyBufferSliceCompatibility(unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, unsigned long *sliceStrides) const
unsigned long verifySliceCompatibility(const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
unsigned localShape_[StackDim]
virtual void process(const Input &value)=0
ArrayND & setData(const Num2 *data, unsigned long dataLength)
ArrayShape sliceShape(const unsigned *fixedIndices, unsigned nFixedIndices) const
void transposeLoop(unsigned level, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
bool isShapeCompatible(const ArrayND< Num2, Len2, Dim2 > &r) const
virtual Result result()=0
void subtractFromProjection(ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
ArrayND dot(const ArrayND< Num2, Len2, Dim2 > &r) const
ArrayND operator-() const
void commonSubrangeLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
unsigned long linearIndex(const unsigned *idx, unsigned idxLen) const
void convertLinearIndex(unsigned long l, unsigned *index, unsigned indexLen) const
static bool less(const T &l, const T &r)
virtual Result result()=0
void projectInnerLoop(unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
bool write(std::ostream &of) const
void processSubrangeLoop(unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &f, const BoxND< Integer > &subrange) const
T * makeBuffer(unsigned sizeNeeded, T *stackBuffer, unsigned sizeofStackBuffer)
ArrayND & operator/=(const Num2 &r)
ArrayND & apply(Functor f)
ArrayND & addmul(const ArrayND< Num2, Len2, Dim2 > &r, const Num3 &c)
void dualCircularScan(ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
void multiMirror(ArrayND< Num2, Len2, Dim2 > *out) const
const unsigned * shapeData() const
void projectLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, unsigned *currentIndex, ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
T interpolate_cubic(const double x, const T &f0, const T &f1, const T &f2, const T &f3)
void jointMemSliceScan(Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
void verifyProjectionCompatibility(const ArrayND< Num2, Len2, Dim2 > &projection, const unsigned *projectedIndices, unsigned nProjectedIndices) const
void flatCircularScan(ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
void importMemSlice(const Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices)
Private::AbsReturnType< T >::type absDifference(const T &v1, const T &v2)
virtual void process(const unsigned *index, unsigned indexLen, unsigned long linearIndex, const Input &value)=0
void jointScan(ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
void scaleBySliceLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
Numeric & closest(const double *x, unsigned xDim)
const Numeric max() const
bool isClose(const ArrayND< Num2, Len2, Dim2 > &r, double eps) const
void dotProductLoop(unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num2, Len2, Dim2 > &r, ArrayND &result) const
std::vector< unsigned > ArrayShape
T interpolate_quadratic(const double x, const T &f0, const T &f1, const T &f2)
void jointSliceLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, Num2 *sliceData, const unsigned long *sliceStrides, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunctor)
Numeric & linearValue(unsigned long index)
unsigned long length() const
unsigned span(unsigned dim) const
Interface definition for functors used to make array projections.
Numeric & value(const unsigned *index, unsigned indexLen)
void addToProjection(ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
ArrayRange fullRange() const
ArrayND contract(unsigned pos1, unsigned pos2) const
static const char * classname()
void linearFillLoop(unsigned level, double s0, unsigned long idx, double shift, const double *coeffs)
Numeric & linearValueAt(unsigned long index)
Compile-time deduction of the underlying floating point type from the given complex type...
void project(ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
bool operator==(const ArrayND< Numeric, Len2, Dim2 > &) const
Numeric interpolate1(const double *x, unsigned xDim) const
unsigned long dim() const
ArrayND & operator=(const ArrayND &)
ArrayND & functorFill(Functor f)
unsigned long localStrides_[StackDim]
ArrayND & constFill(Numeric c)
Multidimensional range of array indices.
ArrayND & scanInPlace(Functor f)
void applySlice(ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
ArrayND & inPlaceMul(const ArrayND< Num2, Len2, Dim2 > &r)
void functorFillLoop(unsigned level, unsigned long idx, Functor f, unsigned *farg)
Numeric marginalizeInnerLoop(unsigned long idx, unsigned levelPr, unsigned long idxPr, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap) const
void outerProductLoop(unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num1, Len1, Dim1 > &a1, const ArrayND< Num2, Len2, Dim2 > &a2)
unsigned long rangeSize() const
Exceptions for the npstat namespace.
void projectInnerLoop2(unsigned level, unsigned long idx0, AbsVisitor< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
void convertToLastDimCdfLoop(ArrayND *sumSlice, unsigned level, unsigned long idx0, unsigned long idxSlice, bool useTrapezoids)
gs::ClassId classId() const
void rotate(const unsigned *shifts, unsigned lenShifts, ArrayND< Num2, Len2, Dim2 > *rotated) const
void circularFlatLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
void dualCircularLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
double maxAbsDifference(const ArrayND< Numeric, Len2, Dim2 > &) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static unsigned version()
void contractLoop(unsigned thisLevel, unsigned resLevel, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
Compile-time deduction of an appropriate precise numeric type.
Numeric & valueAt(const unsigned *index, unsigned indexLen)
ArrayND & operator*=(const Num2 &r)
ArrayND marginalize(const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, unsigned mapLen) const
unsigned minimumSpan() const
ArrayND transpose() const
const Numeric * data() const
unsigned maximumSpan() const
void flatCircularLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
def template(fileName, svg, replaceme="REPLACEME")
void importSubrange(const unsigned *fromCorner, unsigned lenCorner, const ArrayND< Num2, Len2, Dim2 > &from)
Numeric interpolateLoop(unsigned level, const double *x, const Numeric *base) const
#define me_macro_check_loop_prerequisites(METHOD, INNERLOOP)
bool isCompatible(const ArrayShape &shape) const
base
Make Sure CMSSW is Setup ##.
void clearBuffer(T *buf, const unsigned long len)
ArrayND outer(const ArrayND< Num2, Len2, Dim2 > &r) const
void circularFlatScan(ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
Interface definitions and concrete simple functors for a variety of functor-based calculations...
ArrayND & multiplyBySlice(const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices)
void convertToLastDimCdf(ArrayND *sumSlice, bool useTrapezoids)
Interface for piecemeal processing of a data collection.
unsigned long long int rval
ArrayND & assign(const ArrayND< Num2, Len2, Dim2 > &, Functor f)
Numeric localData_[StackLen]
void jointSliceScan(ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
Ordering extended to complex numbers by comparing their magnitudes.
Private::AbsReturnType< T >::type absValue(const T &v1)
void scaleBySliceInnerLoop(unsigned level, unsigned long idx0, Num2 &scale, const unsigned *projectedIndices, unsigned nProjectedIndices, Functor binaryFunct)
static void restore(const gs::ClassId &id, std::istream &in, ArrayND *array)
void exportMemSlice(Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
void fcn(int &, double *, double &, double *, int)
void copyRangeLoopFunct(unsigned level, unsigned long idx0, unsigned long idx1, const ArrayND< Num2, Len2, Dim2 > &r, const ArrayRange &range, Functor f)
void rangeLength(unsigned *range, unsigned rangeLen) const
void importSlice(const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices)
void lowerLimits(unsigned *limits, unsigned limitsLen) const
void exportSubrange(const unsigned *fromCorner, unsigned lenCorner, ArrayND< Num2, Len2, Dim2 > *dest) const
ArrayND operator+() const
void projectLoop2(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
unsigned makeCopulaSteps(double tolerance, unsigned maxIterations)
Ordering extended to complex numbers by always returning "false".
void jointSubrangeScan(ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
ArrayND & makeNonNegative()
std::vector< std::vector< double > > tmp
ArrayND & operator-=(const ArrayND< Num2, Len2, Dim2 > &r)
ArrayShape doubleShape(const ArrayShape &inputShape)
ArrayND derivative(double scale=1.0) const
ArrayND & operator+=(const ArrayND< Num2, Len2, Dim2 > &r)
Accumulator sumBelowLoop(unsigned level, unsigned long idx0, const unsigned *limit) const
void processSubrange(AbsArrayProjector< Numeric, Num2 > &f, const BoxND< Integer > &subrange) const
bool isCompatible(const ArrayShape &shape) const
static unsigned int const shift
const unsigned long * strides() const
const Numeric min() const
ProperDblFromCmpl< Numeric >::type proper_double
bool isShapeKnown() const
ArrayND operator*(const Num2 &r) const
unsigned coordToIndex(double coord, unsigned idim) const
ArrayND operator/(const Num2 &r) const
void buildFromShapePtr(const unsigned *, unsigned)
Num2 cdfValue(const unsigned *index, unsigned indexLen) const
ArrayND cdfArray(double scale=1.0) const
Low-order polynomial interpolation (up to cubic) for equidistant coordinates.
Calculate absolute value of a difference between two numbers for an extended set of types...
T interpolate_linear(const double x, const T &f0, const T &f1)
void destroyBuffer(T *thisBuffer, const T *stackBuffer)
Utilities related to memory management.
bool operator!=(const ArrayND< Numeric, Len2, Dim2 > &) const
void exportSlice(ArrayND< Num2, Len2, Dim2 > *slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
Numeric interpolate3(const double *x, unsigned xDim) const
ArrayND & linearFill(const double *coeff, unsigned coeffLen, double c)