MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / GetEigenVector

Function GetEigenVector

cmp_core/shaders/bc7_encode_kernel.cpp:679–750  ·  view source on GitHub ↗

calculate an eigen vector corresponding to a biggest eigen value will work for non-zero non-negative matricies only

Source from the content-addressed store, hash-verified

677// calculate an eigen vector corresponding to a biggest eigen value
678// will work for non-zero non-negative matricies only
679void GetEigenVector(CGV_FLOAT EigenVector_out[MAX_CHANNELS], // Normalized Eigen Vector output
680 CGV_FLOAT CovarianceVector[MAX_CHANNELS * MAX_CHANNELS], // Covariance Vector
681 CGU_UINT8 channels3or4)
682{ // IN: 3 = RGB or 4 = RGBA
683 CGV_FLOAT vector_covIn[MAX_CHANNELS * MAX_CHANNELS];
684 CGV_FLOAT vector_covOut[MAX_CHANNELS * MAX_CHANNELS];
685 CGV_FLOAT vector_maxCovariance;
686
687 for (CGU_UINT8 ch1 = 0; ch1 < channels3or4; ch1++)
688 for (CGU_UINT8 ch2 = 0; ch2 < channels3or4; ch2++)
689 {
690 vector_covIn[ch1 + ch2 * 4] = CovarianceVector[ch1 + ch2 * 4];
691 }
692
693 vector_maxCovariance = 0;
694
695 for (CGU_UINT8 ch = 0; ch < channels3or4; ch++)
696 {
697 if (vector_covIn[ch + ch * 4] > vector_maxCovariance)
698 vector_maxCovariance = vector_covIn[ch + ch * 4];
699 }
700
701 // Normalize Input Covariance Vector
702 for (CGU_UINT8 ch1 = 0; ch1 < channels3or4; ch1++)
703 for (CGU_UINT8 ch2 = 0; ch2 < channels3or4; ch2++)
704 {
705 if (vector_maxCovariance > 0)
706 vector_covIn[ch1 + ch2 * 4] = vector_covIn[ch1 + ch2 * 4] / vector_maxCovariance;
707 }
708
709 for (CGU_UINT8 ch1 = 0; ch1 < channels3or4; ch1++)
710 {
711 for (CGU_UINT8 ch2 = 0; ch2 < channels3or4; ch2++)
712 {
713 CGV_FLOAT vector_temp_cov = 0;
714 for (CGU_UINT8 ch3 = 0; ch3 < channels3or4; ch3++)
715 {
716 vector_temp_cov = vector_temp_cov + vector_covIn[ch1 + ch3 * 4] * vector_covIn[ch3 + ch2 * 4];
717 }
718 vector_covOut[ch1 + ch2 * 4] = vector_temp_cov;
719 }
720 }
721
722 vector_maxCovariance = 0;
723
724 CGV_INT maxCovariance_channel = 0;
725
726 for (CGU_UINT8 ch = 0; ch < channels3or4; ch++)
727 {
728 if (vector_covOut[ch + ch * 4] > vector_maxCovariance)
729 {
730 maxCovariance_channel = ch;
731 vector_maxCovariance = vector_covOut[ch + ch * 4];
732 }
733 }
734
735 CGV_FLOAT vector_t = 0;
736

Callers 1

GetQuantizeIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected