<commit_before>// This code is in the public domain -- <EMAIL>

#include <nvmath/SphericalHarmonic.h>

using namespace nv;


namespace
{
	
	// Basic integer factorial.
	inline static int factorial( int v )
	{
		if (v == 0) {
			return 1;
		}
	
		int result = v;
		while (--v > 0) {
			result *= v;
		}
		return result;
	}
	
	
	// Double factorial. 
	// Defined as: n!! = n*(n - 2)*(n - 4)..., n!!(0,-1) = 1.
	inline static int doubleFactorial( int x )
	{
		if (x == 0 || x == -1) {
			return 1;
		}
	
		int result = x;
		while ((x -= 2) > 0) {
			result *= x;
		}
	
		return result;
	}	
	
	/// Normalization constant for spherical harmonic.
	/// @param l is the band.
	/// @param m is the argument, in the range [0, m]
	inline static float K( int l, int m )<commit_msg>factorial optimization suggested by pponywong.<commit_after>// This code is in the public domain -- <EMAIL>

#include <nvmath/SphericalHarmonic.h>

using namespace nv;


namespace
{
	
	// Basic integer factorial.
	inline static int factorial( int v )
	{
		const static int fac_table[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800 };

		if(v <= 11){
			return fac_table[v];
		}
	
		int result = v;
		while (--v > 0) {
			result *= v;
		}
		return result;
	}
	
	
	// Double factorial. 
	// Defined as: n!! = n*(n - 2)*(n - 4)..., n!!(0,-1) = 1.
	inline static int doubleFactorial( int x )
	{
		if (x == 0 || x == -1) {
			return 1;
		}
	
		int result = x;
		while ((x -= 2) > 0) {
			result *= x;
		}
	
		return result;
	}	
	
	/// Normalization constant for spherical harmonic.
	/// @param l is the band.
	/// @param m is the argument, in the range [0, m]
	inline static float K( int l, int m )
{'fraction_non_alphanumeric': 0.15786350148367953, 'fraction_numerical': 0.04154302670623145, 'mean_word_length': 2.29296875, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, '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': '1986513', 'n_tokens_mistral': 760, 'n_tokens_neox': 630, 'n_words': 221}