Coder Social home page Coder Social logo

circuitapi's Introduction

Circuit API

CircuitAPI is a tool that can be used for making AND, OR, NOT, GTE gates

System requirements

  • Java 16+

How to run

in order to use this API, add CircuitAPI.jar to your directory, you can create new Gates and logics by using CircuitFactory. It can be used as bellow for creating (X1 And X2) logic:

CircuitFactory factory = new CircuitFactory();
Circuit x1 = factory.createConstant();
Circuit x2 = factory.createConstant();
Circuit and = factory.createAnd(x1, x2);
x1.setValue(Boolean.valueOf(true));
x2.setValue(Boolean.valueOf(true));

What is each Gates functions:

And/Or/Not : these gates are the same logical operators that operate like below:

    X1 and X2 = X1 && X2 
    X1 or X2 = X1 || X2
    NOT X1 = ~X1

GTE Gate Operates like following:

X1 gte X2 = this gate works just for PairInput(Boolean, Double)
    if (the double part of x1 >= x2)  => the result is (true, true)
    otherwise the result is (true, false)

How to create gates and inputs:

Gates is created like above example:

OR  =>  factory.createOr(x1, x2);
AND =>  factory.createAnd(x1, x2);
NOT => factory.createNot(x1);
GTE =>  factory.createGte(x1, x2);

the Inputs is also created as following:

Circuit x2 = factory.createConstant();

Supported Data Types

Boolean Data Type are supported by gates.

CircuitAPI also supports two types of PairInput data Type that are as below:

1. (true, Boolean) -- true mean that the second value in pair is Boolean Type
2. (false, Double) -- false mean that the second value in pair is Double Type

In the case of Double PairInput format, the rules of And/Or/Not are as following:

not((false, d)) = (false, 1-d)
and((false, d1), false, d2)) = (false, d1*d2)
or((false, d1), (false, d2)) =(false, 1-(1-d1)*(1-d2))

Contributors

  • Shyam Akhter

  • Renisa Suryahadikusumah

  • Moslem Teymoori

  • Shabnam Zarepoor

circuitapi's People

Contributors

renisaskusumah avatar sepnazare avatar moslemty1990 avatar sakhter2021 avatar

Watchers

 avatar  avatar  avatar

Forkers

sepnazare

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.