STANC(1)

πŸ“¦
version 2.40.0 Β· 2 versions
, in nixpkgs unstable

πŸ’… STANC(1) β€” like, the Stanc Manual, bestie ✨

okay so real talk: this is the manual page for stanc, and I'm gonna walk you through it like we're texting at 1am 🫢 it's literally the Stan compiler (aka stanc or stanc3), and I promise it's not scary.


🌸 NAME 🌸

stanc β€” compile Stan programs to C++ πŸ”₯

✨ SYNOPSIS ✨

stanc [OPTION]… [MODEL_FILE]

πŸ¦‹ DESCRIPTION πŸ¦‹

So the Stan compiler β€” which honestly goes by stanc or stanc3, pick your fave πŸ’… β€” reads a Stan file and compiles it to C++. That's the main character job. But it ALSO does other Stan program manipulation, like formatting (--auto-format) and introspection (--info). Versatile queen πŸ‘‘.

Wanna know more about Stan in general? https://mc-stan.org β€” go look, it's giving documentation.

More docs on the compiler, like, for users? https://mc-stan.org/docs/stan-users-guide/using-stanc.html 🌈

And for the devs, more compiler info lives at %%PKG_DOC%% 🧚


πŸŽ€ ARGUMENTS πŸŽ€

  • MODEL_FILE β€” the Stan model file you want to compile. It should be a file ending in .stan or .stanfunctions (and ooooh, ending in .stanfunctions automatically sets --standalone-functions for you, slay ✨), or you can pass '-' to read from standard input πŸ“

πŸ’– OPTIONS πŸ’–

okay this is the long part, stay with me, we're gonna get through it together 🫢

  • -? [=FMT] (default=auto) β€” literally just a synonym for --help. same vibe, different key πŸ’…
  • --allow-undefined β€” don't fail if a function is declared but not defined. usually that means the definition is gonna show up later as a C++ function, so like, it's fine, it's handled πŸ™ˆ
  • --auto-format β€” outputs a formatted version of the Stan program. you can tweak that output with --max-line-length and --canonicalize ✨
  • --canonicalize=OPTIONS β€” turn on specific canonicalizations in a comma separated list. the options are 'deprecations', 'parentheses', 'braces', 'includes', 'strip-comments' 🧚
  • --color=WHEN (absent=auto or STANC_COLORS env) β€” colorize the output. WHEN has to be one of auto, always or never. aesthetic decisions are valid 🌈
  • --filename-in-msg=FILENAME (absent=MODEL_FILE) β€” sets the filename used in compiler and runtime errors πŸ‘‘
  • --help[=FMT] (default=auto) β€” shows this help in format FMT. FMT must be one of auto, pager, groff or plain. with auto, the format is pager or plain whenever the TERM env var is dumb or undefined πŸ’€
  • -I DIRS, --include-paths=DIRS (absent="") β€” a comma-separated list of directories that get searched whenever an #include directive is parsed. like a little scavenger hunt for includes πŸ“
  • --info β€” if set, print information about the model πŸ‘€
  • --max-line-length=LENGTH (absent=78) β€” sets the max line length for the formatter. 78 is the default, no cap πŸ“
  • --name=NAME (absent=MODEL_FILE_NAME_model) β€” takes a string and sets it as the model name. this controls the namespace in the generated C++ 🏷️
  • -o FILENAME, --output=FILENAME β€” output file for generated C++ code (default = "MODEL_FILE_NAME.hpp") or for auto-formatting output (default: no file/print to stdout) πŸ’Ύ
  • --O0 β€” (Default) do not apply optimizations to the Stan code. it's giving unbothered 😌
  • --O1 β€” only basic optimizations are applied. Recommended ⭐ also: the deprecated option --O is aliased to this starting in Stan 2.37, so heads up 🫢
  • --Oexperimental β€” (Experimental) apply ALL compiler optimizations. some of these are not thorougly tested and may not always improve a program's performance. it's giving risky behavior, don't say I didn't warn you πŸ’€
  • --print-canonical β€” prints the canonicalized program. equivalent to --auto-format --canonicalize=deprecations,includes,parentheses,braces ✨
  • --print-cpp β€” if set, output the generated C++ Stan model class to stdout πŸ”₯
  • --standalone-functions β€” if set, the generated C++ will only contain the code for the functions in the functions block, not the full Stan model class. minimalism, we love her πŸŽ€
  • --use-opencl β€” if set, try to use matrix_cl signatures for supported Stan Math functions πŸ–₯️
  • --version β€” show version information 🌸
  • --warn-pedantic β€” emit warnings about common mistakes in Stan programs. Note: this may produce false positive warnings, so like, don't spiral πŸ™ˆ
  • --warn-uninitialized β€” (Experimental) emit warnings about uninitialized variables πŸ‘€

