view src/LogCompress.h @ 30:00df792783e3

Faster filter implementation (less copying)
author Chris Cannam
date Wed, 30 Sep 2015 13:45:08 +0100
parents 353e88e4ebea
children 00b6ae41efbe
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */

#ifndef LOGCOMPRESS_H
#define LOGCOMPRESS_H

#include <vector>
#include <cmath>

class LogCompress
{
public:
    static std::vector<double> process(std::vector<double> in,
				       double factor,
				       double addTerm) {
	std::vector<double> out;
	out.reserve(in.size());
	for (auto x: in) {
	    out.push_back(log10(addTerm + factor * x));
	}
	return std::move(out);
    }
};

#endif