take the natural logarithm of a Matrix
| 227 | |
| 228 | /// take the natural logarithm of a Matrix |
| 229 | Matrix log(const Matrix& v) { |
| 230 | size_t M = v.size1(); |
| 231 | size_t N = v.size2(); |
| 232 | Matrix result(M, N); |
| 233 | for (size_t i = 0; i < M; ++i) { |
| 234 | for (size_t j = 0; j < N; ++j) { |
| 235 | result(i, j) = std::log(v(i, j)); |
| 236 | } |
| 237 | } |
| 238 | return result; |
| 239 | } |
| 240 | |
| 241 | /// take the logarithm of a Matrix with certain base |
| 242 | Matrix log(const Matrix& v, double base) { |