@*
MKLGenerator.tmpl

Created by Joe Hope on 2009-08-22.

Copyright (c) 2009-2012, Joe Hope

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*@
@extends xpdeint.Stochastic.Generators.Generator

@from xpdeint.CallOnceGuards import callOnceGuard
@import random

@def description: Generator for Intel MKL random numbers
@def generatorType: VSLStreamStatePtr
@attr uselib = ['mkl_vsl']

@def seedCount
  @return 1
@end def

@def globals
  @#
  @super
  @#
$generatorType ${generatorName};
  @#
@end def

@def constructArrayUniformRandomNumbers
  @set noiseVector = $parent.parent
vdRngUniform(VSL_METHOD_DUNIFORM_STD, ${generatorName}, _vector_size, reinterpret_cast<real*>(_active_${noiseVector.id}), 0.0, 1.0);
@end def

@*
  Static includes
*@
@#  The callOnceGuard won't work until the same includes are gone from the stochastic feature.
@@callOnceGuard
@def static_includes
  @#
  @super
  @#
#include <mkl_vsl.h>
  @#
@end def


@def initialiseLocalSeeds
  @#
  @super
  @#
vslNewStream(&${generatorName}, VSL_BRNG_MT19937, ${generatorName}_local_seeds[0]);
  @#
@end def
