Giter Club home page Giter Club logo

partdiffpp's Introduction

Hi, I'm Ruben and I'm currently doing my PhD in Astrophysics.

Skills

  • C++, C, Python, LaTeX, Bash, AWK, Perl, MatLab, Java, Object Pascal, HTML, CSS, JS
  • High Performance Computing, Embedded Systems
  • Linux (Arch Linux, Ubuntu, Debian)
  • Git, Mercurial
  • Qt, GDB, Valgrind, Buildroot, Busybox
  • OpenMP, MPI, OpenACC

A list of cool stuff I made:

A list of interesting stuff I made:

A list of interesting stuff I made:

Links

partdiffpp's People

Contributors

felsenhower avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

partdiffpp's Issues

Investigate usage of Matrix class that supports m[x,y]

At the moment, allocateMatrices allocates one big memory block double *M with dimensions num_matrices * (N + 1)² and inits double ***Matrix such that the elements of Matrix point to the elements of M, i.e. Matrix[0][0][0] == M[0], Matrix[0][0][1] == M[1] and so on.

This is good, because it guarantees that adjacent elements inside Matrix are adjacent in M and therefore adjacent in memory. This is cache-friendly, because the calculation of star inside calculate uses four close elements.

However, the pointer dereferencing brings a little overhead and one could replace it with doing the pointer arithmetic directly.

This could be done with a class Matrix that accepts two indices like

Matrix[x,y] = value; // or....
Matrix(x,y) = value;

and a vector<Matrix> or a class Tensor that directly accepts three (or better an arbitrary number) of indices.

It is not possible at the current time to directly overload the operator[] to accept two indices: https://stackoverflow.com/questions/1936399/c-array-operator-with-multiple-arguments

There are ways to still do this nonetheless (https://stackoverflow.com/questions/5602112/when-to-overload-the-comma-operator/18136340#18136340), but they involve maps of pairs which probably have a worse performance than arrays.

Include comments again

The original partdiff had rich comments and headers, I'd like to reintroduce them at some point in an amended way.

Use format library

Currently, all IO is done via streams and all temporary streams are used via the build_string method:

std::string build_string(const std::function<void(std::stringstream &)> input) {
  std::stringstream ss;
  input(ss);
  return ss.str();
}
std::cout << [...]
              << partdiff::build_string([time](auto &ss) { ss << std::fixed << std::setprecision(6) << time; }) << " s"
              << std::endl

While this is a very C++ way of exploiting streams, it's also verbose compared to how printing works in e.g. Python.

C++20 adds a format library that adds Python-style printing which sadly isn't yet implemented in g++ 10.2.0.

However, there is the fmt library that implements it.

We could use that and switch to std::format once that's available.

Investigate usage of float

partdiff uses double everywhere.

Investigate the accuracy / performance tradeof of just using float.

If float can be used everywhere, maybe define a type "real" that maps to double or float.

Make types CamelCase instead of snake_case

This is not a stylistic choice, but a practical one:

In C, you declare variables of a struct like this:

struct foo { ... }
struct foo bar;

In C++, the word struct can be omitted in the variable declaration:

struct foo { ... }
foo bar;

If the type and variable name are the same (like frequently in partdiff, e.g. options), this can lead to ambiguities.

The only solution to have to problems at all are to keep the two seperate, e.g. like this:

struct calculation_arguments_t { ... }
calculation_arguments_t calculation_arguments;

Or like this:

struct CalculationArguments { ... }
CalculationArguments calculation_arguments

Optional translation to English

The original partdiff is partly in German and partly in English.

More precisely, everything is in English except for the functions displayStatistics and allocateMemory.

It would be nice to have everything in the application in English, but that would break make test, since that compares the output of the two applications on a char-by-char level.

A solution could be adding a compiler flag, e.g. -Dlegacy or so, that retains all of the original behaviour and translating everything to English if the option has not been passed.

This would also enable us to modernise a few other things here and there.

Introduce enum classes

The following defines should be converted to enum class for better type safety:

#define METH_GAUSS_SEIDEL 1
#define METH_JACOBI 2
#define FUNC_F0 1
#define FUNC_FPISIN 2
#define TERM_PREC 1
#define TERM_ITER 2

Annihilate malloc / delete

Remove instances of malloc and free and replace them by

  • new / delete
  • copies of classes
  • smart pointers

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.