πŸ’œ COMMANDS πŸ’œ

these flags make the compiler exit right after printing info. no MODEL_FILE required, bestie, you can just run them 🫢

  • --dump-stan-math-distributions β€” dumps out the list of supported probability distributions and their supported suffix types for the Stan Math backend πŸ“Š
  • --dump-stan-math-signatures β€” dumps out the list of supported function signatures the for Stan Math backend πŸ“‹

πŸ”§ EXTRA OPTIONS πŸ”§

these flags are provided primarily for development and debugging. their exact behavior should not be relied on. like, fr fr, don't build your whole thing on these πŸ’€
  • --debug-ast β€” for debugging purposes: print the undecorated AST, before semantic checking 🌱
  • --debug-data-file=JSON_FILE β€” provide (possibly partially specified) data block values for use with --debug-generate-data or --debug-generate-inits πŸ“
  • --debug-decorated-ast β€” for debugging purposes: print the decorated AST, after semantic checking πŸŽ„
  • --debug-generate-data β€” for debugging purposes: generate a mock dataset to run the model on 🎲
  • --debug-generate-inits β€” for debugging purposes: generate a mock initial value for each parameter 🎯
  • --debug-lex β€” for debugging purposes: print the lexer actions πŸ”
  • --debug-lir β€” for debugging purposes: print the C++ LIR as a s-expression. mainly for comparison with --print-cpp 🧬
  • --debug-mem-patterns β€” for debugging purposes: print a list of matrix variables and their memory type, either AoS (array of structs) or the more efficient SoA (struct of arrays). only has an effect when optimizations are turned on 🧠
  • --debug-mir β€” for debugging purposes: print the MIR after lowering ⬇️
  • --debug-mir-pretty β€” for debugging purposes: pretty-print the MIR after lowering πŸ’…
  • --debug-optimized-mir β€” for debugging purposes: print the MIR after it's been optimized. only has an effect when optimizations are turned on ⚑
  • --debug-optimized-mir-pretty β€” for debugging purposes: pretty-print the MIR after it's been optimized. only has an effect when optimizations are turned on ✨
  • --debug-parse β€” for debugging purposes: print the parser actions πŸ”Ž
  • --debug-print-factor-graph β€” for debugging purposes: print a conservative over-approximation of the factor graph for the model(s) implemented in the Stan program πŸ•ΈοΈ
  • --debug-transformed-mir β€” for debugging purposes: print the MIR after the backend has transformed it πŸ”„
  • --debug-transformed-mir-pretty β€” for debugging purposes: pretty-print the MIR after the backend has transformed it πŸŽ€
  • -f SETTING β€” debugging features. valid values: -fsoa to force on the Struct of Arrays optimization, -fno-soa to force it off πŸ”¨

🌟 EXIT STATUS 🌟

  • 0 β€” on success. we love a happy ending πŸ’–
  • 1 β€” on compilation failure 😭
  • 124 β€” on command line parsing errors 🫠
  • 125 β€” on internal compiler errors. Please file a bug! like genuinely, tell them, they wanna know πŸ›

🌈 ENVIRONMENT 🌈

these environment variables affect how stanc runs:

  • STANC_COLORS β€” see option --color 🎨

πŸ“ BUGS πŸ“

please report at %%PKG_ISSUES%% 🐞 don't suffer in silence, bestie 🫢


okay that's the whole thing! and for the cute sign-off: this page is from Stanc stanc3 v2.40.0 (Unix) β€” that's the source/version you're looking at, mwah πŸ’‹ go compile something iconic πŸ‘‘βœ¨

πŸ“¦ where this page comes from