MCPcopy Create free account
hub / github.com/Kitware/VTK / computeL1Norm

Function computeL1Norm

Common/Core/vtkArrayComponents.cxx:120–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118};
119
120vtkSmartPointer<vtkDataArray> computeL1Norm(vtkDataArray* array)
121{
122 auto norm = vtkSmartPointer<vtkDoubleArray>::New();
123 norm->SetNumberOfTuples(array->GetNumberOfTuples());
124 vtkSMPTools::For(0, array->GetNumberOfTuples(),
125 [&norm, array](vtkIdType begin, vtkIdType end)
126 {
127 int numComponents = array->GetNumberOfComponents();
128 std::vector<double> tuple(numComponents);
129 for (vtkIdType ii = begin; ii < end; ++ii)
130 {
131 array->GetTuple(ii, tuple.data());
132 double sum = 0;
133 for (int jj = 0; jj < numComponents; ++jj)
134 {
135 sum += absolute(tuple[jj]);
136 }
137 norm->SetTuple1(ii, sum);
138 }
139 });
140 return norm;
141}
142
143vtkSmartPointer<vtkDataArray> computeL2Norm(vtkDataArray* array)
144{

Callers 1

ComponentOrNormAsArrayFunction · 0.85

Calls 9

absoluteFunction · 0.85
SetTuple1Method · 0.80
NewFunction · 0.70
ForFunction · 0.70
SetNumberOfTuplesMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetTupleMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected