Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
prefix_table.hpp File Reference

The table of unit prefixes: a prefix is a dimensionless Unit. More...

#include "shamunits/Unit.hpp"
#include "shamunits/details/registry.hpp"
#include <string_view>
#include <array>
Include dependency graph for prefix_table.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  shamunits
 namespace containing the units library

Functions

Unit shamunits::prefix::from_name (std::string_view name)
 Prefix from its long or short name; throws std::invalid_argument if unknown.

Variables

constexpr Unit shamunits::prefix::tera = scale(1e12)
 T.
constexpr Unit shamunits::prefix::giga = scale(1e9)
 G.
constexpr Unit shamunits::prefix::mega = scale(1e6)
 M.
constexpr Unit shamunits::prefix::kilo = scale(1e3)
 k
constexpr Unit shamunits::prefix::hecto = scale(1e2)
 hect
constexpr Unit shamunits::prefix::deca = scale(1e1)
 dec
constexpr Unit shamunits::prefix::none = scale(1.)
 no prefix ("None", "_")
constexpr Unit shamunits::prefix::centi = scale(1e-2)
 c
constexpr Unit shamunits::prefix::milli = scale(1e-3)
 m
constexpr Unit shamunits::prefix::micro = scale(1e-6)
 mu
constexpr Unit shamunits::prefix::nano = scale(1e-9)
 n
constexpr Unit shamunits::prefix::pico = scale(1e-12)
 p
constexpr Unit shamunits::prefix::femto = scale(1e-15)
 f
constexpr auto shamunits::prefix::registry
 Name registry: Python passes pref="None" by default, so "None" must stay.

Detailed Description

The table of unit prefixes: a prefix is a dimensionless Unit.

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

A prefix multiplies a unit once: prefix::mega * units::year is one Myr, and upow(prefix::kilo * units::metre, 2) is one km2.

Definition in file prefix_table.hpp.

Function Documentation

◆ from_name()

Unit shamunits::prefix::from_name ( std::string_view name)
inline

Prefix from its long or short name; throws std::invalid_argument if unknown.

Definition at line 62 of file prefix_table.hpp.

Variable Documentation

◆ centi

Unit shamunits::prefix::centi = scale(1e-2)
inlineconstexpr

c

Definition at line 35 of file prefix_table.hpp.

◆ deca

Unit shamunits::prefix::deca = scale(1e1)
inlineconstexpr

dec

Definition at line 33 of file prefix_table.hpp.

◆ femto

Unit shamunits::prefix::femto = scale(1e-15)
inlineconstexpr

f

Definition at line 40 of file prefix_table.hpp.

◆ giga

Unit shamunits::prefix::giga = scale(1e9)
inlineconstexpr

G.

Definition at line 29 of file prefix_table.hpp.

◆ hecto

Unit shamunits::prefix::hecto = scale(1e2)
inlineconstexpr

hect

Definition at line 32 of file prefix_table.hpp.

◆ kilo

Unit shamunits::prefix::kilo = scale(1e3)
inlineconstexpr

k

Definition at line 31 of file prefix_table.hpp.

◆ mega

Unit shamunits::prefix::mega = scale(1e6)
inlineconstexpr

M.

Definition at line 30 of file prefix_table.hpp.

◆ micro

Unit shamunits::prefix::micro = scale(1e-6)
inlineconstexpr

mu

Definition at line 37 of file prefix_table.hpp.

◆ milli

Unit shamunits::prefix::milli = scale(1e-3)
inlineconstexpr

m

Definition at line 36 of file prefix_table.hpp.

◆ nano

Unit shamunits::prefix::nano = scale(1e-9)
inlineconstexpr

n

Definition at line 38 of file prefix_table.hpp.

◆ none

Unit shamunits::prefix::none = scale(1.)
inlineconstexpr

no prefix ("None", "_")

Definition at line 34 of file prefix_table.hpp.

◆ pico

Unit shamunits::prefix::pico = scale(1e-12)
inlineconstexpr

p

Definition at line 39 of file prefix_table.hpp.

◆ registry

auto shamunits::prefix::registry
inlineconstexpr
Initial value:
= std::to_array<NamedUnit>({
{"tera", "T", tera},
{"giga", "G", giga},
{"mega", "M", mega},
{"kilo", "k", kilo},
{"hecto", "hect", hecto},
{"deca", "dec", deca},
{"None", "_", none},
{"centi", "c", centi},
{"milli", "m", milli},
{"micro", "mu", micro},
{"nano", "n", nano},
{"pico", "p", pico},
{"femto", "f", femto},
})
constexpr Unit tera
T.
constexpr Unit pico
p
constexpr Unit deca
dec
constexpr Unit none
no prefix ("None", "_")
constexpr Unit milli
m
constexpr Unit giga
G.
constexpr Unit centi
c
constexpr Unit micro
mu
constexpr Unit nano
n
constexpr Unit hecto
hect
constexpr Unit femto
f

Name registry: Python passes pref="None" by default, so "None" must stay.

Definition at line 43 of file prefix_table.hpp.

◆ tera

Unit shamunits::prefix::tera = scale(1e12)
inlineconstexpr

T.

Definition at line 28 of file prefix_table.hpp.