Commit 424c1475b900583dd29e742f9a103c27050a0e94

Authored by David Mayerich
1 parent 00a7e339

added a grid sampling function to spharmonics

Showing 1 changed file with 11 additions and 0 deletions   Show diff stats
stim/math/spharmonics.h
... ... @@ -231,6 +231,17 @@ public:
231 231  
232 232 return fx;
233 233 }
  234 +
  235 + /// Fill an NxN grid with the spherical function for theta = [0 2pi] and phi = [0 pi]
  236 + void grid(T* data, size_t N){
  237 + double dt = stim::TAU / (double)N; //calculate the step size in each direction
  238 + double dp = stim::PI / (double)(N - 1);
  239 + for(size_t ti = 0; ti < N; ti++){
  240 + for(size_t pi = 0; pi < N){
  241 + data[pi * N + ti] = (*this)((double)ti * dt, (double)pi * dp);
  242 + }
  243 + }
  244 + }
234 245 /*
235 246 //overload arithmetic operations
236 247 spharmonics<T> operator*(T rhs) const {
... ...