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

Method Derive

Filters/Statistics/vtkPCAStatistics.cxx:611–732  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

609
610//------------------------------------------------------------------------------
611void vtkPCAStatistics::Derive(vtkStatisticalModel* inMeta)
612{
613 if (!inMeta)
614 {
615 return;
616 }
617
618 // Use the parent class to compute a covariance matrix for each request.
619 this->Superclass::Derive(inMeta);
620
621 // Now that we have the covariance matrices, compute the SVD of each.
622 vtkIdType nb = static_cast<vtkIdType>(inMeta->GetNumberOfTables(vtkStatisticalModel::Derived));
623 for (vtkIdType b = 0; b < nb; ++b)
624 {
625 vtkTable* reqModel = inMeta->GetTable(vtkStatisticalModel::Derived, b);
626 if (!reqModel)
627 {
628 continue;
629 }
630 vtkIdType m = reqModel->GetNumberOfColumns() - 2;
631 Eigen::MatrixXd cov(m, m);
632 // Fill the cov array with values from the vtkTable
633 vtkIdType i, j;
634 for (j = 2; j < 2 + m; ++j)
635 {
636 for (i = 0; i < j - 1; ++i)
637 {
638 cov(i, j - 2) = reqModel->GetValue(i, j).ToDouble();
639 }
640 }
641 // Fill in the lower triangular portion of the matrix
642 for (j = 0; j < m - 1; ++j)
643 {
644 for (i = j; i < m; ++i)
645 {
646 cov(i, j) = cov(j, i);
647 }
648 }
649 // If normalization of the covariance array is requested, perform it:
650 vtkVariantArray* normData = vtkVariantArray::New();
651 switch (this->NormalizationScheme)
652 {
653 case TRIANGLE_SPECIFIED:
654 case DIAGONAL_SPECIFIED:
655 vtkPCAStatisticsNormalizeSpec(normData, cov, this->GetSpecifiedNormalization(), reqModel,
656 this->NormalizationScheme == TRIANGLE_SPECIFIED);
657 break;
658 case DIAGONAL_VARIANCE:
659 vtkPCAStatisticsNormalizeVariance(normData, cov);
660 break;
661 case NONE:
662 case NUM_NORMALIZATION_SCHEMES:
663 default:
664 // do nothing
665 break;
666 }
667 Eigen::BDCSVD<Eigen::MatrixXd> svd(cov, Eigen::ComputeFullU);
668 const Eigen::MatrixXd& u = svd.matrixU();

Callers 1

RequestDataMethod · 0.45

Calls 15

InsertNextRowMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetNumberOfTablesMethod · 0.45
GetTableMethod · 0.45
GetNumberOfColumnsMethod · 0.45
ToDoubleMethod · 0.45
GetValueMethod · 0.45
matrixUMethod · 0.45

Tested by

no test coverage detected