Coder Social home page Coder Social logo

schristofo / tubeproject Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 1.73 MB

Simple cli tool for casual modeling and building numerical computation formulas

Home Page: https://github.com/schristofo/tubeProject

License: Apache License 2.0

Makefile 1.65% C 98.35%
cli cli-app numerical tube tubeproject parser calculation permutation

tubeproject's Introduction

The tube project

tube is a command line project for easy and fast casual model building. Models consist of a sequence of built-in functions executing calculations/permutations onto a user-defined input. Each function takes as input the output of the previous function and outputs the result to the next one.

blender tubes

Format

The format of the formulas/models is:
- <input-function> - <function> - ... - <function> -
where:

  • <input-function> is a function reading and converting the <input-file> into the appropriate form.
  • <function> can be a function executing a calculation/permutation.

Notice that every calculation is separated with dashes from the next and previous one, as well as, the whole model starts with a dash and ends with a dash. You can find analytical documentation for each function in Functions section.

Usage

You should set model, input and output path files before executing your model by typing:

./tube model [your-model-path]
./tube input [your-input-file-path]
./tube output [your-output-file-path]

and then:

./tube run

for execution.

You can also type:

./tube demo

to run a demonstration model.

Model Examples

Some typical model examples are shown below:

  • model: -num-add3-pow2-, with input: 2, gives output: (2+3)^2=25.

  • model: -array5-sort-idx1-, with input: 2 5 8 1 4, gives output: 2.

  • model: -array10-max-add5-, with input: 1 2 3 4 5 6 7 8 9 10, gives output: 10+5=15.

Here is an example of finding a week's average temperature in Celsius and converting it to Fahrenheit:

model screenshot

Functions

input-functions:

  • num: specifies that the input is a number
  • array<num>: specifies that the input is an array with positions

functions:

  • add<num>: adds <num> to the input. (input: num/array, output: num/array)
  • sub<num>: subtracts <num> from the input. (input: num/array, output: num/array)
  • mult<num>: multiplies the input with the <num>. (input: num/array, output: num/array)
  • pow<num>: input to the power of <num>. (input: num/array, output: num/array)
  • med: outputs the median value of an input array. (input: array, output: num)
  • mean: outputs the mean value of an input array. (input: array, output: num)
  • max: outputs the maximum value of an input array. (input: array, output: num)
  • min: outputs the minimum value of an input array. (input: array, output: num)
  • bp: breakpoint. prints the value and and passes it to the next function. (input: anything, output: inp)
  • extract: creates an ./output.txt file and extracts the input. (input: anything, output: inp)
  • sort: sorts a given array. (input: array, output: num)
  • idx<num>: outputs the <num>th element of a given array. (input: array, output: num)

Compile

Download and use the gcc compiler to compile the project. Depending on your operating system, type the following to compile:

Linux:

make

to compile, and:

make clean

to clean.

Windows:

gcc -o bin/main.o -c src/main.c
gcc -o bin/lex.o -c src/lex.c
gcc -o bin/tube.o -c src/tube.c
gcc -o bin/model_builder.o -c src/model_builder.c
gcc -o bin/utils.o -c src/utils.c -lm
gcc -o ./tube bin/main.o bin/tube.o bin/lex.o bin/utils.o bin/model_builder.o -lm

to compile, and:

del -f ./tube
del -f bin/main.o
del -f bin/lex.o
del -f bin/utils.o
del -f bin/tube.o
del -f bin/model_builder.o

to clean.

Execution

Type: tube <command> [<args>] to execute.

Here is a list of all the available commands:

path modification:

  • model: Define model file path
  • input: Define input file path
  • output: Define output file path
  • clear: Delete all the paths

model execution:

  • demo: Run a demonstration model
  • run: Run the model using user-defined paths

You can use input and model samples from the ./input, ./model sub-directories, or you can create and use your own models.

NOTE: Use tube instead of ./tube on Windows.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Apache License 2.0

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.