MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / scale

Method scale

src/data_handler/fastica.cpp:100–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void FastICA::scale (Eigen::Ref<Eigen::MatrixXd> M, bool center, bool normalize,
101 bool ignore_invariants, std::vector<int> *zeros)
102{
103 int rows = (int)M.rows ();
104 Eigen::Array<double, 1, Eigen::Dynamic> means = M.rowwise ().mean ();
105
106 if (normalize)
107 {
108 // TODO: This block has not been tested yet
109 Eigen::Array<double, 1, Eigen::Dynamic> sds =
110 ((M.array ().rowwise () - means).square ().colwise ().sum () / (rows - 1)).sqrt ();
111
112 for (int i = 0; i < sds.size (); i++)
113 {
114 if (sds[i] == 0)
115 {
116 if (!ignore_invariants)
117 return;
118 if (zeros != NULL)
119 zeros->push_back (i);
120 sds[i] = 1.0;
121 }
122 }
123
124 if (center)
125 {
126 M.array ().rowwise () -= means;
127 }
128 M.array ().rowwise () /= sds;
129 }
130 else
131 {
132 M.array ().transpose ().rowwise () -= means;
133 }
134}
135
136void FastICA::random_normal (Eigen::MatrixXd &M)
137{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected