Coder Social home page Coder Social logo

dl4jdslstudien's Introduction

PrePro

Student project at the DHBW Karlsruhe

The Language is designed to simply calculations with time series. To do so, each variable (except of constants) is a time-series. For example a variable with the type vec3 is a time-series of Vectors with the length 3. A PrePro-programm is written in a specific Domain Specific Language in textual form and is run by an Interpreter. The Interpreter takes and returns an PreProDataSet, which stores a set of variables (time-series).

Contents of this repository

Folder Contents
PrePro The source code of the interpreter.
PrePro-Netbeans-Plugin A plugin for the Netbeans IDE supporting syntax highliting and syntax error detection.
Elaboration The document written for the university. It is written in german.

The "Hello world" PrePro program

Simplified PrePro syntax

import vec3 p1, p2;

vec3 result = p1 + p2;

export result;

It uses the variables p1 and p2 from the given PreProDataSet and calculates a resulting Vector3. Remind: All the variables are time-series, there is no need for a loop. The Interpreter will return a PreProDataSet containing the result.

Buildin functions and operators

User defined Functions

function main() {
	import vec3 p1, vec3 p2, vec3 p3;

	vec3 x = calculateDifference(p1, p2);
	vec3 s = calculateDifference(p1, p3);
	vec3 y = s X x;
	vec3 z = y X x;

	export x, y, z;
}

function calculateDifference(vec3 p1, vec3 p2) returns vec3 {
	return p2 - p1;
}

The operation โ€œXโ€ is a cross product. Note, that PrePro currently doesn't support overloading of functions.

Constants

Constants can be defined and set into the SymbolTable:

PreProProgram program = new PreProProgram("foo.prepro");
SymbolTable symbolTable = new SymbolTable();
symbolTable.setValue("pi", new Constant(Math.PI);
PreProDataSet result = program.execute(dataSet, symbolTable);
double pi = result.getVariable()("pi").getDouble(0,0);

Limitations: Only double constants available?

Run the PrePro-program

To run the PrePro code you must provide a PreProDataSet. The following JAVA code creates a PreProDataSet and calls the PrePro-code.

INDArray p1 = Nd4j.create(new double[]{42, 0, 0, 1, 0, 0, 5, 0, 0, 6, 0, 0, 1, 2, 3}, new int[]{4, 3});
INDArray p2 = Nd4j.create(new double[]{43, 0, 0, 44662, 0, 0, 6, 0, 0, 7, 0, 0}, new int[]{4, 3});
INDArray p3 = Nd4j.create(new double[]{42, 0, 1, 1, 0, 1, 5, 0, 1, 6, 0, 1}, new int[]{4, 3});

PreProDataSet preProDataSet = new DefaultPreProDataSet(
        Arrays.asList(p1, p2, p3),
        Arrays.asList("p1", "p2", "p3")
);

PreProProgram program = new PreProProgram("src/test/tests/arithmetic/testCrossProduct.prepro");
PreProDataSet result = program.execute(preProDataSet);

System.out.println("Calculated x:\n" + result.getVariable("x"));
System.out.println("Calculated y:\n" + result.getVariable("y"));
System.out.println("Calculated z:\n" + result.getVariable("z"));

dl4jdslstudien's People

Contributors

orat avatar sbernauer avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

orat lahuunused

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.