Skip to content

A Rust library for accessing a collection of mathematical and cryptographic constants πŸ¦€

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sebastienrousseau/cmn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

71 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Common (CMN) logo

Common (CMN)

A Rust library for accessing a collection of mathematical and cryptographic constants

Part of the Mini Functions family of libraries.

Common (CMN) Banner

Made With Rust Crates.io Lib.rs Docs.rs License Codecov

β€’ Website β€’ Documentation β€’ Report Bug β€’ Request Feature β€’ Contributing Guidelines

divider

Overview πŸ“–

Common (CMN) is a modern, fast, and user-friendly library that makes it easy to access a wide range of mathematical and cryptographic constants.

Features ✨

The Common (CMN) uses the serde crate to serialize and deserialize the data.

The library has three modules:

  • Macros: This module contains functions for generating macros that can be used to access the constants and words.
  • Constants: This module contains the Constants structure, which provides a collection of constant values that are used throughout the library.
  • Words: This module contains the Words structure, which provides a collection of words that are used throughout the library.

Mathematical and Cryptographic Constants

The following table lists the most important mathematical and cryptographic constants available in the Common (CMN) library:

Constants Description Example
APERY ApΓ©ry's constant, which is the sum of the reciprocals of the positive cubes. ΞΆ(3) β‰ˆ 1.2020569032 Used in various mathematical calculations and series approximations.
AVOGADRO Avogadro's constant is the number of atoms or molecules in one mole of a substance. N_A β‰ˆ 6.02214076 x 10^23 mol^-1 The number of atoms in 12 grams of carbon-12 is 6.02214076 Γ— 10^23. This can be used to calculate the number of atoms or molecules in a given sample.
BOLTZMANN Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles. k_B β‰ˆ 1.380648 x 10^-23 J K^-1 The kinetic energy of an atom at room temperature is about 2.0 Γ— 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles.
CATALAN Catalan's constant, which is the sum of the alternating harmonic series. C β‰ˆ 0.915965594177219 Used in various mathematical calculations and series approximations.
COULOMB Coulomb's constant, which is the proportionality constant in Coulomb's law. k_e β‰ˆ 8.9875517923 x 10^9 N m^2 C^-2 Used in calculations related to electrostatic forces and electric fields.
EULER Euler's constant is a mathematical constant approximately equal to 2.71828. e β‰ˆ 2.7182818284590452353602874713527 The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number.
FARADAY Faraday constant, which represents the amount of electric charge carried by one mole of electrons. F β‰ˆ 96485.33212 C mol^-1 Used in calculations related to electrochemistry and electrolysis.
GAMMA The gamma constant is a mathematical constant approximately equal to 0.57721. Ξ³ β‰ˆ 0.5772156649015329 The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number.
GAS_CONSTANT The gas constant, which relates the energy scale to the temperature scale in the ideal gas law. R β‰ˆ 8.314462618 J mol^-1 K^-1 Used in calculations related to the behavior of gases and thermodynamics.
GLAISHER_KINKELIN Glaisher-Kinkelin constant, which arises in the asymptotic expansion of the Barnes G-function. A β‰ˆ 1.2824271291 Used in various mathematical calculations and series approximations.
GRAVITATIONAL_CONSTANT The gravitational constant, which is the proportionality constant in Newton's law of universal gravitation. G β‰ˆ 6.67430 x 10^-11 m^3 kg^-1 s^-2 Used in calculations related to gravitational forces and celestial mechanics.
HASH_ALGORITHM The hash algorithm used to generate the hash. The default is Blake3. The hash of the string "Hello, world!" is 5eb63bbbe01eeed093cb22bb8f5acdc32790160b123138d53f2173b8d3dc3eee. This can be used to verify the integrity of data, or to create a unique identifier for a file.
HASH_COST The cost of the hash. The hash cost of Blake3 is 2^128. This can be used to determine how secure a hash algorithm is.
HASH_LENGTH The length of the hash. The hash length of Blake3 is 32 bytes. This can be used to determine how much space is required to store the hash output.
KHINCHIN Khinchin's constant, which appears in the theory of continued fractions. K β‰ˆ 2.6854520010 Used in various mathematical calculations and series approximations.
PHI The golden ratio is a number approximately equal to 1.618033988749895. Ο† = (1 + √5) / 2 β‰ˆ 1.6180339887498948482045868343656 The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye.
Pi (Ο€) Pi is the ratio of a circle's circumference to its diameter. Ο€ β‰ˆ 3.14159265358979323846264338327950288 The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes.
PLANCK Planck's constant, which relates the energy of a photon to its frequency. h β‰ˆ 6.62607015 x 10^-34 J s The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles.
PLANCK_REDUCED Planck's reduced constant, which is Planck's constant divided by 2Ο€. Δ§ = h / (2Ο€) β‰ˆ 1.054571817 x 10^-34 J s Used in quantum mechanics and related calculations.
SILVER_RATIO The silver ratio is one of the silver means. Ξ΄_s = 1 + √2 β‰ˆ 2.4142135623730950488016887242097 The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye.
SPEED_OF_LIGHT The speed of light in vacuum. c β‰ˆ 299792458 m s^-1 Used in calculations related to relativity and electromagnetic phenomena.
SPECIAL_CHARS A set of special characters. The special characters are: !@#$%^&*()_+-={}[]
SQRT2 The square root of 2. √2 β‰ˆ 1.4142135623730950488016887242097 The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes.
SQRT3 The square root of 3. √3 β‰ˆ 1.7320508075688772935274463415059 The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles.
SQRT5 The square root of 5. √5 β‰ˆ 2.23606797749979 The area of a circle with a radius of 1 is equal to the square root of 5.
TAU The circle constant, which is the ratio of a circle's circumference to its radius. Ο„ = 2Ο€ β‰ˆ 6.28318530717958647692528676655900577 The circumference of a circle with a radius of 1 is equal to tau.
VACUUM_PERMEABILITY The vacuum permeability, which relates magnetic induction to magnetic field strength. ΞΌ_0 β‰ˆ 1.25663706212 x 10^-6 N A^-2 Used in calculations related to electromagnetism and magnetic fields.
VACUUM_PERMITTIVITY The vacuum permittivity, which relates electric displacement to electric field strength. Ξ΅_0 β‰ˆ 8.8541878128 x 10^-12 F m^-1 Used in calculations related to electromagnetism and electric fields.

