├── share
├── src
│ └── bi
│ │ ├── bugs.hpp
│ │ ├── cuda
│ │ ├── math
│ │ │ ├── multi_operation.hpp
│ │ │ ├── magma.cu
│ │ │ ├── cublas.cu
│ │ │ ├── sim_temp_vector.hpp
│ │ │ ├── magma.hpp
│ │ │ ├── temp_vector.hpp
│ │ │ ├── sim_temp_matrix.hpp
│ │ │ └── temp_matrix.hpp
│ │ ├── random
│ │ │ ├── RandomKernel.cu
│ │ │ └── RandomGPU.cu
│ │ ├── resampler
│ │ │ ├── misc.hpp
│ │ │ ├── StratifiedResamplerGPU.cuh
│ │ │ ├── MultinomialResamplerGPU.hpp
│ │ │ └── StratifiedResamplerKernel.cuh
│ │ ├── thread.cuh
│ │ ├── updater
│ │ │ ├── StaticUpdaterGPU.cuh
│ │ │ ├── SparseStaticUpdaterGPU.cuh
│ │ │ ├── DynamicUpdaterGPU.cuh
│ │ │ ├── SparseStaticSamplerGPU.cuh
│ │ │ ├── StaticSamplerGPU.cuh
│ │ │ ├── StaticLogDensityGPU.cuh
│ │ │ ├── StaticMaxLogDensityGPU.cuh
│ │ │ ├── StaticUpdaterKernel.cuh
│ │ │ ├── SparseStaticLogDensityGPU.cuh
│ │ │ ├── DynamicSamplerGPU.cuh
│ │ │ ├── DynamicLogDensityGPU.cuh
│ │ │ ├── SparseStaticMaxLogDensityGPU.cuh
│ │ │ ├── DynamicMaxLogDensityGPU.cuh
│ │ │ └── SparseStaticUpdaterKernel.cuh
│ │ ├── cache
│ │ │ └── AncestryCacheKernel.cuh
│ │ └── ode
│ │ │ └── RK4IntegratorGPU.cuh
│ │ ├── bi.cpp
│ │ ├── math
│ │ ├── matrix.hpp
│ │ ├── vector.hpp
│ │ ├── temp_matrix.hpp
│ │ ├── temp_vector.hpp
│ │ ├── io.hpp
│ │ ├── scalar.hpp
│ │ ├── pi.hpp
│ │ ├── gsl.hpp
│ │ ├── loc_vector.hpp
│ │ ├── loc_temp_vector.hpp
│ │ ├── loc_matrix.hpp
│ │ ├── loc_temp_matrix.hpp
│ │ └── sim_temp_vector.hpp
│ │ ├── kd
│ │ └── partition.hpp
│ │ ├── resampler
│ │ ├── RejectionResampler.cpp
│ │ ├── MultinomialResampler.cpp
│ │ ├── StratifiedResampler.cpp
│ │ ├── SystematicResampler.cpp
│ │ ├── MetropolisResampler.cpp
│ │ └── Resampler.cpp
│ │ ├── misc
│ │ ├── macro.hpp
│ │ ├── location.hpp
│ │ ├── exception.hpp
│ │ ├── compile.hpp
│ │ ├── TicToc.hpp
│ │ └── omp.hpp
│ │ ├── null
│ │ ├── SMCNullBuffer.cpp
│ │ ├── MCMCNullBuffer.cpp
│ │ ├── KalmanFilterNullBuffer.cpp
│ │ ├── ParticleFilterNullBuffer.cpp
│ │ ├── InputNullBuffer.cpp
│ │ ├── OptimiserNullBuffer.cpp
│ │ ├── SimulatorNullBuffer.cpp
│ │ ├── OptimiserNullBuffer.hpp
│ │ ├── SMCNullBuffer.hpp
│ │ └── MCMCNullBuffer.hpp
│ │ ├── host
│ │ ├── math
│ │ │ ├── qrupdate.cpp
│ │ │ ├── lapack.cpp
│ │ │ ├── cblas.cpp
│ │ │ ├── sim_temp_vector.hpp
│ │ │ ├── qrupdate.hpp
│ │ │ └── sim_temp_matrix.hpp
│ │ ├── random
│ │ │ └── RandomHost.cpp
│ │ ├── resampler
│ │ │ └── MetropolisResamplerHost.hpp
│ │ └── updater
│ │ │ ├── StaticSamplerMatrixVisitorHost.hpp
│ │ │ ├── StaticLogDensityMatrixVisitorHost.hpp
│ │ │ └── StaticMaxLogDensityMatrixVisitorHost.hpp
│ │ ├── mpi
│ │ ├── mpi.cpp
│ │ └── mpi.hpp
│ │ ├── state
│ │ └── ScheduleIterator.hpp
│ │ ├── typelist
│ │ ├── empty.hpp
│ │ ├── equals.hpp
│ │ ├── pop_front_spec.hpp
│ │ ├── front_spec.hpp
│ │ ├── push_back_spec.hpp
│ │ ├── append.hpp
│ │ ├── front.hpp
│ │ ├── index.hpp
│ │ ├── contains.hpp
│ │ ├── typelist.hpp
│ │ ├── back.hpp
│ │ ├── push_front.hpp
│ │ ├── push_front_list.hpp
│ │ └── runtime.hpp
│ │ ├── concept
│ │ ├── Norm.hpp
│ │ ├── Kernel.hpp
│ │ ├── ConditionalPdf.hpp
│ │ └── Partitioner.hpp
│ │ ├── traits
│ │ ├── resampler_traits.hpp
│ │ └── dim_traits.hpp
│ │ ├── method
│ │ └── misc.hpp
│ │ ├── random
│ │ └── Random.cpp
│ │ ├── sse
│ │ └── math
│ │ │ └── scalar.hpp
│ │ ├── buffer
│ │ └── buffer.hpp
│ │ ├── netcdf
│ │ ├── NetCDFBuffer.cpp
│ │ └── NetCDFBuffer.hpp
│ │ ├── init.hpp
│ │ ├── primitive
│ │ ├── cross_range.hpp
│ │ ├── repeated_sequence.hpp
│ │ ├── stuttered_sequence.hpp
│ │ ├── pitched_range.hpp
│ │ ├── strided_range.hpp
│ │ └── strided_pitched_range.hpp
│ │ └── ode
│ │ └── IntegratorConstants.hpp
├── tt
│ ├── package
│ │ ├── config.conf.tt
│ │ ├── VERSION.md.tt
│ │ ├── run.sh.tt
│ │ ├── init.sh.tt
│ │ ├── MANIFEST.tt
│ │ ├── META.yml.tt
│ │ ├── README.md.tt
│ │ └── Model.bi.tt
│ ├── bi
│ │ ├── var_group.bi.tt
│ │ ├── const.bi.tt
│ │ ├── inline.bi.tt
│ │ ├── dim.bi.tt
│ │ ├── var.bi.tt
│ │ ├── macro
│ │ │ ├── dim_list.bi.tt
│ │ │ └── arg_list.bi.tt
│ │ ├── action.bi.tt
│ │ ├── block.bi.tt
│ │ └── model.bi.tt
│ ├── cpp
│ │ ├── test
│ │ │ ├── test_filter_gpu.cu.tt
│ │ │ ├── test_gpu.cu.tt
│ │ │ └── test_resampler_gpu.cu.tt
│ │ ├── action
│ │ │ ├── misc
│ │ │ │ ├── footer.hpp.tt
│ │ │ │ └── header.hpp.tt
│ │ │ ├── cholesky.hpp.tt
│ │ │ ├── std_.hpp.tt
│ │ │ ├── transpose.hpp.tt
│ │ │ ├── exclusive_scan.hpp.tt
│ │ │ ├── inclusive_scan.hpp.tt
│ │ │ ├── eval_.hpp.tt
│ │ │ ├── gemm_.hpp.tt
│ │ │ ├── gemv_.hpp.tt
│ │ │ └── ode_.hpp.tt
│ │ ├── block
│ │ │ ├── misc
│ │ │ │ ├── footer.hpp.tt
│ │ │ │ └── header.hpp.tt
│ │ │ ├── initial.hpp.tt
│ │ │ ├── bridge.hpp.tt
│ │ │ ├── proposal_initial.hpp.tt
│ │ │ ├── lookahead_transition.hpp.tt
│ │ │ ├── proposal_parameter.hpp.tt
│ │ │ ├── lookahead_observation.hpp.tt
│ │ │ ├── matrix_.hpp.tt
│ │ │ ├── parameter.hpp.tt
│ │ │ ├── wiener_.hpp.tt
│ │ │ ├── std_.hpp.tt
│ │ │ └── const_std_.hpp.tt
│ │ ├── client
│ │ │ ├── filter_gpu.cu.tt
│ │ │ ├── sample_gpu.cu.tt
│ │ │ ├── optimise_gpu.cu.tt
│ │ │ └── misc
│ │ │ │ └── header.cpp.tt
│ │ ├── macro
│ │ │ ├── put_output.hpp.tt
│ │ │ ├── create_action_typedef.hpp.tt
│ │ │ ├── create_block_typedef.hpp.tt
│ │ │ ├── create_action_typetree.hpp.tt
│ │ │ ├── create_action_typelist.hpp.tt
│ │ │ ├── create_block_typelist.hpp.tt
│ │ │ ├── alias_dims.hpp.tt
│ │ │ ├── std_action.hpp.tt
│ │ │ └── offset_coord.hpp.tt
│ │ ├── model.cpp.tt
│ │ ├── macro.hpp.tt
│ │ └── dim.hpp.tt
│ └── dot
│ │ ├── action.dot.tt
│ │ ├── model.dot.tt
│ │ ├── block.dot.tt
│ │ └── var.dot.tt
├── autogen.sh
├── nvcc_wrapper.pl
└── bi.lex
├── docs
├── .gitignore
└── pdf
│ └── manual.pdf
├── t
├── 001_load.t
├── 010_cpu.t
├── 002_help.t
├── 003_gen.t
└── 004_build_tools.t
├── MakeManifest.PL
├── test.conf
├── MakeParser.PL
├── .includepath
├── .gitignore
├── Test.bi
├── lib
└── Bi
│ ├── Action
│ ├── normal.pm
│ ├── log_normal.pm
│ ├── truncated_normal.pm
│ ├── log_gaussian.pm
│ ├── wiener.pm
│ ├── exclusive_scan.pm
│ ├── inclusive_scan.pm
│ └── transpose.pm
│ ├── Client
│ ├── optimize.pm
│ ├── rewrite.pm
│ └── draw.pm
│ ├── Block
│ ├── eval_.pm
│ ├── matrix_.pm
│ ├── pdf_.pm
│ ├── cholesky_.pm
│ ├── bridge.pm
│ ├── wiener_.pm
│ ├── proposal_parameter.pm
│ ├── lookahead_observation.pm
│ ├── lookahead_transition.pm
│ ├── std_.pm
│ ├── proposal_initial.pm
│ ├── const_std_.pm
│ ├── common_std_.pm
│ ├── observation.pm
│ └── orthogonal_std_.pm
│ ├── Test
│ └── test.pm
│ ├── Visitor
│ ├── EvalConst.pm
│ └── TargetReplacer.pm
│ └── Visitor.pm
├── MANIFEST.SKIP
├── inc
└── Module
│ └── Install
│ ├── Scripts.pm
│ ├── Base.pm
│ └── WriteAll.pm
├── script
├── libbi
└── bi
├── README.md
├── .project
├── Makefile.PL
└── INSTALL_LINUX.md
/share/src/bi/bugs.hpp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | /tex
2 | /dev
3 |
--------------------------------------------------------------------------------
/share/tt/package/config.conf.tt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/share/tt/package/VERSION.md.tt:
--------------------------------------------------------------------------------
1 | v1.0.0
2 | ------
3 |
4 | * First version.
5 |
--------------------------------------------------------------------------------
/t/001_load.t:
--------------------------------------------------------------------------------
1 | use Test::More tests => 1;
2 |
3 | BEGIN { use_ok('Bi'); }
4 |
--------------------------------------------------------------------------------
/share/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #libtoolize
4 | autoreconf --install
5 |
6 |
--------------------------------------------------------------------------------
/docs/pdf/manual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JohannesBuchner/LibBi/master/docs/pdf/manual.pdf
--------------------------------------------------------------------------------
/MakeManifest.PL:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | use ExtUtils::Manifest qw(mkmanifest);
4 |
5 | mkmanifest;
6 |
--------------------------------------------------------------------------------
/t/010_cpu.t:
--------------------------------------------------------------------------------
1 | use Test::More tests => 1;
2 |
3 | is(system('script/libbi sample @test.conf') >> 8, 0, 'CPU');
4 |
--------------------------------------------------------------------------------
/share/tt/package/run.sh.tt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | libbi sample @config.conf --target prior --model-file [% name %].bi
4 |
--------------------------------------------------------------------------------
/test.conf:
--------------------------------------------------------------------------------
1 | --target prior
2 | --model-file Test.bi
3 | --end-time 1
4 | --nsamples 32
5 | --output-file test.nc
6 |
--------------------------------------------------------------------------------
/t/002_help.t:
--------------------------------------------------------------------------------
1 | use Test::More tests => 1;
2 |
3 | is(system('script/libbi help >/dev/null') >> 8, 0, 'help system');
4 |
--------------------------------------------------------------------------------
/MakeParser.PL:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | `mkdir -p lib/Parse`;
4 | `yapp -m Parse::Bi -o lib/Parse/Bi.pm share/bi.yp`;
5 |
--------------------------------------------------------------------------------
/.includepath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/share/tt/bi/var_group.bi.tt:
--------------------------------------------------------------------------------
1 |
2 | // Variable group [% var_group.get_name %]
3 | [% INCLUDE var.bi.tt FOREACH var IN var_group.get_vars-%]
4 |
--------------------------------------------------------------------------------
/share/tt/package/init.sh.tt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | libbi sample @config.conf --target joint --model-file [% name %].bi --output-file data/obs.nc
4 |
--------------------------------------------------------------------------------
/t/003_gen.t:
--------------------------------------------------------------------------------
1 | use Test::More tests => 1;
2 |
3 | is(system('script/libbi sample @test.conf --dry-build --dry-run') >> 8, 0, 'code generation');
4 |
--------------------------------------------------------------------------------
/share/tt/cpp/test/test_filter_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | %]
6 |
7 | #include "test_filter_cpu.cpp"
8 |
--------------------------------------------------------------------------------
/share/tt/package/MANIFEST.tt:
--------------------------------------------------------------------------------
1 | MANIFEST
2 | LICENSE
3 | META.yml
4 | README.md
5 | VERSION.md
6 | init.sh
7 | run.sh
8 | [% name %].bi
9 | config.conf
10 | data
11 |
--------------------------------------------------------------------------------
/share/tt/package/META.yml.tt:
--------------------------------------------------------------------------------
1 | name: [% name %]
2 | version: 1.0.0
3 | author:
4 | email:
5 | website-url:
6 | download-url:
7 | github-url:
8 | description:
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /Makefile
2 | /MANIFEST.bak
3 | /META.yml
4 | /MYMETA.json
5 | /MYMETA.yml
6 | /Makefile.old
7 | /.LibBi
8 | /.Test
9 | /blib
10 | /pm_to_blib
11 | /test.nc
12 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/misc/footer.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/misc/footer.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/test/test_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | #include "test_cpu.cpp"
10 |
--------------------------------------------------------------------------------
/share/tt/bi/const.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | const [% const.get_name %] = [% const.get_expr.to_bi %]
9 |
--------------------------------------------------------------------------------
/share/tt/bi/inline.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | inline [% inline.get_name %] = [% inline.get_expr.to_bi %]
9 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/initial.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS block/parameter.hpp.tt-%]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/bridge.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [% PROCESS block/observation.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/proposal_initial.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [% PROCESS block/initial.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/test/test_resampler_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | #include "test_resampler_cpu.cpp"
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/lookahead_transition.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [% PROCESS block/transition.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/proposal_parameter.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [% PROCESS block/parameter.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/lookahead_observation.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [% PROCESS block/observation.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/bi/dim.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | PROCESS macro/arg_list.bi.tt
8 | -%]
9 | dim [% dim.get_name %][% arg_list(dim) %]
10 |
--------------------------------------------------------------------------------
/share/tt/package/README.md.tt:
--------------------------------------------------------------------------------
1 | LibBi package: [% name %]
2 | =========================
3 |
4 | Synopsis
5 | --------
6 |
7 | ./run.sh
8 |
9 | Description
10 | -----------
11 |
12 |
13 | References
14 | ----------
15 |
--------------------------------------------------------------------------------
/share/tt/cpp/client/filter_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS client/misc/header.cpp.tt-%]
10 |
11 | #include "filter_cpu.cpp"
12 |
--------------------------------------------------------------------------------
/share/tt/cpp/client/sample_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS client/misc/header.cpp.tt-%]
10 |
11 | #include "sample_cpu.cpp"
12 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/matrix_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev: 3232 $
6 | ## $Date: 2012-10-16 14:09:21 +0800 (Tue, 16 Oct 2012) $
7 | %]
8 |
9 | [%-PROCESS block/eval_.hpp.tt %]
10 |
--------------------------------------------------------------------------------
/share/tt/cpp/client/optimise_gpu.cu.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS client/misc/header.cpp.tt-%]
10 |
11 | #include "optimise_cpu.cpp"
12 |
--------------------------------------------------------------------------------
/share/tt/bi/var.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | PROCESS macro/dim_list.bi.tt
8 | -%]
9 | [% var.get_type %] [% var.get_name %][% dim_list(var) %][% arg_list(var) %]
10 |
--------------------------------------------------------------------------------
/t/004_build_tools.t:
--------------------------------------------------------------------------------
1 | use Test::More tests => 3;
2 |
3 | is(system('make --version >/dev/null') >> 8, 0, 'make presence');
4 | is(system('automake --version >/dev/null') >> 8, 0, 'automake presence');
5 | is(system('autoconf --version >/dev/null') >> 8, 0, 'autoconf presence');
6 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/math/multi_operation.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_CUDA_MATH_MULTIOPERATION_HPP
9 | #define BI_CUDA_MATH_MULTIOPERATION_HPP
10 |
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/share/tt/dot/action.dot.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-FOREACH ref IN action.get_all_right_var_refs %]
9 | [% ref.get_var.get_name %] -> [% action.get_left.get_var.get_name %];
10 | [%-END-%]
11 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/put_output.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO put_output(action, expr) BLOCK-%]
9 | x.template fetch(s, p, cox_.index()) = [% expr.to_cpp %];
10 | [%-END-%]
11 |
--------------------------------------------------------------------------------
/share/src/bi/bi.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * This file exists only to readily facilitate autoconf checks for the
5 | * presence of libbi.
6 | *
7 | * @author Lawrence Murray
8 | * $Rev$
9 | * $Date$
10 | */
11 | int main(int argc, char** argv) {
12 | //
13 | }
14 |
--------------------------------------------------------------------------------
/share/src/bi/math/matrix.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_MATRIX_HPP
9 | #define BI_MATH_MATRIX_HPP
10 |
11 | #include "../host/math/matrix.hpp"
12 | #ifdef ENABLE_CUDA
13 | #include "../cuda/math/matrix.hpp"
14 | #endif
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/share/src/bi/math/vector.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_VECTOR_HPP
9 | #define BI_MATH_VECTOR_HPP
10 |
11 | #include "../host/math/vector.hpp"
12 | #ifdef ENABLE_CUDA
13 | #include "../cuda/math/vector.hpp"
14 | #endif
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/Test.bi:
--------------------------------------------------------------------------------
1 | model Test {
2 | param theta, sigma2;
3 | noise w;
4 | state x;
5 |
6 | sub parameter {
7 | theta ~ gaussian();
8 | sigma2 ~ inverse_gamma();
9 | }
10 |
11 | sub initial {
12 | x ~ gaussian();
13 | }
14 |
15 | sub transition {
16 | w ~ gaussian(0.0, sqrt(sigma2));
17 | x <- theta*x + w;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/share/src/bi/kd/partition.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_KD_PARTITION_HPP
9 | #define BI_KD_PARTITION_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Partitions.
14 | */
15 | enum Partition {
16 | LEFT,
17 | RIGHT
18 | };
19 | }
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/RejectionResampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "RejectionResampler.hpp"
9 |
10 | bi::RejectionResampler::RejectionResampler() :
11 | Resampler(1.0, 1.0) {
12 | // ^ the arguments (0.0, 0.0) force resampling at all times.
13 | }
14 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/cholesky.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | %]
6 |
7 | [%-PROCESS action/misc/header.hpp.tt-%]
8 |
9 | /**
10 | * Action: [% action.get_name %].
11 | */
12 | class [% class_name %] {
13 | public:
14 | [% std_action %]
15 |
16 | };
17 |
18 | [%-PROCESS action/misc/footer.hpp.tt-%]
19 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/create_action_typedef.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO create_action_typedef(block) BLOCK %]
9 | /**
10 | * Type list for actions.
11 | */
12 | typedef GET_TYPETREE(Block[% block.get_id %]ActionTypeList) action_typelist;
13 | [% END-%]
14 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/create_block_typedef.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO create_block_typedef(block) BLOCK %]
9 | /**
10 | * Type list of sub-blocks.
11 | */
12 | typedef GET_TYPETREE(Block[% block.get_id %]BlockTypeList) block_typelist;
13 | [% END-%]
14 |
--------------------------------------------------------------------------------
/share/src/bi/math/temp_matrix.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_TEMPMATRIX_HPP
9 | #define BI_MATH_TEMPMATRIX_HPP
10 |
11 | #include "../host/math/temp_matrix.hpp"
12 | #ifdef ENABLE_CUDA
13 | #include "../cuda/math/temp_matrix.hpp"
14 | #endif
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/share/src/bi/math/temp_vector.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_TEMPVECTOR_HPP
9 | #define BI_MATH_TEMPVECTOR_HPP
10 |
11 | #include "../host/math/temp_vector.hpp"
12 | #ifdef ENABLE_CUDA
13 | #include "../cuda/math/temp_vector.hpp"
14 | #endif
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/lib/Bi/Action/normal.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | normal - normal distribution, synonym of L.
4 |
5 | =head1 SEE ALSO
6 |
7 | L
8 |
9 | =cut
10 |
11 | package Bi::Action::normal;
12 |
13 | use parent 'Bi::Action::gaussian';
14 |
15 | 1;
16 |
17 | =head1 AUTHOR
18 |
19 | Lawrence Murray
20 |
21 | =head1 VERSION
22 |
23 | $Rev$ $Date$
24 |
--------------------------------------------------------------------------------
/share/src/bi/math/io.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * IO functions for matrix and vector types.
5 | *
6 | * @author Lawrence Murray
7 | * $Rev$
8 | * $Date$
9 | */
10 | #ifndef BI_MATH_IO_HPP
11 | #define BI_MATH_IO_HPP
12 |
13 | #include "../host/math/io.hpp"
14 | #ifdef ENABLE_CUDA
15 | #include "../cuda/math/io.hpp"
16 | #endif
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/share/tt/bi/macro/dim_list.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 |
9 | [%-MACRO dim_list(var) BLOCK-%]
10 | [%-'[' IF var.get_dims.size-%]
11 | [%-FOREACH dim IN var.get_dims-%]
12 | [%-dim.get_name-%]
13 | [%-IF !loop.last %],[% END-%]
14 | [%-END-%]
15 | [%-']' IF var.get_dims.size-%]
16 | [%-END-%]
17 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/create_action_typetree.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO create_action_typetree(block) BLOCK-%]
9 | /**
10 | * Type tree for actions.
11 | */
12 | BEGIN_TYPETREE(Block[% block.get_id %]ActionTypeList)
13 | [% block.get_actions.to_typetree %]
14 | END_TYPETREE()
15 | [% END %]
16 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/MultinomialResampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "MultinomialResampler.hpp"
9 |
10 | bi::MultinomialResampler::MultinomialResampler(const bool sort,
11 | const double essRel, const double bridgeEssRel) :
12 | Resampler(essRel, bridgeEssRel), sort(sort) {
13 | //
14 | }
15 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/StratifiedResampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "StratifiedResampler.hpp"
9 |
10 | bi::StratifiedResampler::StratifiedResampler(const bool sort,
11 | const double essRel, const double bridgeEssRel) :
12 | Resampler(essRel, bridgeEssRel), sort(sort) {
13 | //
14 | }
15 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/SystematicResampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "SystematicResampler.hpp"
9 |
10 | bi::SystematicResampler::SystematicResampler(const bool sort,
11 | const double essRel, const double bridgeEssRel) :
12 | Resampler(essRel, bridgeEssRel), sort(sort) {
13 | //
14 | }
15 |
--------------------------------------------------------------------------------
/lib/Bi/Action/log_normal.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | log_normal - log-normal distribution, synonym of L.
4 |
5 | =head1 SEE ALSO
6 |
7 | L
8 |
9 | =cut
10 |
11 | package Bi::Action::log_normal;
12 |
13 | use parent 'Bi::Action::gaussian';
14 |
15 | 1;
16 |
17 | =head1 AUTHOR
18 |
19 | Lawrence Murray
20 |
21 | =head1 VERSION
22 |
23 | $Rev$ $Date$
24 |
--------------------------------------------------------------------------------
/MANIFEST.SKIP:
--------------------------------------------------------------------------------
1 | ~$
2 | \.svn
3 | \.git
4 | \.Bi
5 | \.LibBi
6 | \.Test
7 | \.#MANIFEST.SKIP
8 | \.includepath
9 | \.project
10 | ^MANIFEST\.bak$
11 | ^docs/dev
12 | ^docs/html
13 | ^docs/tex
14 | ^eclipse
15 | ^LibBi.*
16 | ^libbi.*
17 | ^Makefile$
18 | ^Makefile\.old$
19 | ^MakeManifest.PL$
20 | ^MANIFEST$
21 | ^MANIFEST.SKIP$
22 | ^META.yml$
23 | ^MYMETA.json$
24 | ^MYMETA.yml$
25 | ^_site
26 | ^blib
27 | ^pm_to_blib
28 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/std_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev: 3273 $
6 | ## $Date: 2012-11-05 13:26:38 +0800 (Mon, 05 Nov 2012) $
7 | %]
8 |
9 | [%-PROCESS action/misc/header.hpp.tt-%]
10 |
11 | /**
12 | * Action: [% action.get_name %].
13 | */
14 | struct [% class_name %] {
15 | [% std_action %]
16 | };
17 |
18 | [%-PROCESS action/misc/footer.hpp.tt-%]
19 |
--------------------------------------------------------------------------------
/share/src/bi/misc/macro.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | *
8 | * Useful macros for defining other macros...
9 | */
10 | #ifndef BI_MISC_MACRO_HPP
11 | #define BI_MISC_MACRO_HPP
12 |
13 | /**
14 | * @def MACRO_QUOTE
15 | *
16 | * @arg x
17 | *
18 | * Quotes macro argument as string
19 | */
20 | #define MACRO_QUOTE(x) #x
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/share/src/bi/null/SMCNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Pierre Jacob
5 | * $Rev $
6 | * $Date$
7 | */
8 | #include "SMCNullBuffer.hpp"
9 |
10 | bi::SMCNullBuffer::SMCNullBuffer(const Model& m, const size_t P,
11 | const size_t T, const std::string& file, const FileMode mode,
12 | const SchemaMode schema) :
13 | MCMCNullBuffer(m, P, T, file, mode, schema) {
14 | //
15 | }
16 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/random/RandomKernel.cu:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "RandomKernel.cuh"
9 |
10 | CUDA_FUNC_GLOBAL void bi::kernelSeeds(curandStateSA rng, const unsigned seed) {
11 | const int p = blockIdx.x*blockDim.x + threadIdx.x;
12 | RngGPU rng1;
13 | rng.load(p, rng1.r);
14 | rng1.seed(seed);
15 | rng.store(p, rng1.r);
16 | }
17 |
--------------------------------------------------------------------------------
/share/src/bi/null/MCMCNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "MCMCNullBuffer.hpp"
9 |
10 | bi::MCMCNullBuffer::MCMCNullBuffer(const Model& m, const size_t P,
11 | const size_t T, const std::string& file, const FileMode mode,
12 | const SchemaMode schema) :
13 | SimulatorNullBuffer(m, P, T, file, mode, schema) {
14 | //
15 | }
16 |
--------------------------------------------------------------------------------
/lib/Bi/Client/optimize.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | optimize - optimization of the parameters of a model.
4 |
5 | =head1 SEE ALSO
6 |
7 | L
8 |
9 | =cut
10 |
11 | package Bi::Client::optimize;
12 |
13 | use parent 'Bi::Client::optimise';
14 |
15 | 1;
16 |
17 | =head1 AUTHOR
18 |
19 | Lawrence Murray
20 |
21 | =head1 VERSION
22 |
23 | $Rev: 3483 $ $Date: 2013-02-13 12:08:35 +0800 (Wed, 13 Feb 2013) $
24 |
25 |
--------------------------------------------------------------------------------
/lib/Bi/Action/truncated_normal.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | truncated_normal - truncated normal distribution, synonym of
4 | L.
5 |
6 | =head1 SEE ALSO
7 |
8 | L
9 |
10 | =cut
11 |
12 | package Bi::Action::truncated_normal;
13 |
14 | use parent 'Bi::Action::truncated_gaussian';
15 |
16 | 1;
17 |
18 | =head1 AUTHOR
19 |
20 | Lawrence Murray
21 |
22 | =head1 VERSION
23 |
24 | $Rev$ $Date$
25 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/create_action_typelist.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO create_action_typelist(block) BLOCK-%]
9 | /**
10 | * Type list for actions.
11 | */
12 | BEGIN_TYPELIST(Block[% block.get_id %]ActionTypeList)
13 | [% FOREACH action IN block.get_actions-%]
14 | SINGLE_TYPE(1, Action[% action.get_id %])
15 | [% END-%]
16 | END_TYPELIST()
17 | [% END %]
18 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/create_block_typelist.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO create_block_typelist(block) BLOCK %]
9 | /**
10 | * Type list of sub-blocks.
11 | */
12 | BEGIN_TYPELIST(Block[% block.get_id %]BlockTypeList)
13 | [% FOREACH subblock IN block.get_blocks-%]
14 | SINGLE_TYPE(1, Block[% subblock.get_id %])
15 | [% END-%]
16 | END_TYPELIST()
17 | [% END-%]
18 |
--------------------------------------------------------------------------------
/lib/Bi/Block/eval_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | eval- - scalar expression block.
4 |
5 | =cut
6 |
7 | package Bi::Block::eval_;
8 |
9 | use parent 'Bi::Block';
10 | use warnings;
11 | use strict;
12 |
13 | our $BLOCK_ARGS = [];
14 |
15 | sub validate {
16 | my $self = shift;
17 |
18 | $self->process_args($BLOCK_ARGS);
19 | }
20 |
21 | 1;
22 |
23 | =head1 AUTHOR
24 |
25 | Lawrence Murray
26 |
27 | =head1 VERSION
28 |
29 | $Rev$ $Date$
30 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/MetropolisResampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "MetropolisResampler.hpp"
9 |
10 | bi::MetropolisResampler::MetropolisResampler(const int B, const double essRel,
11 | const double bridgeEssRel) :
12 | Resampler(essRel, bridgeEssRel), B(B) {
13 | //
14 | }
15 |
16 | void bi::MetropolisResampler::setSteps(const int B) {
17 | this->B = B;
18 | }
19 |
--------------------------------------------------------------------------------
/share/src/bi/host/math/qrupdate.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "qrupdate.hpp"
9 |
10 | #define QRUPDATE_FUNC_DEF(name, dname, sname) \
11 | BOOST_TYPEOF(sname##_) *bi::qrupdate_##name::func = sname##_; \
12 | BOOST_TYPEOF(dname##_) *bi::qrupdate_##name::func = dname##_;
13 |
14 | QRUPDATE_FUNC_DEF(ch1up, dch1up, sch1up)
15 | QRUPDATE_FUNC_DEF(ch1dn, dch1dn, sch1dn)
16 |
--------------------------------------------------------------------------------
/share/tt/dot/model.dot.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | digraph model {
9 | compound=true;
10 | overlap=scale;
11 | splines=true;
12 | sep=.2;
13 | d2tgraphstyle="scale=0.6"
14 | nslimit=4.0;
15 | mclimit=4.0;
16 |
17 | [% FOREACH name IN ['parameter', 'transition', 'observation'] %]
18 | [%-INCLUDE block.dot.tt block = model.get_block(name) FILTER indent(2) %]
19 | [%-END-%]
20 | }
21 |
--------------------------------------------------------------------------------
/share/src/bi/mpi/mpi.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "mpi.hpp"
9 |
10 | #include
11 |
12 | std::string bi::append_rank(const std::string& name) {
13 | #ifdef ENABLE_MPI
14 | boost::mpi::communicator world;
15 | std::stringstream stream;
16 |
17 | stream << name << '.' << world.rank();
18 |
19 | return stream.str();
20 | #else
21 | return name;
22 | #endif
23 | }
24 |
--------------------------------------------------------------------------------
/share/tt/package/Model.bi.tt:
--------------------------------------------------------------------------------
1 | /**
2 | * [% name %] model.
3 | */
4 | model [% name %] {
5 | // declare constants...
6 | // declare dimensions...
7 | // declare variables...
8 |
9 | sub parameter {
10 | // specify the parameter model
11 | }
12 |
13 | sub initial {
14 | // specify the initial condition model
15 | }
16 |
17 | sub transition {
18 | // specify the transition model
19 | }
20 |
21 | sub observation {
22 | // specify the observation model
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/alias_dims.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO alias_dims(action) BLOCK %]
9 | [%-un = 0-%]
10 | [%-FOREACH alias IN action.get_aliases %]
11 | [%-IF alias.has_name -%]
12 | BI_UNUSED const int [% alias.get_name %]_ = cox.i[% loop.index %];
13 | [%-ELSE-%]
14 | BI_UNUSED const int un[% un; un = un + 1 %] = cox.i[% loop.index %];
15 | [%-END-%]
16 | [%-END %]
17 | [%-END-%]
18 |
--------------------------------------------------------------------------------
/share/src/bi/state/ScheduleIterator.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_STATE_SCHEDULEITERATOR_HPP
9 | #define BI_STATE_SCHEDULEITERATOR_HPP
10 |
11 | #include "ScheduleElement.hpp"
12 |
13 | #include
14 |
15 | namespace bi {
16 | /**
17 | * Iterator over Schedule.
18 | *
19 | * @ingroup state
20 | */
21 | typedef std::vector::const_iterator ScheduleIterator;
22 | }
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/share/src/bi/host/math/lapack.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "lapack.hpp"
9 |
10 | #define LAPACK_FUNC_DEF(name, dname, sname) \
11 | BOOST_TYPEOF(sname##_) *bi::lapack_##name::func = sname##_; \
12 | BOOST_TYPEOF(dname##_) *bi::lapack_##name::func = dname##_;
13 |
14 | LAPACK_FUNC_DEF(potrf, dpotrf, spotrf)
15 | LAPACK_FUNC_DEF(potrs, dpotrs, spotrs)
16 | LAPACK_FUNC_DEF(syevx, dsyevx, ssyevx)
17 |
--------------------------------------------------------------------------------
/share/src/bi/misc/location.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MISC_LOCATION_HPP
9 | #define BI_MISC_LOCATION_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Tags for location-specific data types and operations.
14 | */
15 | enum Location {
16 | /**
17 | * Locate object on host.
18 | */
19 | ON_HOST = 0,
20 |
21 | /**
22 | * Locate object on device.
23 | */
24 | ON_DEVICE = 1
25 | };
26 | }
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/share/tt/cpp/client/misc/header.cpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-
10 | IF have_model;
11 | class_name = "Model" _ model.get_name;
12 | ELSE;
13 | class_name = "Model";
14 | END;
15 | -%]
16 |
17 | /**
18 | * @file
19 | *
20 | * @author Generated by LibBi
21 | * $Rev$
22 | * $Date$
23 | */
24 | #ifdef ENABLE_GPERFTOOLS
25 | #include "google/profiler.h"
26 | #endif
27 | #include "bi/init.hpp"
28 | #include "bi/cuda/cuda.hpp"
29 | #include "bi/mpi/mpi.hpp"
30 |
--------------------------------------------------------------------------------
/share/src/bi/mpi/mpi.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MPI_MPI_HPP
9 | #define BI_MPI_MPI_HPP
10 |
11 | #ifdef ENABLE_MPI
12 | #include
13 | #include "boost/mpi/environment.hpp"
14 | #include "boost/mpi/communicator.hpp"
15 | #endif
16 |
17 | #include
18 |
19 | namespace bi {
20 | /**
21 | * Append rank to file name.
22 | *
23 | * @param name File name.
24 | */
25 | std::string append_rank(const std::string& name);
26 |
27 | }
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/share/src/bi/null/KalmanFilterNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "KalmanFilterNullBuffer.hpp"
9 |
10 | bi::KalmanFilterNullBuffer::KalmanFilterNullBuffer(const Model& m,
11 | const size_t P, const size_t T, const std::string& file,
12 | const FileMode mode, const SchemaMode schema) :
13 | SimulatorNullBuffer(m, P, T, file, mode, schema) {
14 | //
15 | }
16 |
17 | void bi::KalmanFilterNullBuffer::writeLogLikelihood(const real ll) {
18 | //
19 | }
20 |
--------------------------------------------------------------------------------
/share/src/bi/null/ParticleFilterNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "ParticleFilterNullBuffer.hpp"
9 |
10 | bi::ParticleFilterNullBuffer::ParticleFilterNullBuffer(const Model& m,
11 | const size_t P, const size_t T, const std::string& file,
12 | const FileMode mode, const SchemaMode schema) :
13 | SimulatorNullBuffer(m, P, T, file, mode, schema) {
14 | //
15 | }
16 |
17 | void bi::ParticleFilterNullBuffer::writeLogLikelihood(const real ll) {
18 | //
19 | }
20 |
--------------------------------------------------------------------------------
/share/tt/bi/action.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | PROCESS macro/arg_list.bi.tt
8 | -%]
9 |
10 | [%-action.get_left.get_var.get_name-%]
11 | [%-IF action.get_aliases.size-%]
12 | [[% FOREACH alias IN action.get_aliases %][% IF alias.has_name %][% alias.get_name %][% IF alias.has_range %]=[% END %][% END %][% IF alias.has_range %][% alias.get_range.to_bi %][% END %][% IF !loop.last %],[% END %][% END %]]
13 | [%-END-%] [% action.get_op %] [% action.get_name %][% arg_list(action) %] // Action[% action.get_id %]
14 |
--------------------------------------------------------------------------------
/lib/Bi/Block/matrix_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | matrix_ - matrix expression block.
4 |
5 | =head1 DESCRIPTION
6 |
7 | This block behaves the same as L, but is required to group matrix
8 | actions into separate blocks from scalar actions.
9 |
10 | =cut
11 |
12 | package Bi::Block::matrix_;
13 |
14 | use parent 'Bi::Block';
15 | use warnings;
16 | use strict;
17 |
18 | our $BLOCK_ARGS = [];
19 |
20 | sub validate {
21 | my $self = shift;
22 |
23 | $self->process_args($BLOCK_ARGS);
24 | }
25 |
26 | 1;
27 |
28 | =head1 AUTHOR
29 |
30 | Lawrence Murray
31 |
--------------------------------------------------------------------------------
/share/tt/bi/macro/arg_list.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 |
9 | [%-MACRO arg_list(item) BLOCK-%]
10 | [%-'(' IF (item.num_args || item.num_named_args)-%]
11 | [%-FOREACH arg IN item.get_args-%]
12 | [%-arg.to_bi %][% IF !(loop.last && item.num_named_args == 0) %], [% END-%]
13 | [%-END-%]
14 | [%-FOREACH name IN item.get_named_args.keys.sort-%]
15 | [%-name %] = [% item.get_named_args.$name.to_bi %][% IF !loop.last %], [% END-%]
16 | [%-END-%]
17 | [%-')' IF (item.num_args || item.num_named_args)-%]
18 | [%-END-%]
19 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/resampler/misc.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_CUDA_RESAMPLER_MISC_HPP
9 | #define BI_CUDA_RESAMPLER_MISC_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Placeholder for passing as argument to kernels to enable pre-permute.
14 | */
15 | enum EnablePrePermute {
16 | ENABLE_PRE_PERMUTE = 1
17 | };
18 |
19 | /**
20 | * Placeholder for passing as argument to kernels to disable pre-permute.
21 | */
22 | enum DisablePrePermute {
23 | DISABLE_PRE_PERMUTE = 0
24 | };
25 |
26 | }
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/share/src/bi/resampler/Resampler.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "Resampler.hpp"
9 |
10 | bi::Resampler::Resampler(const double essRel, const double bridgeEssRel) :
11 | essRel(essRel), bridgeEssRel(bridgeEssRel), maxLogWeight(0.0) {
12 | /* pre-condition */
13 | BI_ASSERT(essRel >= 0.0 && essRel <= 1.0);
14 | BI_ASSERT(bridgeEssRel >= 0.0 && bridgeEssRel <= 1.0);
15 |
16 | //
17 | }
18 |
19 | void bi::Resampler::setMaxLogWeight(const double maxLogWeight) {
20 | this->maxLogWeight = maxLogWeight;
21 | }
22 |
--------------------------------------------------------------------------------
/share/src/bi/null/InputNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "InputNullBuffer.hpp"
9 |
10 | bi::InputNullBuffer::InputNullBuffer(const Model& m,
11 | const std::string& file, const long ns, const long np) {
12 | //
13 | }
14 |
15 | void bi::InputNullBuffer::readMask(const size_t k, const VarType type,
16 | Mask& mask) {
17 | BI_ERROR_MSG(false, "time index outside valid range");
18 | }
19 |
20 | void bi::InputNullBuffer::readMask0(const VarType type,
21 | Mask& mask) {
22 | mask.clear();
23 | }
24 |
--------------------------------------------------------------------------------
/share/src/bi/null/OptimiserNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "OptimiserNullBuffer.hpp"
9 |
10 | bi::OptimiserNullBuffer::OptimiserNullBuffer(const Model& m, const size_t T,
11 | const std::string& file, const FileMode mode, const SchemaMode schema) :
12 | SimulatorNullBuffer(m, 0, T, file, mode, schema) {
13 | //
14 | }
15 |
16 | void bi::OptimiserNullBuffer::writeValue(const size_t k, const real& x) {
17 | //
18 | }
19 |
20 | void bi::OptimiserNullBuffer::writeSize(const size_t k, const real& x) {
21 | //
22 | }
23 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/math/magma.cu:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "magma.hpp"
9 |
10 | #define MAGMA_FUNC_DEF(name, dname, sname) \
11 | BOOST_TYPEOF(magma_##sname) *bi::magma_##name::func = magma_##sname; \
12 | BOOST_TYPEOF(magma_##dname) *bi::magma_##name::func = magma_##dname;
13 |
14 | #ifdef HAVE_MAGMA_H
15 | MAGMA_FUNC_DEF(potrf, dpotrf_gpu, spotrf_gpu)
16 | MAGMA_FUNC_DEF(potrs, dpotrs_gpu, spotrs_gpu)
17 | MAGMA_FUNC_DEF(get_potrf_nb, get_dpotrf_nb, get_spotrf_nb)
18 | //MAGMA_FUNC_DEF(syevx, dsyevx_gpu, ssyevx_gpu)
19 | #endif
20 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/empty.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_EMPTY_HPP
9 | #define BI_TYPELIST_EMPTY_HPP
10 |
11 | #include "typelist.hpp"
12 |
13 | namespace bi {
14 | /**
15 | * Is type list empty?
16 | *
17 | * @ingroup typelist
18 | *
19 | * @tparam T A type list.
20 | */
21 | template
22 | struct empty {
23 | static const bool value = false;
24 | };
25 |
26 | /**
27 | * @internal
28 | */
29 | template<>
30 | struct empty {
31 | static const bool value = true;
32 | };
33 |
34 | }
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/equals.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_EQUALS_HPP
9 | #define BI_TYPELIST_EQUALS_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Type equality check.
14 | *
15 | * @ingroup typelist
16 | *
17 | * @tparam X A type.
18 | * @ptaram Y A type.
19 | */
20 | template
21 | struct equals {
22 | static const bool value = false;
23 | };
24 |
25 | /**
26 | * @internal
27 | */
28 | template
29 | struct equals {
30 | static const bool value = true;
31 | };
32 |
33 | }
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/share/nvcc_wrapper.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | ##
4 | ## Wrapper around nvcc for compatibility with libtool.
5 | ##
6 | ## @author Lawrence Murray
7 | ## $Rev$
8 | ## $Date$
9 | ##
10 |
11 | my @host_args;
12 | my @dev_args;
13 | my $arg;
14 | my $cmd;
15 |
16 | foreach $arg (@ARGV) {
17 | $arg =~ s/(-pthread)/-Xcompiler="$1"/g;
18 | $arg =~ s/-g\d+/-g/g;
19 | $arg =~ s/(-f(?:instrument-functions|unroll-loops|no-inline|PIC))/-Xcompiler="$1"/g;
20 | $arg =~ s/(-D(?:PIC))/-Xcompiler="$1"/g;
21 |
22 | push(@dev_args, $arg);
23 | }
24 |
25 | $cmd = join(' ', @dev_args) . "\n";
26 |
27 | exec($cmd) || die;
28 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/std_action.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO std_action BLOCK %]
9 | /**
10 | * Target type.
11 | */
12 | typedef Var[% action.get_left.get_var.get_id %] target_type;
13 |
14 | /**
15 | * Coordinate type.
16 | */
17 | typedef ActionCoord[% action.get_id %] coord_type;
18 |
19 | /**
20 | * Size of the action.
21 | */
22 | static const int SIZE = [% action.get_size %];
23 |
24 | /**
25 | * Is this a matrix action?
26 | */
27 | static const bool IS_MATRIX = [% action.is_matrix %];
28 | [%-END-%]
29 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/pop_front_spec.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_POP_FRONT_SPEC_HPP
9 | #define BI_TYPELIST_POP_FRONT_SPEC_HPP
10 |
11 | #include "empty.hpp"
12 |
13 | //#include "boost/static_assert.hpp"
14 |
15 | namespace bi {
16 | /**
17 | * Pop first spec of a type list. Used by append.
18 | *
19 | * @ingroup typelist
20 | *
21 | * @tparam T A type list.
22 | */
23 | template
24 | struct pop_front_spec {
25 | //BOOST_STATIC_ASSERT(!empty::value);
26 | typedef typename T::tail type;
27 | };
28 | }
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/lib/Bi/Block/pdf_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | pdf_ - block for univariate pdf actions.
4 |
5 | =cut
6 |
7 | package Bi::Block::pdf_;
8 |
9 | use parent 'Bi::Block';
10 | use warnings;
11 | use strict;
12 |
13 | our $BLOCK_ARGS = [];
14 |
15 | sub validate {
16 | my $self = shift;
17 |
18 | $self->process_args($BLOCK_ARGS);
19 |
20 | if (@{$self->get_blocks} > 0) {
21 | die("a 'pdf_' block may not contain nested blocks\n");
22 | }
23 | }
24 |
25 | 1;
26 |
27 | =head1 AUTHOR
28 |
29 | Lawrence Murray
30 |
31 | =head1 VERSION
32 |
33 | $Rev: 2925 $ $Date: 2012-08-12 17:49:28 +0800 (Sun, 12 Aug 2012) $
34 |
--------------------------------------------------------------------------------
/inc/Module/Install/Scripts.pm:
--------------------------------------------------------------------------------
1 | #line 1
2 | package Module::Install::Scripts;
3 |
4 | use strict 'vars';
5 | use Module::Install::Base ();
6 |
7 | use vars qw{$VERSION @ISA $ISCORE};
8 | BEGIN {
9 | $VERSION = '1.06';
10 | @ISA = 'Module::Install::Base';
11 | $ISCORE = 1;
12 | }
13 |
14 | sub install_script {
15 | my $self = shift;
16 | my $args = $self->makemaker_args;
17 | my $exe = $args->{EXE_FILES} ||= [];
18 | foreach ( @_ ) {
19 | if ( -f $_ ) {
20 | push @$exe, $_;
21 | } elsif ( -d 'script' and -f "script/$_" ) {
22 | push @$exe, "script/$_";
23 | } else {
24 | die("Cannot find script '$_'");
25 | }
26 | }
27 | }
28 |
29 | 1;
30 |
--------------------------------------------------------------------------------
/share/src/bi/math/scalar.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_SCALAR_HPP
9 | #define BI_MATH_SCALAR_HPP
10 |
11 | /**
12 | * Value type for calculations, float or double. We use this rather
13 | * than templates because of limited function template support on the GPU
14 | * and necessary use of global variables.
15 | */
16 | #ifdef ENABLE_SINGLE
17 | typedef float real;
18 | #else
19 | typedef double real;
20 | #endif
21 |
22 | /**
23 | * @def BI_REAL
24 | *
25 | * Cast alias.
26 | */
27 | #define BI_REAL(x, ...) static_cast(x,##__VA_ARGS__)
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro/offset_coord.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-MACRO offset_coord(action) BLOCK-%]
9 | [%-dynamic = 0-%]
10 | [%-FOREACH alias IN action.get_aliases-%]
11 | [%-IF !alias.get_range.get_start.is_const-%]
12 | [%-dynamic = 1-%]
13 | [%-END-%]
14 | [%-END-%]
15 |
16 | [%-IF !dynamic-%]
17 | const CX& cox_ = cox;
18 | [%-ELSE-%]
19 | CX cox_ = cox;
20 | [% FOREACH alias IN action.get_aliases %]
21 | [% IF !alias.get_range.get_start.is_const %]
22 | cox_.i[% loop.index %] = [% alias.get_range.get_start.to_cpp %];
23 | [% END %]
24 | [%-END %]
25 | [%-END-%]
26 | [%-END-%]
27 |
--------------------------------------------------------------------------------
/lib/Bi/Test/test.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | test - frontend to test client programs.
4 |
5 | =head1 SYNOPSIS
6 |
7 | libbi test ...
8 |
9 | =head1 INHERITS
10 |
11 | L
12 |
13 | =cut
14 | our @CLIENT_OPTIONS = ();
15 |
16 | =head1 METHODS
17 |
18 | =over 4
19 |
20 | =cut
21 |
22 | package Bi::Client::test;
23 |
24 | use parent 'Bi::Client';
25 | use warnings;
26 | use strict;
27 |
28 | sub init {
29 | my $self = shift;
30 |
31 | $self->{_binary} = 'test';
32 | push(@{$self->{_params}}, @CLIENT_OPTIONS);
33 | }
34 |
35 | 1;
36 |
37 | =back
38 |
39 | =head1 AUTHOR
40 |
41 | Lawrence Murray
42 |
43 | =head1 VERSION
44 |
45 | $Rev$ $Date$
46 |
--------------------------------------------------------------------------------
/share/src/bi/null/SimulatorNullBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "SimulatorNullBuffer.hpp"
9 |
10 | bi::SimulatorNullBuffer::SimulatorNullBuffer(const Model& m, const size_t P,
11 | const size_t T, const std::string& file, const FileMode mode,
12 | const SchemaMode schema) {
13 | //
14 | }
15 |
16 | void bi::SimulatorNullBuffer::writeTime(const size_t k, const real& t) {
17 | //
18 | }
19 |
20 | void bi::SimulatorNullBuffer::writeStart(const size_t k, const long& start) {
21 | //
22 | }
23 |
24 | void bi::SimulatorNullBuffer::writeLen(const size_t k, const long& len) {
25 | //
26 | }
27 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/front_spec.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_FRONT_SPEC_HPP
9 | #define BI_TYPELIST_FRONT_SPEC_HPP
10 |
11 | #include "typelist.hpp"
12 | #include "empty.hpp"
13 |
14 | //#include "boost/static_assert.hpp"
15 |
16 | namespace bi {
17 | /**
18 | * Get front spec of a type list. Used by append.
19 | *
20 | * @ingroup typelist
21 | *
22 | * @tparam T A type list.
23 | */
24 | template
25 | struct front_spec {
26 | //BOOST_STATIC_ASSERT(!empty::value);
27 | typedef typelist type;
28 | };
29 |
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/share/tt/cpp/model.cpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-class_name = "Model" _ model.get_name-%]
10 | /**
11 | * @file
12 | *
13 | * @author Generated by LibBi
14 | * $Rev$
15 | * $Date$
16 | */
17 | #include "[% class_name %].hpp"
18 |
19 | using namespace bi;
20 |
21 | [% class_name %]::[% class_name %]() : Model(*this) {
22 | /* add dimensions */
23 | [%-FOREACH dim IN model.get_all_dims %]
24 | addDim(dim[% dim.get_id %]);
25 | [%-END %]
26 |
27 | /* add variables */
28 | [%-FOREACH var IN model.get_all_vars %]
29 | addVar<[% class_name %],Var[% var.get_id %]>(var[% var.get_id %]);
30 | [%-END %]
31 | }
32 |
--------------------------------------------------------------------------------
/lib/Bi/Block/cholesky_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | cholesky_ - special block for cholesky action.
4 |
5 | =cut
6 |
7 | package Bi::Block::cholesky_;
8 |
9 | use parent 'Bi::Block';
10 | use warnings;
11 | use strict;
12 |
13 | our $BLOCK_ARGS = [];
14 |
15 | sub validate {
16 | my $self = shift;
17 |
18 | $self->process_args($BLOCK_ARGS);
19 |
20 | my $name = $self->get_name;
21 | if (@{$self->get_blocks} > 0) {
22 | die("a '$name' block may not contain nested blocks\n");
23 | }
24 | if (@{$self->get_actions} != 1) {
25 | die("a '$name' block may only contain one action\n");
26 | }
27 | }
28 |
29 | 1;
30 |
31 | =head1 AUTHOR
32 |
33 | Lawrence Murray
34 |
--------------------------------------------------------------------------------
/lib/Bi/Block/bridge.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | bridge - the bridge potential.
4 |
5 | =head1 SYNOPSIS
6 |
7 | sub bridge {
8 | ...
9 | }
10 |
11 | =head1 DESCRIPTION
12 |
13 | Actions in the C block may reference variables of any type, but may
14 | only target variables of type C and C. References to C
15 | variables provide their next value. Use of the built-in variables C
16 | and C will be useful.
17 |
18 | =cut
19 |
20 | package Bi::Block::bridge;
21 |
22 | use parent 'Bi::Block::observation';
23 | use warnings;
24 | use strict;
25 |
26 | 1;
27 |
28 | =head1 AUTHOR
29 |
30 | Lawrence Murray
31 |
32 | =head1 VERSION
33 |
34 | $Rev$ $Date$
35 |
--------------------------------------------------------------------------------
/share/src/bi/host/random/RandomHost.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "RandomHost.hpp"
9 |
10 | #ifdef ENABLE_MPI
11 | #include "boost/mpi/communicator.hpp"
12 | #endif
13 |
14 | void bi::RandomHost::seeds(Random& rng, const unsigned seed) {
15 | #pragma omp parallel
16 | {
17 | #ifdef ENABLE_MPI
18 | boost::mpi::communicator world;
19 | const int rank = world.rank();
20 | const int size = world.size();
21 |
22 | int s = seed*size*bi_omp_max_threads + rank*bi_omp_max_threads + bi_omp_tid;
23 | #else
24 | int s = seed*bi_omp_max_threads + bi_omp_tid;
25 | #endif
26 |
27 | rng.getHostRng().seed(s);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/share/src/bi/concept/Norm.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #error "Concept documentation only, should not be #included"
9 |
10 | namespace concept {
11 | /**
12 | * Vector norm concept.
13 | *
14 | * @ingroup concept
15 | *
16 | * @note This is a phony class, representing a concept, for documentation
17 | * purposes only.
18 | */
19 | struct Norm {
20 | /**
21 | * Evaluate the norm.
22 | *
23 | * @tparam V1 Vector type.
24 | *
25 | * @param x \f$\mathbf{x}\f$; a vector.
26 | *
27 | * @return \f$\|\mathbf{x}\|\f$; the norm of the vector.
28 | */
29 | template
30 | typename V1::value_type operator()(const V1& x) const = 0;
31 | };
32 | }
33 |
--------------------------------------------------------------------------------
/script/libbi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | =head1 NAME
4 |
5 | libbi - frontend to LibBi functionality.
6 |
7 | =head1 SYNOPSIS
8 |
9 | libbi I I
10 |
11 | libbi @I
12 | libbi I @I
13 |
14 | =head1 METHODS
15 |
16 | =over 4
17 |
18 | =cut
19 |
20 | BEGIN {
21 | use FindBin qw($Bin);
22 | use File::Spec;
23 |
24 | unshift(@INC, File::Spec->catfile($Bin, '..', 'lib'));
25 | }
26 |
27 | use warnings;
28 | use strict;
29 |
30 | use Getopt::ArgvFile;
31 |
32 | use Bi::FrontEnd;
33 |
34 |
35 | my $frontend = new Bi::FrontEnd;
36 | $frontend->do;
37 |
38 | =back
39 |
40 | =head1 AUTHOR
41 |
42 | Lawrence Murray
43 |
44 | =head1 VERSION
45 |
46 | $Rev$ $Date$
47 |
--------------------------------------------------------------------------------
/share/src/bi/traits/resampler_traits.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TRAITS_RESAMPLER_TRAITS_HPP
9 | #define BI_TRAITS_RESAMPLER_TRAITS_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Precompute type for given resampler.
14 | *
15 | * @ingroup method_resampler
16 | *
17 | * @tparam R Resampler type.
18 | * @tparam L Location.
19 | */
20 | template
21 | struct precompute_type {
22 | typedef int type;
23 | };
24 |
25 | /**
26 | * Does resampler need a maximum log-weight?
27 | *
28 | * @ingroup method_resampler
29 | */
30 | template
31 | struct resampler_needs_max {
32 | static const bool value = false;
33 | };
34 | }
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | LibBi README.md
2 | ===============
3 |
4 | [LibBi](http://www.libbi.org) is used for state-space modelling and Bayesian
5 | inference on modern computer hardware, including multi-core CPUs, many-core
6 | GPUs (graphics processing units) and distributed-memory clusters.
7 |
8 | The staple methods used in LibBi are those based on sequential Monte Carlo
9 | (SMC). This includes particle Markov chain Monte Carlo (PMCMC) and SMC^2
10 | methods. Extra methods include the extended Kalman filter and some parameter
11 | optimisation routines.
12 |
13 | LibBi consists of a C++ template library, as well as a parser and compiler,
14 | written in Perl, for its own domain-specific language that is used to specify
15 | models.
16 |
17 | See the `INSTALL.md` file for installation instructions.
18 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/random/RandomGPU.cu:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "RandomGPU.cuh"
9 |
10 | #include "../../cuda/device.hpp"
11 |
12 | #ifdef ENABLE_MPI
13 | #include "boost/mpi/communicator.hpp"
14 | #endif
15 |
16 | void bi::RandomGPU::seeds(Random& rng, const unsigned seed) {
17 | #ifdef ENABLE_MPI
18 | boost::mpi::communicator world;
19 | const int rank = world.rank();
20 | const int size = world.size();
21 |
22 | int s = seed*size + rank;
23 | #else
24 | int s = seed;
25 | #endif
26 |
27 | dim3 Db, Dg;
28 | Db.x = deviceIdealThreadsPerBlock();
29 | Dg.x = deviceIdealThreads()/Db.x;
30 |
31 | kernelSeeds<<>>(rng.devRngs, s);
32 | CUDA_CHECK;
33 | }
34 |
--------------------------------------------------------------------------------
/lib/Bi/Block/wiener_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | wiener_ - block for L actions.
4 |
5 | =cut
6 |
7 | package Bi::Block::wiener_;
8 |
9 | use parent 'Bi::Block';
10 | use warnings;
11 | use strict;
12 |
13 | our $BLOCK_ARGS = [];
14 |
15 | sub validate {
16 | my $self = shift;
17 |
18 | $self->process_args($BLOCK_ARGS);
19 |
20 | if (@{$self->get_blocks} > 0) {
21 | die("a 'wiener_' block may not contain nested blocks\n");
22 | }
23 |
24 | foreach my $action (@{$self->get_actions}) {
25 | if ($action->get_name ne 'wiener') {
26 | die("a 'wiener_' block may only contain 'wiener' actions\n");
27 | }
28 | }
29 | }
30 |
31 | 1;
32 |
33 | =head1 AUTHOR
34 |
35 | Lawrence Murray
36 |
37 | =head1 VERSION
38 |
39 | $Rev$ $Date$
40 |
--------------------------------------------------------------------------------
/share/src/bi/method/misc.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_METHOD_MISC_HPP
9 | #define BI_METHOD_MISC_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Optimisation modes.
14 | */
15 | enum OptimiserMode {
16 | /**
17 | * Maximum likelihood estimation.
18 | */
19 | MAXIMUM_LIKELIHOOD,
20 |
21 | /**
22 | * Maximum a posteriori.
23 | */
24 | MAXIMUM_A_POSTERIORI
25 | };
26 |
27 | /**
28 | * MarginalSIR adaptation strategies.
29 | */
30 | enum MarginalSIRAdapter {
31 | /**
32 | * No adaptation.
33 | */
34 | NO_ADAPTER,
35 |
36 | /**
37 | * Local proposals.
38 | */
39 | LOCAL_ADAPTER,
40 |
41 | /**
42 | * Global proposals.
43 | */
44 | GLOBAL_ADAPTER
45 | };
46 |
47 | }
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/share/tt/cpp/block/misc/header.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS macro.hpp.tt-%]
10 |
11 | [%-class_name = "Block" _ block.get_id-%]
12 | [%-model_class_name = "Model" _ model.get_name-%]
13 | /**
14 | * @file
15 | *
16 | * @author Generated by LibBi
17 | * $Rev$
18 | * $Date$
19 | */
20 | #ifndef LIBBI_[% class_name | upper %]_HPP
21 | #define LIBBI_[% class_name | upper %]_HPP
22 |
23 | [%-FOREACH subblock IN block.get_blocks %]
24 | #include "Block[% subblock.get_id %].hpp"
25 | [%-END %]
26 | [%-FOREACH action IN block.get_actions %]
27 | #include "../action/Action[% action.get_id %].hpp"
28 | [%-END %]
29 |
30 | #include "bi/typelist/macro_typelist.hpp"
31 | #include "bi/traits/block_traits.hpp"
32 |
33 | #include "boost/typeof/typeof.hpp"
34 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/thread.cuh:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_CUDA_THREAD_CUH
9 | #define BI_CUDA_THREAD_CUH
10 |
11 | #include "cuda.hpp"
12 |
13 | /**
14 | * @internal
15 | *
16 | * Return id of the current thread, a unique number across all threads in all
17 | * blocks.
18 | *
19 | * @return Id of the thread.
20 | */
21 | CUDA_FUNC_DEVICE int get_tid();
22 |
23 | inline int get_tid() {
24 | int blockSize, blockId, threadId, tid;
25 |
26 | blockSize = blockDim.y*blockDim.x*blockDim.z;
27 | blockId = blockIdx.y + blockIdx.x*gridDim.x + blockIdx.z*gridDim.x*gridDim.y;
28 | threadId = threadIdx.y + threadIdx.x*blockDim.y + threadIdx.z*blockDim.y*blockDim.x;
29 | tid = blockId*blockSize + threadId;
30 |
31 | return tid;
32 | }
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/share/src/bi/traits/dim_traits.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TRAITS_DIM_TRAITS_HPP
9 | #define BI_TRAITS_DIM_TRAITS_HPP
10 |
11 | #include "../typelist/index.hpp"
12 | #include "../typelist/front.hpp"
13 | #include "../typelist/pop_front.hpp"
14 | #include "../typelist/size.hpp"
15 |
16 | namespace bi {
17 | /**
18 | * Id of dimension.
19 | *
20 | * @ingroup model_low
21 | *
22 | * @tparam D Dimension type.
23 | */
24 | template
25 | struct dim_id {
26 | static const int value = D::ID;
27 | };
28 |
29 | /**
30 | * Size of dimension.
31 | *
32 | * @ingroup model_low
33 | *
34 | * @tparam D Dimension type.
35 | */
36 | template
37 | struct dim_size {
38 | static const int value = D::SIZE;
39 | };
40 |
41 | }
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/misc/header.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS macro.hpp.tt-%]
10 |
11 | [%-class_name = 'Action' _ action.get_id-%]
12 | [%-model_class_name = "Model" _ model.get_name-%]
13 | /**
14 | * @file
15 | *
16 | * Automatically generated by LibBi, do not edit.
17 | */
18 | #ifndef LIBBI_ACTION[% action.get_id %]_HPP
19 | #define LIBBI_ACTION[% action.get_id %]_HPP
20 |
21 | #include "ActionCoord[% action.get_id %].hpp"
22 |
23 | #include "bi/state/State.hpp"
24 | #include "bi/state/Mask.hpp"
25 | #include "bi/cuda/cuda.hpp"
26 | #include "bi/math/scalar.hpp"
27 | #include "bi/math/pi.hpp"
28 | #include "bi/math/function.hpp"
29 | #ifdef ENABLE_SSE
30 | #include "bi/sse/math/scalar.hpp"
31 | #endif
32 |
33 | class Model[% model.get_name %];
34 |
--------------------------------------------------------------------------------
/script/bi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | =head1 NAME
4 |
5 | bi - frontend to LibBi functionality.
6 |
7 | =head1 SYNOPSIS
8 |
9 | bi I I
10 |
11 | bi @I
12 | bi I @I
13 |
14 | =head1 METHODS
15 |
16 | =over 4
17 |
18 | =cut
19 |
20 | BEGIN {
21 | use FindBin qw($Bin);
22 | use File::Spec;
23 |
24 | unshift(@INC, File::Spec->catfile($Bin, '..', 'lib'));
25 | }
26 |
27 | use warnings;
28 | use strict;
29 |
30 | use Getopt::ArgvFile;
31 |
32 | use Bi::FrontEnd;
33 |
34 | warn("the 'bi' command is deprecated, use 'libbi' instead.\n");
35 |
36 | my $frontend = new Bi::FrontEnd;
37 | $frontend->do;
38 |
39 | =back
40 |
41 | =head1 AUTHOR
42 |
43 | Lawrence Murray
44 |
45 | =head1 VERSION
46 |
47 | $Rev: 3864 $ $Date: 2013-05-22 17:48:18 +0800 (Wed, 22 May 2013) $
48 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | LibBi
4 |
5 |
6 |
7 |
8 |
9 | net.sourceforge.texlipse.builder.TexlipseBuilder
10 |
11 |
12 |
13 |
14 | org.epic.perleditor.perlbuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.linuxtools.rpm.rpmlint.rpmlintBuilder
20 |
21 |
22 |
23 |
24 |
25 | net.sourceforge.texlipse.builder.TexlipseNature
26 | org.epic.perleditor.perlnature
27 | org.eclipse.linuxtools.rpm.rpmlint.rpmlintNature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lib/Bi/Block/proposal_parameter.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | parameter - a proposal distribution over parameters.
4 |
5 | =head1 SYNOPSIS
6 |
7 | sub proposal_parameter {
8 | theta ~ gaussian(theta, 1.0) // local proposal
9 | theta ~ gaussian(0.0, 1.0) // independent proposal
10 | }
11 |
12 | =head1 DESCRIPTION
13 |
14 | This may be a local or independent proposal distribution, used by the
15 | C command.
16 |
17 | Actions in the C block may only refer to variables of
18 | type C and C. They may only target variables of type C.
19 |
20 | =cut
21 |
22 | package Bi::Block::proposal_parameter;
23 |
24 | use parent 'Bi::Block::parameter';
25 | use warnings;
26 | use strict;
27 |
28 | 1;
29 |
30 | =head1 AUTHOR
31 |
32 | Lawrence Murray
33 |
34 | =head1 VERSION
35 |
36 | $Rev$ $Date$
37 |
--------------------------------------------------------------------------------
/lib/Bi/Block/lookahead_observation.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | lookahead_observation - a likelihood function for lookahead operations.
4 |
5 | =head1 SYNOPSIS
6 |
7 | sub lookahead_observation {
8 | ...
9 | }
10 |
11 | =head1 DESCRIPTION
12 |
13 | This may be a deterministic, computationally cheaper or perhaps inflated
14 | version of the likelihood function. It is used by the auxiliary particle
15 | filter.
16 |
17 | Actions in the C block may only refer to variables
18 | of type C, C and C. They may only target variables of
19 | type C.
20 |
21 | =cut
22 |
23 | package Bi::Block::lookahead_observation;
24 |
25 | use parent 'Bi::Block::observation';
26 | use warnings;
27 | use strict;
28 |
29 | 1;
30 |
31 | =head1 AUTHOR
32 |
33 | Lawrence Murray
34 |
35 | =head1 VERSION
36 |
37 | $Rev$ $Date$
38 |
--------------------------------------------------------------------------------
/lib/Bi/Block/lookahead_transition.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | lookahead_transition - a transition distribution for lookahead operations.
4 |
5 | =head1 SYNOPSIS
6 |
7 | sub lookahead_transition {
8 | ...
9 | }
10 |
11 | =head1 DESCRIPTION
12 |
13 | This may be a deterministic, computationally cheaper or perhaps inflated
14 | version of the transition distribution. It is used by the auxiliary particle
15 | filter.
16 |
17 | Actions in the C block may reference variables of any
18 | type except C, but may only target variables of type C and
19 | C.
20 |
21 | =cut
22 |
23 | package Bi::Block::lookahead_transition;
24 |
25 | use parent 'Bi::Block::transition';
26 | use warnings;
27 | use strict;
28 |
29 | 1;
30 |
31 | =head1 AUTHOR
32 |
33 | Lawrence Murray
34 |
35 | =head1 VERSION
36 |
37 | $Rev$ $Date$
38 |
--------------------------------------------------------------------------------
/share/tt/bi/block.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | PROCESS macro/arg_list.bi.tt
8 | -%]
9 | [% IF block.get_top_level %]sub [% END %][% IF block.is_named %][% block.get_name %][% END %][% arg_list(block) %] { // Block[% block.get_id %]
10 | [% INCLUDE const.bi.tt FILTER indent(2) FOREACH const IN block.get_consts-%]
11 | [% INCLUDE inline.bi.tt FILTER indent(2) FOREACH inline IN block.get_inlines-%]
12 | [% INCLUDE dim.bi.tt FILTER indent(2) FOREACH dim IN block.get_dims-%]
13 | [% INCLUDE var.bi.tt FILTER indent(2) FOREACH var IN block.get_vars-%]
14 |
15 | [%-FOREACH child IN block.get_children-%]
16 | [%-IF child.get_type == 'action'-%]
17 | [%-INCLUDE action.bi.tt action = child FILTER indent(2)-%]
18 | [%-ELSE-%]
19 | [%-INCLUDE block.bi.tt block = child FILTER indent(2)-%]
20 | [%-END-%]
21 | [%-END-%]
22 | }
23 |
--------------------------------------------------------------------------------
/lib/Bi/Block/std_.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | std_ - optimisation block for L actions.
4 |
5 | =cut
6 |
7 | package Bi::Block::std_;
8 |
9 | use parent 'Bi::Block';
10 | use warnings;
11 | use strict;
12 |
13 | our $BLOCK_ARGS = [];
14 |
15 | sub validate {
16 | my $self = shift;
17 |
18 | $self->process_args($BLOCK_ARGS);
19 |
20 | if (@{$self->get_blocks} > 0) {
21 | die("a 'std_' block may not contain nested blocks\n");
22 | }
23 | if (@{$self->get_actions} != 1) {
24 | die("a 'std_' block may only contain one action\n");
25 | }
26 |
27 | my $action = $self->get_action;
28 | if ($action->get_name ne 'std_') {
29 | die("a 'std_' block may only contain 'std_' actions\n");
30 | }
31 | }
32 |
33 | 1;
34 |
35 | =head1 AUTHOR
36 |
37 | Lawrence Murray
38 |
39 | =head1 VERSION
40 |
41 | $Rev$ $Date$
42 |
--------------------------------------------------------------------------------
/share/tt/bi/model.bi.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-PROCESS macro/arg_list.bi.tt-%]
9 | model [% model.get_name %][% arg_list(model) %] {
10 | [% INCLUDE const.bi.tt FILTER indent(2) FOREACH const IN model.get_consts-%]
11 | [% INCLUDE inline.bi.tt FILTER indent(2) FOREACH inline IN model.get_inlines-%]
12 | [% INCLUDE dim.bi.tt FILTER indent(2) FOREACH dim IN model.get_dims-%]
13 | [% INCLUDE var.bi.tt FILTER indent(2) FOREACH var IN model.get_vars-%]
14 | [% INCLUDE var_group.bi.tt FILTER indent(2) FOREACH var_group IN model.get_var_groups-%]
15 |
16 | [% FOREACH child IN model.get_children-%]
17 | [%-IF child.get_type == 'action'-%]
18 | [% INCLUDE action.bi.tt action = child FILTER indent(2)-%]
19 | [%-ELSE-%]
20 | [% INCLUDE block.bi.tt block = child FILTER indent(2) %]
21 |
22 | [%-END-%]
23 | [% END-%]
24 | }
25 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/push_back_spec.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_PUSH_BACK_SPEC_HPP
9 | #define BI_TYPELIST_PUSH_BACK_SPEC_HPP
10 |
11 | #include "typelist.hpp"
12 |
13 | namespace bi {
14 | /**
15 | * Push spec onto back of a type list. Used by append.
16 | *
17 | * @ingroup typelist
18 | *
19 | * @tparam T1 A type list.
20 | * @tparam T2 A type list.
21 | */
22 | template
23 | struct push_back_spec {
24 | typedef typelist::type> type;
25 | };
26 |
27 | /**
28 | * @internal
29 | *
30 | * Base case.
31 | */
32 | template
33 | struct push_back_spec {
34 | typedef typelist type;
35 | };
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/share/tt/dot/block.dot.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-FOREACH ref IN block.get_vars(['input', 'param', 'noise', 'state', 'obs']) %]
9 | [%-INCLUDE ref.dot.tt FILTER indent(2) %]
10 | [%-END-%]
11 |
12 | [% IF block.get_name != 'eval_' %]
13 | subgraph cluster_block[% block.get_id %] {
14 | label="[% block.get_name %]";
15 | color="#000000";
16 | [% END %]
17 |
18 | [%-FOREACH action IN block.get_actions-%]
19 | [%-INCLUDE var.dot.tt var = action.get_left.get_var FILTER indent(2) %]
20 | [%-END-%]
21 |
22 | [%-FOREACH subblock IN block.get_blocks %]
23 | [%-INCLUDE block.dot.tt block = subblock FILTER indent(2) %]
24 | [%-END-%]
25 |
26 | [%-FOREACH action IN block.get_actions %]
27 | [%-INCLUDE action.dot.tt action = action FILTER indent(2) %]
28 | [%-END-%]
29 |
30 | [% IF block.get_name != 'eval_' %]
31 | }
32 | [% END %]
33 |
--------------------------------------------------------------------------------
/share/src/bi/math/pi.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * Common \f$\pi\f$ pre-calculations using big-decimal. We should note that,
5 | * actually, these are no more accurate than using double precision, but they
6 | * do at least ensure decent accuracy before casting to single precision.
7 | *
8 | * @author Lawrence Murray
9 | * $Rev$
10 | * $Date$
11 | */
12 | #ifndef BI_MATH_PI_HPP
13 | #define BI_MATH_PI_HPP
14 |
15 | /**
16 | * Value of \f$\pi\f$
17 | */
18 | #define BI_PI 3.1415926535897932384626433832795
19 |
20 | /**
21 | * Value of \f$2\pi\f$
22 | */
23 | #define BI_TWO_PI 6.2831853071795864769252867665590
24 |
25 | /**
26 | * Value of \f$\sqrt{2\pi}\f$
27 | */
28 | #define BI_SQRT_TWO_PI 2.5066282746310005024157652848110
29 |
30 | /**
31 | * Value of \f$\frac{1}{2}\ln 2\pi = \ln \sqrt{2\pi}\f$
32 | */
33 | #define BI_HALF_LOG_TWO_PI 0.91893853320467274178032973640562
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/share/src/bi/random/Random.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "Random.hpp"
9 |
10 | #ifdef ENABLE_CUDA
11 | #include "../cuda/device.hpp"
12 | #endif
13 |
14 | bi::Random::Random() : own(true) {
15 | hostRngs = new RngHost[bi_omp_max_threads];
16 | }
17 |
18 | bi::Random::Random(const unsigned seed) : own(true) {
19 | hostRngs = new RngHost[bi_omp_max_threads];
20 | this->seeds(seed);
21 | }
22 |
23 | bi::Random::Random(const Random& o) {
24 | hostRngs = o.hostRngs;
25 | #ifdef ENABLE_CUDA
26 | devRngs = o.devRngs;
27 | #endif
28 | own = false;
29 | }
30 |
31 | bi::Random::~Random() {
32 | if (own) {
33 | delete[] hostRngs;
34 | }
35 | }
36 |
37 | void bi::Random::seeds(const unsigned seed) {
38 | RandomHost::seeds(*this, seed);
39 | #ifdef ENABLE_CUDA
40 | RandomGPU::seeds(*this, seed);
41 | #endif
42 | }
43 |
--------------------------------------------------------------------------------
/lib/Bi/Action/log_gaussian.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | log_gaussian - log-Gaussian distribution.
4 |
5 | =head1 SYNOPSIS
6 |
7 | x ~ log_gaussian()
8 | x ~ log_gaussian(0.0, 1.0)
9 | x ~ log_gaussian(mean = 0.0, std = 1.0)
10 |
11 | =head1 DESCRIPTION
12 |
13 | A C action specifies that the logarithm of a variable is
14 | Gaussian distributed according to the given C and C parameters.
15 |
16 | =cut
17 |
18 | package Bi::Action::log_gaussian;
19 |
20 | use parent 'Bi::Action::gaussian';
21 |
22 | =head1 PARAMETERS
23 |
24 | =over 4
25 |
26 | =item C (position 0, default 0.0)
27 |
28 | Mean of the log-transformed variable.
29 |
30 | =item C (position 1, default 1.0)
31 |
32 | Standard deviation of the log-transformed variable.
33 |
34 | =back
35 |
36 | =cut
37 |
38 | 1;
39 |
40 | =head1 AUTHOR
41 |
42 | Lawrence Murray
43 |
44 | =head1 VERSION
45 |
46 | $Rev$ $Date$
47 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/transpose.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | %]
6 |
7 | [%-
8 | A = action.get_named_arg('A');
9 | %]
10 |
11 | [%-PROCESS action/misc/header.hpp.tt-%]
12 |
13 | /**
14 | * Action: [% action.get_name %].
15 | */
16 | class [% class_name %] {
17 | public:
18 | [% std_action %]
19 |
20 | [% declare_action_static_matrix_function('simulate') %]
21 | [% declare_action_dynamic_matrix_function('simulate') %]
22 | };
23 |
24 | #include "bi/math/view.hpp"
25 | #include "bi/math/operation.hpp"
26 |
27 | [% sig_action_static_matrix_function('simulate') %] {
28 | [% fetch_parents(action) %]
29 |
30 | BOOST_AUTO(A, [% get_var(A) %]);
31 | BOOST_AUTO(B, [% get_output_var(B) %]);
32 |
33 | bi::trans(A, B);
34 | }
35 |
36 | [% sig_action_dynamic_matrix_function('simulate') %] {
37 | simulates(s, p, pax, x);
38 | }
39 |
40 | [%-PROCESS action/misc/footer.hpp.tt-%]
41 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/exclusive_scan.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-
10 | a = action.get_named_arg('x');
11 | %]
12 |
13 | [%-PROCESS action/misc/header.hpp.tt-%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | class [% class_name %] {
19 | public:
20 | [% std_action %]
21 |
22 | [% declare_action_static_matrix_function('simulate') %]
23 | [% declare_action_dynamic_matrix_function('simulate') %]
24 | };
25 |
26 | #include "bi/math/view.hpp"
27 |
28 | [% sig_action_static_matrix_function('simulate') %] {
29 | [% fetch_parents(action) %]
30 |
31 | BOOST_AUTO(a, [% get_var(a) %]);
32 | BOOST_AUTO(b, [% get_output_var(b) %]);
33 |
34 | bi::exclusive_scan(a, b);
35 | }
36 |
37 | [% sig_action_dynamic_matrix_function('simulate') %] {
38 | simulates(s, p, pax, x);
39 | }
40 |
41 | [%-PROCESS action/misc/footer.hpp.tt-%]
42 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/inclusive_scan.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-
10 | a = action.get_named_arg('x');
11 | %]
12 |
13 | [%-PROCESS action/misc/header.hpp.tt-%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | class [% class_name %] {
19 | public:
20 | [% std_action %]
21 |
22 | [% declare_action_static_matrix_function('simulate') %]
23 | [% declare_action_dynamic_matrix_function('simulate') %]
24 | };
25 |
26 | #include "bi/math/view.hpp"
27 |
28 | [% sig_action_static_matrix_function('simulate') %] {
29 | [% fetch_parents(action) %]
30 |
31 | BOOST_AUTO(a, [% get_var(a) %]);
32 | BOOST_AUTO(b, [% get_output_var(b) %]);
33 |
34 | bi::inclusive_scan(a, b);
35 | }
36 |
37 | [% sig_action_dynamic_matrix_function('simulate') %] {
38 | simulates(s, p, pax, x);
39 | }
40 |
41 | [%-PROCESS action/misc/footer.hpp.tt-%]
42 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/eval_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS action/misc/header.hpp.tt-%]
10 |
11 | [%-
12 | expr = action.get_named_arg('expr')
13 | -%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | struct [% class_name %] {
19 | [% std_action %]
20 |
21 | [% declare_action_static_function('simulate') %]
22 | [% declare_action_dynamic_function('simulate') %]
23 | };
24 |
25 |
26 | [% sig_action_static_function('simulate') %] {
27 | [% alias_dims(action) %]
28 | [% fetch_parents(action) %]
29 | [% offset_coord(action) %]
30 | [% put_output(action, expr) %]
31 | }
32 |
33 | [% sig_action_dynamic_function('simulate') %] {
34 | [% alias_dims(action) %]
35 | [% fetch_parents(action) %]
36 | [% offset_coord(action) %]
37 | [% put_output(action, expr) %]
38 | }
39 |
40 | [%-PROCESS action/misc/footer.hpp.tt-%]
41 |
--------------------------------------------------------------------------------
/lib/Bi/Block/proposal_initial.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | proposal_initial - a proposal distribution over the initial values of state
4 | variables.
5 |
6 | =head1 SYNOPSIS
7 |
8 | sub proposal_initial {
9 | x ~ gaussian(x, 1.0) // local proposal
10 | x ~ gaussian(0.0, 1.0) // independent proposal
11 | }
12 |
13 | =head1 DESCRIPTION
14 |
15 | This may be a local or independent proposal distribution, used by the
16 | C command when the C<--with-transform-initial-to-param> option is
17 | used.
18 |
19 | Actions in the C block may only refer to variables of
20 | type C, C and C. They may only target variables of type
21 | C.
22 |
23 | =cut
24 |
25 | package Bi::Block::proposal_initial;
26 |
27 | use parent 'Bi::Block::initial';
28 | use warnings;
29 | use strict;
30 |
31 | 1;
32 |
33 | =head1 AUTHOR
34 |
35 | Lawrence Murray
36 |
37 | =head1 VERSION
38 |
39 | $Rev$ $Date$
40 |
--------------------------------------------------------------------------------
/share/tt/dot/var.dot.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-
9 | shapes.param = 'circle';
10 | shapes.noise = 'circle';
11 | shapes.input = 'circle';
12 | shapes.obs = 'circle';
13 | shapes.state = 'circle';
14 |
15 | styles.param = 'filled';
16 | styles.noise = 'filled';
17 | styles.input = 'filled';
18 | styles.obs = 'filled';
19 | styles.state = 'filled';
20 |
21 | colors.param = '#000000';
22 | colors.noise = '#000000';
23 | colors.input = '#000000';
24 | colors.obs = '#000000';
25 | colors.state = '#000000';
26 |
27 | fillcolors.param = '#FFFFFF';
28 | fillcolors.noise = '#FFFFFF';
29 | fillcolors.input = '#CCCCCC';
30 | fillcolors.obs = '#CCCCCC';
31 | fillcolors.state = '#FFFFFF';
32 | -%]
33 | [% var.get_name %] [label="[% var.get_name %]",shape="[% shapes.${var.get_type} %]",style="[% styles.${var.get_type} %]",color="[% colors.${var.get_type} %]",fillcolor="[% fillcolors.${var.get_type} %]"]
34 |
--------------------------------------------------------------------------------
/Makefile.PL:
--------------------------------------------------------------------------------
1 | use inc::Module::Install;
2 |
3 | # metadata
4 | name 'LibBi';
5 | abstract 'LibBi is used for state-space modelling and Bayesian inference on
6 | modern computer hardware, including multi-core CPUs, many-core GPUs (graphics
7 | processing units) and distributed-memory clusters.';
8 | author 'Lawrence Murray ';
9 | version '1.2.0';
10 | license 'gpl';
11 |
12 | # dependencies
13 | requires 'Template' => 2.24;
14 | requires 'Graph' => 0.94;
15 | requires 'Math::Symbolic' => 0.606;
16 | requires 'Carp::Assert' => 0.20;
17 | requires 'Parse::Yapp' => 0.0;
18 | requires 'Parse::Lex' => 2.21;
19 | requires 'File::Slurp' => 0.0;
20 | requires 'File::ShareDir' => 1.03;
21 | requires 'Getopt::ArgvFile' => 1.11;
22 |
23 | # installs
24 | install_script 'script/libbi';
25 | install_script 'script/bi';
26 | install_share 'share';
27 |
28 | # ignores
29 | makemaker_args(PL_FILES => { 'MakeParser.PL' => 'lib/Parse/Bi.pm' });
30 | no_index 'docs';
31 |
32 | WriteAll;
33 |
--------------------------------------------------------------------------------
/share/src/bi/math/gsl.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_GSL_HPP
9 | #define BI_MATH_GSL_HPP
10 |
11 | #include "vector.hpp"
12 |
13 | #include
14 |
15 | namespace bi {
16 | /**
17 | * View of GSL vector.
18 | *
19 | * @param x The GSL vector.
20 | */
21 | host_vector_reference gsl_vector_reference(gsl_vector* x);
22 |
23 | /**
24 | * View of GSL vector.
25 | *
26 | * @param x The GSL vector.
27 | */
28 | const host_vector_reference gsl_vector_reference(const gsl_vector* x);
29 |
30 | }
31 |
32 | bi::host_vector_reference bi::gsl_vector_reference(gsl_vector* x) {
33 | return host_vector_reference(x->data, x->size, x->stride);
34 | }
35 |
36 | const bi::host_vector_reference bi::gsl_vector_reference(
37 | const gsl_vector* x) {
38 | return host_vector_reference(x->data, x->size, x->stride);
39 | }
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/share/src/bi/sse/math/scalar.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * Types and operators for Streaming SIMD Extensions (SSE).
5 | *
6 | * @author Lawrence Murray
7 | * $Rev$
8 | * $Date$
9 | */
10 | #ifndef BI_SSE_MATH_SCALAR_HPP
11 | #define BI_SSE_MATH_SCALAR_HPP
12 |
13 | #include "../../math/scalar.hpp"
14 |
15 | #ifdef ENABLE_SSE
16 | #include "sse_float.hpp"
17 | #include "sse_double.hpp"
18 | #endif
19 |
20 | #ifdef ENABLE_AVX
21 | #include "avx_float.hpp"
22 | #include "avx_double.hpp"
23 | #endif
24 |
25 | namespace bi {
26 | #if defined(ENABLE_SINGLE) && defined(ENABLE_AVX)
27 | typedef avx_float simd_real;
28 | #elif defined(ENABLE_SINGLE) && defined(ENABLE_SSE)
29 | typedef sse_float simd_real;
30 | #elif defined(ENABLE_AVX)
31 | typedef avx_double simd_real;
32 | #elif defined(ENABLE_SSE)
33 | typedef sse_double simd_real;
34 | #else
35 | typedef real simd_real;
36 | #endif
37 | }
38 |
39 | #define BI_SIMD_SIZE (sizeof(simd_real)/sizeof(real))
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/gemm_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | %]
6 |
7 | [%-
8 | A = action.get_named_arg('A');
9 | X = action.get_named_arg('X');
10 | Y = action.get_left;
11 | %]
12 |
13 | [%-PROCESS action/misc/header.hpp.tt-%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | class [% class_name %] {
19 | public:
20 | [% std_action %]
21 |
22 | [% declare_action_static_matrix_function('simulate') %]
23 | [% declare_action_dynamic_matrix_function('simulate') %]
24 | };
25 |
26 | #include "bi/math/view.hpp"
27 |
28 | [% sig_action_static_matrix_function('simulate') %] {
29 | [% fetch_parents(action) %]
30 |
31 | BOOST_AUTO(A, [% get_var(A) %]);
32 | BOOST_AUTO(X, [% get_var(X) %]);
33 | BOOST_AUTO(Y, [% get_output_var(Y) %]);
34 |
35 | bi::gemm(A, X, Y);
36 | }
37 |
38 | [% sig_action_dynamic_matrix_function('simulate') %] {
39 | simulates(s, p, pax, x);
40 | }
41 |
42 | [%-PROCESS action/misc/footer.hpp.tt-%]
43 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/gemv_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | %]
6 |
7 | [%-
8 | A = action.get_named_arg('A');
9 | b = action.get_named_arg('x');
10 | c = action.get_left;
11 | %]
12 |
13 | [%-PROCESS action/misc/header.hpp.tt-%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | class [% class_name %] {
19 | public:
20 | [% std_action %]
21 |
22 | [% declare_action_static_matrix_function('simulate') %]
23 | [% declare_action_dynamic_matrix_function('simulate') %]
24 | };
25 |
26 | #include "bi/math/view.hpp"
27 |
28 | [% sig_action_static_matrix_function('simulate') %] {
29 | [% fetch_parents(action) %]
30 |
31 | BOOST_AUTO(A, [% get_var(A) %]);
32 | BOOST_AUTO(b, [% get_var(b) %]);
33 | BOOST_AUTO(c, [% get_output_var(c) %]);
34 |
35 | bi::gemv(A, b, c);
36 | }
37 |
38 | [% sig_action_dynamic_matrix_function('simulate') %] {
39 | simulates(s, p, pax, x);
40 | }
41 |
42 | [%-PROCESS action/misc/footer.hpp.tt-%]
43 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/resampler/StratifiedResamplerGPU.cuh:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_CUDA_RESAMPLER_STRATIFIEDRESAMPLERGPU_CUH
9 | #define BI_CUDA_RESAMPLER_STRATIFIEDRESAMPLERGPU_CUH
10 |
11 | #include "StratifiedResamplerKernel.cuh"
12 | #include "../device.hpp"
13 |
14 | template
15 | void bi::StratifiedResamplerGPU::op(Random& rng, const V1 Ws, V2 Os,
16 | const int n) {
17 | /* pre-condition */
18 | BI_ASSERT(Ws.size() == Os.size());
19 |
20 | typedef typename V1::value_type T1;
21 | typename sim_temp_vector::type alphas(n);
22 |
23 | const int P = Ws.size();
24 |
25 | rng.uniforms(alphas);
26 |
27 | dim3 Db, Dg;
28 | Db.x = bi::min(P, deviceIdealThreadsPerBlock());
29 | Dg.x = (bi::min(P, deviceIdealThreads()) + Db.x - 1)/Db.x;
30 | //deviceBalance1d(Db, Dg);
31 |
32 | kernelStratifiedResamplerOp<<>>(alphas, Ws, Os, n);
33 | CUDA_CHECK;
34 | }
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/share/src/bi/typelist/append.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_TYPELIST_APPEND_HPP
9 | #define BI_TYPELIST_APPEND_HPP
10 |
11 | #include "typelist.hpp"
12 | #include "front_spec.hpp"
13 | #include "push_back_spec.hpp"
14 | #include "pop_front_spec.hpp"
15 |
16 | namespace bi {
17 | /**
18 | * Append two type lists.
19 | *
20 | * @ingroup typelist
21 | *
22 | * @tparam T1 A type list.
23 | * @tparam T2 A type list.
24 | */
25 | template
26 | struct append {
27 | typedef typename append::type>::type,typename pop_front_spec::type>::type type;
28 | };
29 |
30 | /**
31 | * @internal
32 | */
33 | template
34 | struct append {
35 | typedef T1 type;
36 | };
37 |
38 | /**
39 | * @internal
40 | */
41 | template
42 | struct append {
43 | typedef T2 type;
44 | };
45 |
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/share/src/bi/null/OptimiserNullBuffer.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_NULL_OPTIMISERNULLBUFFER_HPP
9 | #define BI_NULL_OPTIMISERNULLBUFFER_HPP
10 |
11 | #include "SimulatorNullBuffer.hpp"
12 |
13 | namespace bi {
14 | /**
15 | * Null output buffer for optimisers.
16 | *
17 | * @ingroup io_null
18 | */
19 | class OptimiserNullBuffer: public SimulatorNullBuffer {
20 | public:
21 | /**
22 | * @copydoc OptimiserNetCDFBuffer::OptimiserNetCDFBuffer()
23 | */
24 | OptimiserNullBuffer(const Model& m, const size_t T = 0,
25 | const std::string& file = "", const FileMode mode = READ_ONLY,
26 | const SchemaMode schema = PARAM_ONLY);
27 |
28 | /**
29 | * @copydoc OptimiserNetCDFBuffer::writeValue()
30 | */
31 | void writeValue(const size_t k, const real& x);
32 |
33 | /**
34 | * @copydoc OptimiserNetCDFBuffer::writeSize()
35 | */
36 | void writeSize(const size_t k, const real& x);
37 | };
38 | }
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/share/src/bi/misc/exception.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MISC_EXCEPTION_HPP
9 | #define BI_MISC_EXCEPTION_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Cholesky decomposition failed (matrix not positive definite).
14 | */
15 | struct CholeskyException {
16 | /**
17 | * Constructor.
18 | */
19 | CholeskyException(const int info) : info(info) {
20 | //
21 | }
22 |
23 | /**
24 | * Info return by potrf().
25 | */
26 | int info;
27 | };
28 |
29 | /**
30 | * Eigendecomposition failed.
31 | */
32 | struct EigenException {
33 | /**
34 | * Constructor.
35 | */
36 | EigenException(const int info) : info(info) {
37 | //
38 | }
39 |
40 | /**
41 | * Info return by potrf().
42 | */
43 | int info;
44 | };
45 |
46 | /**
47 | * Particle filter degenerated.
48 | */
49 | struct ParticleFilterDegeneratedException {
50 | //
51 | };
52 | }
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/share/src/bi/host/math/cblas.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "cblas.hpp"
9 |
10 | #define CBLAS_FUNC_DEF(name, dname, sname) \
11 | BOOST_TYPEOF(cblas_##sname) *bi::cblas_##name::func = cblas_##sname; \
12 | BOOST_TYPEOF(cblas_##dname) *bi::cblas_##name::func = cblas_##dname;
13 |
14 | CBLAS_FUNC_DEF(copy, dcopy, scopy)
15 | CBLAS_FUNC_DEF(scal, dscal, sscal)
16 | CBLAS_FUNC_DEF(dot, ddot, sdot)
17 | CBLAS_FUNC_DEF(iamax, idamax, isamax)
18 | CBLAS_FUNC_DEF(axpy, daxpy, saxpy)
19 | CBLAS_FUNC_DEF(gemv, dgemv, sgemv)
20 | CBLAS_FUNC_DEF(symv, dsymv, ssymv)
21 | CBLAS_FUNC_DEF(trmv, dtrmv, strmv)
22 | CBLAS_FUNC_DEF(gbmv, dgbmv, sgbmv)
23 | CBLAS_FUNC_DEF(gemm, dgemm, sgemm)
24 | CBLAS_FUNC_DEF(symm, dsymm, ssymm)
25 | CBLAS_FUNC_DEF(trmm, dtrmm, strmm)
26 | CBLAS_FUNC_DEF(ger, dger, sger)
27 | CBLAS_FUNC_DEF(syr, dsyr, ssyr)
28 | CBLAS_FUNC_DEF(syr2, dsyr2, ssyr2)
29 | CBLAS_FUNC_DEF(syrk, dsyrk, ssyrk)
30 | CBLAS_FUNC_DEF(trsv, dtrsv, strsv)
31 | CBLAS_FUNC_DEF(trsm, dtrsm, strsm)
32 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/math/cublas.cu:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "cublas.hpp"
9 |
10 | #define CUBLAS_FUNC_DEF(name, dname, sname) \
11 | BOOST_TYPEOF(cublas##sname) *bi::cublas_##name::func = cublas##sname; \
12 | BOOST_TYPEOF(cublas##dname) *bi::cublas_##name::func = cublas##dname;
13 |
14 | CUBLAS_FUNC_DEF(copy, Dcopy, Scopy)
15 | CUBLAS_FUNC_DEF(scal, Dscal, Sscal)
16 | CUBLAS_FUNC_DEF(dot, Ddot, Sdot)
17 | CUBLAS_FUNC_DEF(iamax, Idamax, Isamax)
18 | CUBLAS_FUNC_DEF(axpy, Daxpy, Saxpy)
19 | CUBLAS_FUNC_DEF(gemv, Dgemv, Sgemv)
20 | CUBLAS_FUNC_DEF(symv, Dsymv, Ssymv)
21 | CUBLAS_FUNC_DEF(trmv, Dtrmv, Strmv)
22 | CUBLAS_FUNC_DEF(gbmv, Dgbmv, Sgbmv)
23 | CUBLAS_FUNC_DEF(gemm, Dgemm, Sgemm)
24 | CUBLAS_FUNC_DEF(symm, Dsymm, Ssymm)
25 | CUBLAS_FUNC_DEF(trmm, Dtrmm, Strmm)
26 | CUBLAS_FUNC_DEF(ger, Dger, Sger)
27 | CUBLAS_FUNC_DEF(syr, Dsyr, Ssyr)
28 | CUBLAS_FUNC_DEF(syr2, Dsyr2, Ssyr2)
29 | CUBLAS_FUNC_DEF(syrk, Dsyrk, Ssyrk)
30 | CUBLAS_FUNC_DEF(trsv, Dtrsv, Strsv)
31 | CUBLAS_FUNC_DEF(trsm, Dtrsm, Strsm)
32 |
--------------------------------------------------------------------------------
/share/tt/cpp/macro.hpp.tt:
--------------------------------------------------------------------------------
1 | [%-
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | -%]
8 | [%-PROCESS macro/alias_dims.hpp.tt-%]
9 | [%-PROCESS macro/create_action_typedef.hpp.tt-%]
10 | [%-PROCESS macro/create_action_typelist.hpp.tt-%]
11 | [%-PROCESS macro/create_action_typetree.hpp.tt-%]
12 | [%-PROCESS macro/create_block_typedef.hpp.tt-%]
13 | [%-PROCESS macro/create_block_typelist.hpp.tt-%]
14 | [%-PROCESS macro/declare_action_function.hpp.tt-%]
15 | [%-PROCESS macro/declare_action_matrix_function.hpp.tt-%]
16 | [%-PROCESS macro/declare_block_function.hpp.tt-%]
17 | [%-PROCESS macro/fetch_parents.hpp.tt-%]
18 | [%-PROCESS macro/get_var.hpp.tt-%]
19 | [%-PROCESS macro/offset_coord.hpp.tt-%]
20 | [%-PROCESS macro/put_output.hpp.tt-%]
21 | [%-PROCESS macro/read_argv.cpp.tt-%]
22 | [%-PROCESS macro/sig_action_function.hpp.tt-%]
23 | [%-PROCESS macro/sig_action_matrix_function.hpp.tt-%]
24 | [%-PROCESS macro/sig_block_function.hpp.tt-%]
25 | [%-PROCESS macro/std_action.hpp.tt-%]
26 | [%-PROCESS macro/std_action_function.hpp.tt-%]
27 | [%-PROCESS macro/std_block_function.hpp.tt-%]
28 |
--------------------------------------------------------------------------------
/share/tt/cpp/action/ode_.hpp.tt:
--------------------------------------------------------------------------------
1 | [%
2 | ## @file
3 | ##
4 | ## @author Lawrence Murray
5 | ## $Rev$
6 | ## $Date$
7 | %]
8 |
9 | [%-PROCESS action/misc/header.hpp.tt-%]
10 |
11 | [%-
12 | dfdt = action.get_named_arg('dfdt')
13 | -%]
14 |
15 | /**
16 | * Action: [% action.get_name %].
17 | */
18 | class [% class_name %] {
19 | public:
20 | [% std_action %]
21 |
22 | /**
23 | * Compute time derivative of variable.
24 | */
25 | template
26 | static CUDA_FUNC_BOTH void dfdt(const T1 t,
27 | const bi::State<[% model_class_name %],L>& s, const int p,
28 | const CX& cox, const PX& pax, T2& dfdt);
29 | };
30 |
31 | template
32 | inline void [% class_name %]::dfdt(const T1 t,
33 | const bi::State<[% model_class_name %],L>& s, const int p,
34 | const CX& cox, const PX& pax, T2& dfdt) {
35 | [% alias_dims(action) %]
36 | [% fetch_parents(action) %]
37 | [% offset_coord(action) %]
38 | dfdt = [% dfdt.to_cpp %];
39 | }
40 |
41 | [%-PROCESS action/misc/footer.hpp.tt-%]
42 |
--------------------------------------------------------------------------------
/share/src/bi/buffer/buffer.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_BUFFER_BUFFER_HPP
9 | #define BI_BUFFER_BUFFER_HPP
10 |
11 | namespace bi {
12 | /**
13 | * Schema flags.
14 | */
15 | enum SchemaMode {
16 | /**
17 | * Default schema.
18 | */
19 | DEFAULT,
20 |
21 | /**
22 | * Have multiple parameter samples.
23 | */
24 | MULTI,
25 |
26 | /**
27 | * Multiple parameter samples, but parameters only.
28 | */
29 | PARAM_ONLY,
30 |
31 | /**
32 | * Use flexi schema.
33 | */
34 | FLEXI
35 | };
36 |
37 | /**
38 | * File open flags.
39 | */
40 | enum FileMode {
41 | /**
42 | * Open file read-only.
43 | */
44 | READ_ONLY,
45 |
46 | /**
47 | * Open file for reading and writing,
48 | */
49 | WRITE,
50 |
51 | /**
52 | * Open file for reading and writing, replacing any existing file of the
53 | * same name.
54 | */
55 | REPLACE,
56 |
57 | /**
58 | * Open file for reading and writing, fails if any existing file of the
59 | * same name
60 | */
61 | NEW
62 | };
63 | }
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/share/src/bi/netcdf/NetCDFBuffer.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #include "NetCDFBuffer.hpp"
9 |
10 | #include "../misc/assert.hpp"
11 |
12 | bi::NetCDFBuffer::NetCDFBuffer(const std::string& file, const FileMode mode) :
13 | file(file), ncid(-1) {
14 | BI_ERROR_MSG(!file.empty(), "No file specified");
15 | switch (mode) {
16 | case WRITE:
17 | ncid = nc_open(file, NC_WRITE);
18 | break;
19 | case NEW:
20 | ncid = nc_create(file, NC_NETCDF4 | NC_NOCLOBBER);
21 | nc_set_fill(ncid, NC_NOFILL);
22 | break;
23 | case REPLACE:
24 | ncid = nc_create(file, NC_NETCDF4);
25 | nc_set_fill(ncid, NC_NOFILL);
26 | break;
27 | default:
28 | ncid = nc_open(file, NC_NOWRITE);
29 | }
30 | }
31 |
32 | bi::NetCDFBuffer::NetCDFBuffer(const NetCDFBuffer& o) :
33 | file(o.file), ncid(-1) {
34 | if (!file.empty()) {
35 | ncid = nc_open(file, NC_NOWRITE);
36 | }
37 | }
38 |
39 | bi::NetCDFBuffer::~NetCDFBuffer() {
40 | nc_sync(ncid);
41 | nc_close(ncid);
42 | }
43 |
44 | void bi::NetCDFBuffer::clear() {
45 | //
46 | }
47 |
--------------------------------------------------------------------------------
/share/src/bi/math/loc_vector.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_MATH_LOC_VECTOR_HPP
9 | #define BI_MATH_LOC_VECTOR_HPP
10 |
11 | #include "vector.hpp"
12 | #include "../misc/location.hpp"
13 |
14 | #include "boost/mpl/if.hpp"
15 |
16 | namespace bi {
17 | /**
18 | * Vector with location designated by template parameter.
19 | *
20 | * @ingroup math_matvec
21 | *
22 | * @tparam L Location.
23 | * @tparam T Scalar type.
24 | * @tparam size_value Static size, -1 for dynamic.
25 | * @tparam inc_value Static increment, -1 for dynamic.
26 | *
27 | * loc_vector is a convenience class for creating a vector on host or device
28 | * according to a template argument.
29 | */
30 | template
31 | struct loc_vector {
32 | #ifdef ENABLE_CUDA
33 | typedef typename boost::mpl::if_c,
35 | host_vector >::type type;
36 | #else
37 | typedef host_vector type;
38 | #endif
39 | };
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/lib/Bi/Visitor/EvalConst.pm:
--------------------------------------------------------------------------------
1 | =head1 NAME
2 |
3 | Bi::Visitor::EvalConst - visitor for evaluating a constant expression.
4 |
5 | =head1 SYNOPSIS
6 |
7 | use Bi::Visitor::EvalConst;
8 | $val = Bi::Visitor::EvalConst->evaluate($expr);
9 |
10 | =head1 INHERITS
11 |
12 | L
13 |
14 | =head1 METHODS
15 |
16 | =over 4
17 |
18 | =cut
19 |
20 | package Bi::Visitor::EvalConst;
21 |
22 | use parent 'Bi::Visitor';
23 | use warnings;
24 | use strict;
25 |
26 | use Carp::Assert;
27 | use Bi::Visitor::ToPerl;
28 |
29 | =item B(I)
30 |
31 | Evaluate.
32 |
33 | =over 4
34 |
35 | =item I
36 |
37 | L object.
38 |
39 | =back
40 |
41 | Returns the result of evaluating the expression.
42 |
43 | =cut
44 | sub evaluate {
45 | my $class = shift;
46 | my $expr = shift;
47 |
48 | assert ($expr->isa('Bi::Expression') && $expr->is_const) if DEBUG;
49 |
50 | my $perl = Bi::Visitor::ToPerl->evaluate($expr);
51 |
52 | return eval($perl);
53 | }
54 |
55 | 1;
56 |
57 | =back
58 |
59 | =head1 AUTHOR
60 |
61 | Lawrence Murray
62 |
63 | =head1 VERSION
64 |
65 | $Rev$ $Date$
66 |
--------------------------------------------------------------------------------
/share/src/bi/host/math/sim_temp_vector.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_HOST_MATH_SIM_TEMP_VECTOR_HPP
9 | #define BI_HOST_MATH_SIM_TEMP_VECTOR_HPP
10 |
11 | #include "temp_vector.hpp"
12 |
13 | #include "boost/mpl/if.hpp"
14 |
15 | namespace bi {
16 | /**
17 | * Temporary host vector type that is similar to some other given stencil
18 | * type.
19 | *
20 | * @ingroup math_matvec
21 | *
22 | * @tparam VM1 Vector or matrix type.
23 | * @tparam size_value Static size, -1 for dynamic.
24 | * @tparam inc_value Static increment, -1 for dynamic.
25 | *
26 | * sim_temp_host_vector is a convenience class for creating a temporary vector
27 | * on host that is similar to the given vector or matrix type @p VM1 in the
28 | * sense that it has the same scalar type.
29 | */
30 | template
31 | struct sim_temp_host_vector {
32 | /**
33 | * @internal
34 | */
35 | typedef typename VM1::value_type T;
36 |
37 | typedef typename temp_host_vector::type type;
38 | };
39 | }
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/share/src/bi/concept/Kernel.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #error "Concept documentation only, should not be #included"
9 |
10 | namespace concept {
11 | /**
12 | * %Kernel.
13 | *
14 | * @ingroup concept
15 | *
16 | * @note This is a phony class, representing a concept, for documentation
17 | * purposes only.
18 | */
19 | struct Kernel {
20 | /**
21 | * Evaluate the kernel.
22 | *
23 | * @param x \f$x\f$; point at which to evaluate the kernel.
24 | *
25 | * @return \f$\log \mathcal{K}(x)\f$; log-density of the kernel at the
26 | * given point.
27 | */
28 | template
29 | T1 logDensity(const T1 x) const = 0;
30 |
31 | /**
32 | * Evaluate the kernel.
33 | *
34 | * @param x \f$x\f$; point at which to evaluate the kernel.
35 | *
36 | * @return \f$\mathcal{K}(x)\f$; density of the kernel at the given point.
37 | */
38 | template
39 | T1 density(const T1 x) const = 0;
40 |
41 | /**
42 | * @copydoc density()
43 | */
44 | template
45 | T1 operator()(const T1 x) const = 0;
46 | };
47 | }
48 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/math/sim_temp_vector.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * @author Lawrence Murray
5 | * $Rev$
6 | * $Date$
7 | */
8 | #ifndef BI_CUDA_MATH_SIM_TEMP_VECTOR_HPP
9 | #define BI_CUDA_MATH_SIM_TEMP_VECTOR_HPP
10 |
11 | #include "temp_vector.hpp"
12 |
13 | #include "boost/mpl/if.hpp"
14 |
15 | namespace bi {
16 | /**
17 | * Temporary device vector type that is similar to some other given stencil
18 | * type.
19 | *
20 | * @ingroup math_matvec
21 | *
22 | * @tparam VM1 Vector or matrix type.
23 | * @tparam size_value Static size, -1 for dynamic.
24 | * @tparam inc_value Static increment, -1 for dynamic.
25 | *
26 | * sim_temp_gpu_vector is a convenience class for creating a temporary vector
27 | * on device that is similar to the given vector or matrix type @p VM1 in the
28 | * sense that it has the same scalar type.
29 | */
30 | template
31 | struct sim_temp_gpu_vector {
32 | /**
33 | * @internal
34 | */
35 | typedef typename VM1::value_type T;
36 |
37 | typedef typename temp_gpu_vector::type type;
38 | };
39 | }
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/share/src/bi/cuda/math/magma.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * Macros for MAGMA usage.
5 | *
6 | * @author Lawrence Murray
7 | * $Rev$
8 | * $Date$
9 | */
10 | #ifndef BI_CUDA_MATH_MAGMA_HPP
11 | #define BI_CUDA_MATH_MAGMA_HPP
12 |
13 | #include "cublas.hpp"
14 | #ifdef HAVE_MAGMA_H
15 | #include "magma.h"
16 | #endif
17 |
18 | #include "boost/typeof/typeof.hpp"
19 |
20 | /**
21 | * @def MAGMA_FUNC(name, sname, dname)
22 | *
23 | * Macro for constructing template facades for magma functions.
24 | */
25 | #define MAGMA_FUNC(name, dname, sname) \
26 | namespace bi { \
27 | template