#ifndef __LINEAR_LOGARITHMIC_INTERPOLATION_TEMPLATE_CLASS__ #define __LINEAR_LOGARITHMIC_INTERPOLATION_TEMPLATE_CLASS__ /** @file LinLogInterp.hpp @author Brian Magill @datecreated 8/17/2006 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief Function Template for linear logarithmic interpolation Here the independent variable is approximately linear and the logarithm of the dependent variable is approximately linear. */ //---------------------------------------------------------------------- // #include "VectorLinInterp.hpp" #include #include #include #include template T LinLogInterp(T const x, T const xa, T const xb, T const ya, T const yb) { VectorLinInterp A; assert( ya > 0. && yb > 0.); T za = log(ya); T zb = log(yb); T z_out = A.linear_interpolate(x, xa, xb, za, zb); T result = exp(z_out); return result; }; template class Log { public: Log() {} ; ~Log() {}; T operator () (T x) { return log(x); } }; template T LinLogInterp(std::vector const &yin, std::vector const &xin, T const &xout) { assert( yin.size() > 0. && xin.size() > 0.); VectorLinInterp A; std::vector z_in(yin.size() ); transform(yin.begin(),yin.end(), z_in.begin(), Log() ); T z_out = A.Interpol(z_in, xin, xout); T result = exp(z_out); return result; }; #endif