Code Monkey home page Code Monkey logo

combinatoric's Introduction

ZoftWhere Combinatoric Library

Language License GitHub release (latest by date) GitHub Release Date GitHub last commit (branch)

A combinatoric library.

Features

Features for Series

  • Calculate the sequence for the sequence of values
  • Calculate the sequence for the sequence of squared values
  • Calculate the sequence for the sequence of cubed values
  • Calculate the sequence for the sequence of polynomial values
  • Use of primitive data type for sequence
  • Use of arbitrary precision data type for sequence

Features for Permutation

  • Manipulate index only zero-indexed permutation
  • Manipulate object-value linked to zero-indexed permutation
  • Retrieve/restore permutation state

Features for Combinations

(Still under development)

Not implemented (Out of current library scope)

  • Calculate the value of a negative integer power sequence
  • Calculate the value of an infinite sequence

Compiling and Installing the Library

The source code can be compiled with Java language version 8. It has been tested with Oracle JDK8, JDK11 and JDK12. The test sources are compiled against JDK 11.

The project is Maven based, so executing the mvn install should install the library to the local repository (Requires at least JDK11). It has been tested with Apache Maven v3.6.1.

The project will package the JavaDoc archive using JDK8 rules and styles. The JavaDoc archive can be set to a later release by specifying the maven.compiler.main-jdk property. For example, the JavaDoc will be packaged and installed for JDK11 by calling:

mvn clean install -Dmaven.compiler.main-jdk=11

If the project needs to be installed against JDK8, it can be accomplished by calling the following Maven command:

mvn clean compiler:compile@main-compile-jdk8 jar:jar@main-jar source:jar@main-sources javadoc:jar@main-javadoc-jdk8 moditect:add-module-info@main-jpms install:install-file@main-install

Examples

Example of Immutable Sequence

The sequence builder is an immutable factory as the sequence objects themselves are immutable builders.

    sequence = Generator.primitiveSequence();
    series10 = sequence.length(10);
    series20 = sequence.length(20);

Example for Sum of Series

The sequence builder allows the calculation of the sum of a sequence.

The sum 7 + 20 + 33 + ... 72

= 7 + ... + (7 + 13 i) + ... (7 + 13 * 5)

    // 237
    series = Generator.primitiveSequence()
        .base(7).increment(13).length(6).sum();

The sum (9)^6 + (19)^6 + (29)^6 + ... (1009)^6

= (9)^6 + ... + (9 + 10 i)^6 + ... (9 + 10 * 100)^6

    // 15743225838776547541
    series = Generator.bigIntegerSequence()
        .base(9).increment(10).exponent(6).length(101).sum();

The sum (1.1)^4 + (2.2)^4 + (3.3)^4 + ... + (1.1 + 1.1 n)^4 + ... (10312.5)^4

= (0.0)^4 + (1.1)^4 + (2.2)^4 + (3.3)^4 + ... + (1.1 * 9375)^4

    // 21211575295124816437.0000
    series = Generator.bigDecimalSequence()
        .base(0).increment(BigDecimal.valueOf(1.1)).exponent(4).length(9376).sum();

Example for Permutation (index only)

To run through two permutations by changing the index 1 to the next value.

    permutation = Generator.newPermutation(5);
    // [0, 1, 2, 3, 4]
    System.out.println(permutation);
    permutation = permutation.progress(1);
    // [0, 2, 1, 3, 4]
    System.out.println(permutation);
    permutation = permutation.progress(1);
    // [0, 3, 1, 2, 4]
    System.out.println(permutation);

More Examples

The source code for the ZoftWhere Combinatoric Examples, and more, are available for download here.

License

Copyright (C) 2020 ZoftWhere

Licensed under the MIT License


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.