Skip to content

Instantly share code, notes, and snippets.

@drezap
Created May 7, 2019 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drezap/bf5dfbbb5013c317fefd838dec271f3d to your computer and use it in GitHub Desktop.
Save drezap/bf5dfbbb5013c317fefd838dec271f3d to your computer and use it in GitHub Desktop.
resets includes to work with the flattened prim structure throughout the entire stan math library
fldrs=("rev" "mix" "fwd" "prim")
for fldr in "${fldrs[@]}";
do
echo $fldr
## parsing all .hpp files in rev, mix and prim
for f in ./stan/math/$fldr/*/*/*.hpp
do
echo $f
sed -i -e "s/stan\/math\/prim\/scal/stan\/math\/prim/g" $f ## remove scal
sed -i -e "s/stan\/math\/prim\/mat/stan\/math\/prim/g" $f ## "" mat
sed -i -e "s/stan\/math\/prim\/arr/stan\/math\/prim/g" $f ## "" arr
## edit higher level includes
sed -i -e "s/stan\/math\/prim\/scal.hpp/stan\/math\/prim.hpp/g" $f
sed -i -e "s/stan\/math\/prim\/mat.hpp/stan\/math\/prim.hpp/g" $f
sed -i -e "s/stan\/math\/prim\/arr.hpp/stan\/math\/prim.hpp/g" $f
done
for f in ./stan/math/rev/core/*.hpp
do
echo $f
sed -i -e "s/stan\/math\/prim\/scal/stan\/math\/prim/g" $f ## remove scal
sed -i -e "s/stan\/math\/prim\/mat/stan\/math\/prim/g" $f ## "" mat
sed -i -e "s/stan\/math\/prim\/arr/stan\/math\/prim/g" $f ## "" arrx
done
## editing the higher level includes
for f in ./stan/math/$fldr/*.hpp
do
echo $f
sed -i -e "s/stan\/math\/prim\/scal/stan\/math\/prim/g" $f
sed -i -e "s/stan\/math\/prim\/mat/stan\/math\/prim/g" $f
sed -i -e "s/stan\/math\/prim\/arr/stan\/math\/prim/g" $f
## edit higher level includes
sed -i -e "s/stan\/math\/prim\/scal.hpp/stan\/math\/prim.hpp/g" $f
sed -i -e "s/stan\/math\/prim\/mat.hpp/stan\/math\/prim.hpp/g" $f
sed -i -e "s/stan\/math\/prim\/arr.hpp/stan\/math\/prim.hpp/g" $f
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment