<commit_before>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#pragma once

#ifndef VSNRAY_SPD_D65_H
#define VSNRAY_SPD_D65_H

namespace visionaray
{

//-------------------------------------------------------------------------------------------------
// Spectral power distribution of D65 illuminant (daylight 6500 K)
// Data derived from here: http://www.rit-mcsl.org/UsefulData/DaylightSeries.xls
// Normalized such that P(560) = 1
//

class spd_d65
{
public:

    float operator()(float lambda) const
    {
        if (lambda < 300 || lambda >= 830)
        {
            return 0;
        }

        auto i = (int)floorf(lambda) / 10;
        auto s = (lambda - i * 10.0f) / 10.0f;

        i -= 30;

        return (1.0f - s) * table_[i] + s * table_[i + 1];
    }

private:

    float table_[54] = {
            0.0003, // 300
            0.0336, // 310
            0.2042, // 320
            0.3742, // 330
            0.4029, // 340
            0.4524, // 350
            0.4692, // 360
            0.5241, // 370
            0.5088, // 380
            0.5483, // 390
            0.8293, // 400
            0.9169, // 410<commit_msg>Use lerp() function<commit_after>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#pragma once

#ifndef VSNRAY_SPD_D65_H
#define VSNRAY_SPD_D65_H

namespace visionaray
{

//-------------------------------------------------------------------------------------------------
// Spectral power distribution of D65 illuminant (daylight 6500 K)
// Data derived from here: http://www.rit-mcsl.org/UsefulData/DaylightSeries.xls
// Normalized such that P(560) = 1
//

class spd_d65
{
public:

    float operator()(float lambda) const
    {
        if (lambda < 300 || lambda >= 830)
        {
            return 0;
        }

        auto i = (int)floorf(lambda) / 10;
        auto s = (lambda - i * 10.0f) / 10.0f;

        i -= 30;

        return lerp( table_[i], table_[i + 1], s );
    }

private:

    float table_[54] = {
            0.0003, // 300
            0.0336, // 310
            0.2042, // 320
            0.3742, // 330
            0.4029, // 340
            0.4524, // 350
            0.4692, // 360
            0.5241, // 370
            0.5088, // 380
            0.5483, // 390
            0.8293, // 400
            0.9169, // 410
{'fraction_non_alphanumeric': 0.20084566596194503, 'fraction_numerical': 0.11247357293868922, 'mean_word_length': 1.1686526122823098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2997123', 'n_tokens_mistral': 936, 'n_tokens_neox': 745, 'n_words': 204}