Giter Club home page Giter Club logo

banng's Introduction

BANNG ๐Ÿ’ฅ

Borna's Approximate Nearest Neighbor Gearbox

Requirements

Building

git clone --recursive https://github.com/bornabesic/banng.git
cd banng
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=Release
make

Example

Python

import banng.float as banng
import numpy as np

n, d = 8, 2

X = np.random.uniform(size=(n, d)).astype(np.float32)
print("Data:")
print(X)
print()

index = banng.AxisAlignedSplit.Index()
index.build(X)

query = np.array([0] * d, dtype=np.float32)
print("Query:", query)
print("Result:", index.search(query))

C++

#include <iostream>
#include <cstdlib>

/* BANNG */
#include <array.hpp>
#include <index.hpp>

int main(void) {
    constexpr unsigned int n = 8;
    constexpr unsigned int d = 2;

    Array2d<float> X = Array2d<float>::allocate(n, d);
    for (unsigned int i = 0; i < n; ++i)
        for (unsigned int j = 0; j < d; ++j)
            X(i, j) = ((float) std::rand()) / RAND_MAX;

    Index<float, AxisAlignedSplit> index;
    index.build(X);

    std::cout << "Data:" << '\n';
    Array2d<float>::print(X);
    std::cout << '\n';

    float query_data[d] = {0};
    constexpr unsigned int query_stride = 1;
    Array1d<float> query{query_data, d, query_stride};
    std::cout << "Query: ";
    Array1d<float>::print(query);

    Array1d<float> result = index.search(query);
    std::cout << "Result: ";
    Array1d<float>::print(result);

    return 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.