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

Method Learn

Filters/ParallelStatistics/vtkPOrderStatistics.cxx:115–344  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

113
114//------------------------------------------------------------------------------
115void vtkPOrderStatistics::Learn(
116 vtkTable* inData, vtkTable* inParameters, vtkStatisticalModel* outMeta)
117{
118 if (!outMeta)
119 {
120 return;
121 }
122
123 // First calculate order statistics on local data set
124 this->Superclass::Learn(inData, inParameters, outMeta);
125
126 if (!outMeta || outMeta->GetNumberOfTables(vtkStatisticalModel::Learned) < 1)
127 {
128 // No statistics were calculated.
129 return;
130 }
131
132 // Make sure that parallel updates are needed, otherwise leave it at that.
133 int np = this->Controller->GetNumberOfProcesses();
134 if (np < 2)
135 {
136 return;
137 }
138
139 // Get ready for parallel calculations
140 vtkCommunicator* com = this->Controller->GetCommunicator();
141 if (!com)
142 {
143 vtkErrorMacro("No parallel communicator.");
144 }
145
146 // Figure local process id
147 vtkIdType myRank = com->GetLocalProcessId();
148
149 // NB: Use process 0 as sole reducer for now
150 vtkIdType rProc = 0;
151
152 // Iterate over primary tables
153 int nParts = outMeta->GetNumberOfTables(vtkStatisticalModel::Learned);
154 for (int b = 0; b < nParts; ++b)
155 {
156 // Fetch histogram table
157 vtkTable* histoTab = outMeta->GetTable(vtkStatisticalModel::Learned, b);
158 if (!histoTab)
159 {
160 continue;
161 }
162 std::string histoTabName = outMeta->GetTableName(vtkStatisticalModel::Learned, b);
163
164 // Downcast columns to typed arrays for efficient data access
165 vtkAbstractArray* vals = histoTab->GetColumnByName("Value");
166 vtkIdTypeArray* card =
167 vtkArrayDownCast<vtkIdTypeArray>(histoTab->GetColumnByName("Cardinality"));
168 if (!vals || !card)
169 {
170 vtkErrorMacro("Column fetching error on process " << myRank << ".");
171
172 return;

Callers

nothing calls this directly

Calls 15

ReduceMethod · 0.95
BroadcastMethod · 0.95
GetNumberOfProcessesMethod · 0.80
GetTableNameMethod · 0.80
GetColumnByNameMethod · 0.80
GatherVMethod · 0.80
IsAMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
CreateDataArrayFunction · 0.50
GetNumberOfTablesMethod · 0.45

Tested by

no test coverage detected