<commit_before>package chromath

import (
	"math"
	"sync"
)

type scaler8bClamping struct{}

// Scaler8bClamping is a simple mapping of values [0,255] to [0,1], clamping all out of bounds values
var Scaler8bClamping scaler8bClamping

func (*scaler8bClamping) Init(ws *RGBSpace) Scaler { return &Scaler8bClamping }

func (*scaler8bClamping) Scale(p Point) Point {
	p[0] *= (1/255.0)
	p[1] *= (1/255.0)
	p[2] *= (1/255.0)
	return p
}

func (*scaler8bClamping) ScaleInv(p Point) Point {
	if p[0] < 0.0 {
		p[0] = 0.0
	} else if p[0] > 1.0 {
		p[0] = 1.0
	}
	if p[1] < 0.0 {
		p[1] = 0.0
	} else if p[1] > 1.0 {
		p[1] = 1.0
	}
	if p[2] < 0.0 {
		p[2] = 0.0
	} else if p[2] > 1.0 {
		p[2] = 1.0
	}

	p[0] = math.Floor(0.5 + p[0]*255)
	p[1] = math.Floor(0.5 + p[1]*255)
	p[2] = math.Floor(0.5 + p[2]*255)
	return p
}

type scaler16bClamping struct{}

// Scaler16bClamping is a simple mapping of values [0,2^16-1] to [0,1], clamping all out of bounds values. Typically used for 16-bit RGB
var Scaler16bClamping scaler16bClamping

func (*scaler16bClamping) Init(ws *RGBSpace) Scaler { return &Scaler16bClamping }

func (*scaler16bClamping) Scale(p Point) Point {
	p[0] *= (1/65535.0)
	p[1] *= (1/65535.0)
	p[2] *= (1/65535.0)
	return p
}

func (*scaler16bClamping) ScaleInv(p Point) Point {
	if p[0] < 0.0 {
		p[0] = 0.0
	} else if p[0] > 1.0 {
		p[0] = 1.0
	}
	if p[1] < 0.0 {
		p[1] = 0.0
	} else if p[1] > 1.0 {
		p[1] = 1.0
	}
	if p[2] < 0.0 {
		p[2] = 0.0
	} else if p[2] > 1.0 {
		p[2] = 1.0
	}

	p[0] = math.Floor(0.5 + p[0]*65535)
	p[1] = math.Floor(0.5 + p[1]*65535)
	p[2] = math.Floor(0.5 + p[2]*65535)
	return p
}

type gammaCompander struct {<commit_msg>Inliner is fine with this<commit_after>package chromath

import (
	"math"
	"sync"
)

func clip(v float64) float64 {
	if v < 0.0 {
		v = 0.0
	} else if v > 1.0 {
		v = 1.0
	}
	return v
}

type scaler8bClamping struct{}

// Scaler8bClamping is a simple mapping of values [0,255] to [0,1], clamping all out of bounds values
var Scaler8bClamping scaler8bClamping

func (*scaler8bClamping) Init(ws *RGBSpace) Scaler { return &Scaler8bClamping }

func (*scaler8bClamping) Scale(p Point) Point {
	p[0] *= (1/255.0)
	p[1] *= (1/255.0)
	p[2] *= (1/255.0)
	return p
}

func (*scaler8bClamping) ScaleInv(p Point) Point {
	p[0] = math.Floor(0.5 + clip(p[0])*255)
	p[1] = math.Floor(0.5 + clip(p[1])*255)
	p[2] = math.Floor(0.5 + clip(p[2])*255)
	return p
}

type scaler16bClamping struct{}

// Scaler16bClamping is a simple mapping of values [0,2^16-1] to [0,1], clamping all out of bounds values. Typically used for 16-bit RGB
var Scaler16bClamping scaler16bClamping

func (*scaler16bClamping) Init(ws *RGBSpace) Scaler { return &Scaler16bClamping }

func (*scaler16bClamping) Scale(p Point) Point {
	p[0] *= (1/65535.0)
	p[1] *= (1/65535.0)
	p[2] *= (1/65535.0)
	return p
}

func (*scaler16bClamping) ScaleInv(p Point) Point {
	p[0] = math.Floor(0.5 + clip(p[0])*65535)
	p[1] = math.Floor(0.5 + clip(p[1])*65535)
	p[2] = math.Floor(0.5 + clip(p[2])*65535)
	return p
}

type gammaCompander struct {
{'fraction_non_alphanumeric': 0.17728168089297439, 'fraction_numerical': 0.11227839789888379, 'mean_word_length': 3.514074074074074, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '25084', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1458, 'n_words': 345}