Git Product home page Git Product logo

hypervector's Introduction

hypervector

A multi-dimensional vector based on a one-dimensional std::vector.

Intended to be used like static multi-dimensional arrays (T[N][M] or std::array<std::array<T, M>, N>) with the benefit of dynamic resizeability. While the number of dimensions is fixed at compile time, the size of each dimension can be changed at runtime. E.g. a 3D grid data storage can be resized in its width/height/depth according to changed parameters. The number of dimensions is not limited; the hypervector can be templated as 1D array, 2D grid, 3D cuboid, 4D hypercube, etc. Compared to a multi-dimensional std::vector (std::vector<std::vector<...<T>>>) the hypervector will use the one (pre-reserved) memory of its one-dimensional container without multiple (per dimension) allocations.

The interface is designed to resemble std::vector, except that some methods require a number of arguments according to the number of dimensions the hypervector was templated with:

  • constructor()
  • constructor(size_type dim0, size_type dim1, ... , const T& value)
  • constructor(size_type dim0, size_type dim1, ... )
  • void assign(size_type dim0, size_type dim1, ... , const T& value)
  • void resize(size_type dim0, size_type dim1, ... )
  • void resize(size_type dim0, size_type dim1, ... , const T& value)
  • void reserve(size_type dim0, size_type dim1, ... )
  • reference at(size_type dim0, size_type dim1, ... )
  • operator[](size_t) returns views on subdimensions or slices that themselves can be sliced further up to individual storage elements slice

Implemented as C++11 variadic template.

Build test using CMake or $ g++ -o hypervector_test hypervector_test.cpp -std=c++11

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.