Giter Club home page Giter Club logo

finitefields's Introduction

finitefields

crates.io documentation Build Status Byy Me A Coffee

Allows to perform simple algebraic operations over a finite field

Arguments

  • value - number be represented as value % modulo
  • modulo - An integer corresponding to the size of the modular space. For this to be a finite field it must be a prime number!

Operations

  • addition
  • subtraction
  • multiplication
  • division
  • inversion

Examples

// Simple operations within a finite field

use finitefields::{FF,Finitefield,primes};

fn main(){
    // Pick a prime
    let modulo = primes::PRIMES31[0];
    // Define numbers to be cast into our field
    let num1: FF = 23742687;
    let num2: FF = 87129774;

    let fnum1 = Finitefield::new(num1, modulo).unwrap();
    let fnum2 = Finitefield::new(num2, modulo).unwrap();

    // Compute product
    let product = fnum1 * fnum2;
    assert_eq!(product.value, 174523906);

    // Compute the inverse of the product
    let product_inv = product.inverse().unwrap();
    assert_eq!(product_inv.value, 486606559);

    // Multiply by the product
    assert_eq!((product * product_inv).value, 1);
}

finitefields's People

Contributors

apelloni avatar

Stargazers

Alireza Shirzad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.