Getting Started πŸš€

It takes just a few minutes to get up and running with Common (CMN).

Installation

To install Common (CMN), you need to have the Rust toolchain installed on your machine. You can install the Rust toolchain by following the instructions on the Rust website.

Once you have the Rust toolchain installed, you can install Common (CMN) using the following command:

cargo install cmn

Requirements

The minimum supported Rust toolchain version is currently Rust 1.60 or later (stable). It is recommended that you install the latest stable version of Rust.

Platform support

cmn supports a variety of CPU architectures. It is supported and tested on MacOS, Linux, and Windows.

Documentation

ℹ️ Info: Please check out our website for more information. You can find our documentation on docs.rs, lib.rs and crates.io.

Usage πŸ“–

To use the Common (CMN) library in your project, add the following to your Cargo.toml file:

[dependencies]
cmn = "0.0.4"

Add the following to your main.rs file:

extern crate cmn;
use cmn::*;

then you can use the functions in your application code.

Examples

Common (CMN) comes with a set of examples that you can use to get started. The examples are located in the examples directory of the project. To run the examples, clone the repository and run the following command in your terminal from the project root directory.

cargo run --example cmn

Semantic Versioning Policy πŸš₯

For transparency into our release cycle and in striving to maintain backward compatibility, Common (CMN) follows semantic versioning.

License πŸ“

Common (CMN)is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Contribution 🀝

We welcome all people who want to contribute. Please see the contributing instructions for more information.

Contributions in any form (issues, pull requests, etc.) to this project must adhere to the Rust's Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Acknowledgements πŸ’™

A big thank you to all the awesome contributors of the Common (CMN) Library for their help and support.

A special thank you goes to the Rust Reddit community for providing a lot of useful suggestions on how to improve this project.