<commit_before>// math - general purpose functions, equations, RNG, etc.
// Part of Stardazed TX
// (c) 2016 by <NAME> - @zenmumbler
// https://github.com/stardazed/stardazed-tx

/// <reference path="../../typings/veclib.d.ts" />
/// <reference path="../core/array.ts" />

namespace sd {
	export const vec2 = veclib.vec2;
	export const vec3 = veclib.vec3;
	export const vec4 = veclib.vec4;
	export const quat = veclib.quat;
	export const mat2 = veclib.mat2;
	export const mat3 = veclib.mat3;
	export const mat4 = veclib.mat4;
} // ns sd


namespace sd.math {

	// common functions
	export function intRandom(maximum: number): number {
		return (Math.random() * (maximum + 1)) | 0;
	}


	export function intRandomRange(minimum: number, maximum: number): number {
		const diff = (maximum - minimum) | 0;
		return minimum + intRandom(diff);
	}


	export function hertz(hz: number) {
		return 1 / hz;
	}


	export function deg2rad(deg: number): number {
		return deg * Math.PI / 180.0;
	}


	export function rad2deg(rad: number): number {
		return rad * 180.0 / Math.PI;
	}


	export function clamp(n: number, min: number, max: number): number {
		return Math.max(min, Math.min(max, n));
	}


	export function clamp01(n: number): number {
		return Math.max(0.0, Math.min(1.0, n));
	}


	export function isPowerOf2(n: number) {
		return (n & (n - 1)) == 0;
	}


	// roundUpPowerOf2
	// return closest powerOf2 number that is >= n
	// e.g.: 15 -> 16; 16 -> 16; 17 -> 32

	export function roundUpPowerOf2(n: number) {
		if (n <= 0) { return 1; }
		n = (n | 0) - 1;
		n |= n >> 1;
		n |= n >> 2;
		n |= n >> 4;
		n |= n >> 8;
		n |= n >> 16;<commit_msg>refactor(math): re-export util funcs from veclib<commit_after>// math - general purpose functions, equations, RNG, etc.
// Part of Stardazed TX
// (c) 2016 by <NAME> - @zenmumbler
// https://github.com/stardazed/stardazed-tx

/// <reference path="../../typings/veclib.d.ts" />
/// <reference path="../core/array.ts" />

namespace sd {
	export const vec2 = veclib.vec2;
	export const vec3 = veclib.vec3;
	export const vec4 = veclib.vec4;
	export const quat = veclib.quat;
	export const mat2 = veclib.mat2;
	export const mat3 = veclib.mat3;
	export const mat4 = veclib.mat4;
} // ns sd


namespace sd.math {

	// re-export some functions defined in veclib
	export const clamp = veclib.clamp;
	export const clamp01 = veclib.clamp01;
	export const mix = veclib.mix;


	// common functions
	export function intRandom(maximum: number): number {
		return (Math.random() * (maximum + 1)) | 0;
	}

	export function intRandomRange(minimum: number, maximum: number): number {
		const diff = (maximum - minimum) | 0;
		return minimum + intRandom(diff);
	}

	export function hertz(hz: number) {
		return 1 / hz;
	}

	export function deg2rad(deg: number): number {
		return deg * Math.PI / 180.0;
	}

	export function rad2deg(rad: number): number {
		return rad * 180.0 / Math.PI;
	}

	export function isPowerOf2(n: number) {
		return (n & (n - 1)) == 0;
	}


	// roundUpPowerOf2
	// return closest powerOf2 number that is >= n
	// e.g.: 15 -> 16; 16 -> 16; 17 -> 32

	export function roundUpPowerOf2(n: number) {
		if (n <= 0) { return 1; }
		n = (n | 0) - 1;
		n |= n >> 1;
		n |= n >> 2;
		n |= n >> 4;
		n |= n >> 8;
		n |= n >> 16;
{'fraction_non_alphanumeric': 0.1561065197428834, 'fraction_numerical': 0.03856749311294766, 'mean_word_length': 2.9468599033816427, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '6491707', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1195, 'n_words': 364}