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

Function computeL2Norm

Common/Core/vtkArrayComponents.cxx:143–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143vtkSmartPointer<vtkDataArray> computeL2Norm(vtkDataArray* array)
144{
145 auto norm = vtkSmartPointer<vtkDoubleArray>::New();
146 norm->SetNumberOfTuples(array->GetNumberOfTuples());
147 vtkSMPTools::For(0, array->GetNumberOfTuples(),
148 [&norm, array](vtkIdType begin, vtkIdType end)
149 {
150 int numComponents = array->GetNumberOfComponents();
151 std::vector<double> tuple(numComponents);
152 for (vtkIdType ii = begin; ii < end; ++ii)
153 {
154 array->GetTuple(ii, tuple.data());
155 double norm2 = 0;
156 for (int jj = 0; jj < numComponents; ++jj)
157 {
158 norm2 += tuple[jj] * tuple[jj];
159 }
160 norm->SetValue(ii, std::sqrt(norm2));
161 }
162 });
163 return norm;
164}
165
166vtkSmartPointer<vtkDataArray> computeLInfNorm(vtkDataArray* array)
167{

Callers 1

ComponentOrNormAsArrayFunction · 0.85

Calls 9

NewFunction · 0.70
ForFunction · 0.70
sqrtFunction · 0.50
SetNumberOfTuplesMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetTupleMethod · 0.45
dataMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected