generates a Vector of N points logarithmically spaced between and including base^a and base^b.
| 238 | |
| 239 | /// generates a Vector of N points logarithmically spaced between and including base^a and base^b. |
| 240 | Vector logspace(double a, double b, unsigned N, double base) { |
| 241 | Vector powers = linspace(a, b, N); |
| 242 | |
| 243 | Vector result(N); |
| 244 | for (unsigned n = 0; n < N; ++n) { |
| 245 | result(n) = std::pow(base, powers(n)); |
| 246 | } |
| 247 | |
| 248 | return result; |
| 249 | } |
| 250 | |
| 251 | /// take the natural logarithm of elements of a Vector |
| 252 | Vector log(const Vector& x) { |