<commit_before>/**
 * @doc Vector NIF module - provides a C++ implementation of the `vector` Erlang module
 *
 * @copyright 2012-2013 <NAME> and <NAME>
 * Licensed under the MIT license; see the LICENSE file for details.
 */

/* Erlang module exports:
 *
 *		+ => implemented
 *		! => still need to implement
 *		- => don't bother implementing
 *		? => not sure yet
 *
 *   .-- Main C++ function
 *  / .- Erlang wrapper function
 * / /
 * % % vec_to_list/1
 * % % list_to_vec/1
 * ! ! dot/2
 * ! ! cross/2
 * ! ! multiply/2
 * ! ! divide/2
 * ! ! squared_norm/1
 * ! ! norm/1
 * ! ! length/1
 * ! ! unit/1
 * ! ! hpr_to/1
 * ! ! add/2
 * ! ! add/3
 * ! ! subtract/2
 * ! ! is_zero/1
 */

#ifndef __VECTOR_NIF__
#define __VECTOR_NIF__

#include "Vec.h"


// --------------------------------------------------------------------------------------------------------------------
// NIFs

// dot/2
static ERL_NIF_TERM dot(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// cross/2
static ERL_NIF_TERM cross(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// multiply/2
static ERL_NIF_TERM multiply(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// divide/2
static ERL_NIF_TERM divide(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// squared_norm/1
static ERL_NIF_TERM squared_norm(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// norm/1
static ERL_NIF_TERM norm(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// length/1
static ERL_NIF_TERM length(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// unit/1
static ERL_NIF_TERM unit(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// hpr_to/1
static ERL_NIF_TERM hpr_to(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// add/2
static ERL_NIF_TERM add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// add/3
static ERL_NIF_TERM add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// subtract/2
static ERL_NIF_TERM subtract(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// is_zero/1
static ERL_NIF_TERM is_zero(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);


// --------------------------------------------------------------------------------------------------------------------
// Helpers

// Conversion
static bool termToVec(ErlNifEnv* env, const ERL_NIF_TERM term, Vec& targetVec);

static ERL_NIF_TERM vecToTerm(ErlNifEnv* env, Vec vec);


// Operations with Erlang terms
static Vec multiply(const Vec& vec, ErlNifEnv* env, const ERL_NIF_TERM other);


// --------------------------------------------------------------------------------------------------------------------
// Declare Erlang exports

static ErlNifFunc nif_funcs[] =
{
	{"dot", 2, dot},
	{"cross", 2, cross},
	{"multiply", 2, multiply},
	{"divide", 2, divide},
	{"squared_norm", 1, squared_norm},
	{"norm", 1, norm},
	{"length", 1, length},
	{"unit", 1, unit},
	{"hpr_to", 1, hpr_to},
	{"add", 2, add},
	{"add", 3, add},
	{"subtract", 2, subtract},
	{"is_zero", 1, is_zero}
};

ERL_NIF_INIT(quaternion, nif_funcs, NULL, NULL, NULL, NULL)


#endif // __VECTOR_NIF__
<commit_msg>Corrected NIF definition in vector_nif.h, and made the vecToTerm helper inline.<commit_after>/**
 * @doc Vector NIF module - provides a C++ implementation of the `vector` Erlang module
 *
 * @copyright 2012-2013 <NAME> and <NAME>
 * Licensed under the MIT license; see the LICENSE file for details.
 */

/* Erlang module exports:
 *
 *		+ => implemented
 *		! => still need to implement
 *		- => don't bother implementing
 *		? => not sure yet
 *
 *   .-- Main C++ function
 *  / .- Erlang wrapper function
 * / /
 * % % vec_to_list/1
 * % % list_to_vec/1
 * ! ! dot/2
 * ! ! cross/2
 * ! ! multiply/2
 * ! ! divide/2
 * ! ! squared_norm/1
 * ! ! norm/1
 * ! ! length/1
 * ! ! unit/1
 * ! ! hpr_to/1
 * ! ! add/2
 * ! ! add/3
 * ! ! subtract/2
 * ! ! is_zero/1
 */

#ifndef __VECTOR_NIF__
#define __VECTOR_NIF__

#include "Vec.h"


// --------------------------------------------------------------------------------------------------------------------
// NIFs

// dot/2
static ERL_NIF_TERM dot(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// cross/2
static ERL_NIF_TERM cross(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// multiply/2
static ERL_NIF_TERM multiply(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// divide/2
static ERL_NIF_TERM divide(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// squared_norm/1
static ERL_NIF_TERM squared_norm(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// norm/1
static ERL_NIF_TERM norm(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// length/1
static ERL_NIF_TERM length(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// unit/1
static ERL_NIF_TERM unit(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// hpr_to/1
static ERL_NIF_TERM hpr_to(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// add/2
static ERL_NIF_TERM add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// add/3
static ERL_NIF_TERM add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// subtract/2
static ERL_NIF_TERM subtract(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);

// is_zero/1
static ERL_NIF_TERM is_zero(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);


// --------------------------------------------------------------------------------------------------------------------
// Helpers

// Conversion
static bool termToVec(ErlNifEnv* env, const ERL_NIF_TERM term, Vec& targetVec);

static inline ERL_NIF_TERM vecToTerm(ErlNifEnv* env, const Vec& vec);


// Operations with Erlang terms
static Vec multiply(const Vec& vec, ErlNifEnv* env, const ERL_NIF_TERM other);


// --------------------------------------------------------------------------------------------------------------------
// Declare Erlang exports

static ErlNifFunc nif_funcs[] =
{
	{"dot", 2, dot},
	{"cross", 2, cross},
	{"multiply", 2, multiply},
	{"divide", 2, divide},
	{"squared_norm", 1, squared_norm},
	{"norm", 1, norm},
	{"length", 1, length},
	{"unit", 1, unit},
	{"hpr_to", 1, hpr_to},
	{"add", 2, add},
	{"add", 3, add},
	{"subtract", 2, subtract},
	{"is_zero", 1, is_zero}
};

ERL_NIF_INIT(vector, nif_funcs, NULL, NULL, NULL, NULL)


#endif // __VECTOR_NIF__

{'fraction_non_alphanumeric': 0.24416, 'fraction_numerical': 0.01568, 'mean_word_length': 2.421455938697318, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4405742', 'n_tokens_mistral': 2415, 'n_tokens_neox': 2335, 'n_words': 584}