| 98 | } |
| 99 | |
| 100 | void 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 | |
| 136 | void FastICA::random_normal (Eigen::MatrixXd &M) |
| 137 | { |
nothing calls this directly
no outgoing calls
no test coverage detected