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

Function computeLInfNorm

Common/Core/vtkArrayComponents.cxx:166–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166vtkSmartPointer<vtkDataArray> computeLInfNorm(vtkDataArray* array)
167{
168 vtkSmartPointer<vtkDataArray> norm;
169 norm.TakeReference(array->NewInstance());
170 norm->SetNumberOfTuples(array->GetNumberOfTuples());
171 if (!vtkArrayDispatch::Dispatch2::Execute(array, norm, InfNorm{}))
172 {
173 vtkSMPTools::For(0, array->GetNumberOfTuples(),
174 [&norm, array](vtkIdType begin, vtkIdType end)
175 {
176 int numComponents = array->GetNumberOfComponents();
177 assert(numComponents > 1);
178 std::vector<double> tuple(numComponents);
179 for (vtkIdType ii = begin; ii < end; ++ii)
180 {
181 array->GetTuple(ii, tuple.data());
182 double max = std::abs(tuple[0]);
183 for (int jj = 1; jj < numComponents; ++jj)
184 {
185 max = std::max(max, std::abs(tuple[jj]));
186 }
187 norm->SetTuple1(ii, max);
188 }
189 });
190 }
191 return norm;
192}
193
194} // anonymous namespace
195

Callers 1

ComponentOrNormAsArrayFunction · 0.85

Calls 13

SetTuple1Method · 0.80
ForFunction · 0.70
ExecuteFunction · 0.50
assertFunction · 0.50
absFunction · 0.50
maxFunction · 0.50
TakeReferenceMethod · 0.45
NewInstanceMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetTupleMethod · 0.45

Tested by

no test coverage detected