Click here to Skip to main content
15,885,906 members
Articles / Programming Languages / C++

Fast Automatic Differentiation in C++

Rate me:
Please Sign up or sign in to vote.
4.67/5 (12 votes)
1 Sep 2006CPOL12 min read 76.2K   2.9K   27  
An article on fast automatic differentiation (FAD), another way of computing the derivatives of a function.
//////////////////////////////////////////////////////////////////////////
/// The Reed Library
/// Copyright (c) 2006 Yevgeniy Shatokhin

/// File: util.h
/// Contains some utility stuff.
/// 

/// 
/// Last update: August 29, 2006

#ifndef __UTIL_H__EC89223A_854F_4995_AFE7_974D7057922B_INCLUDED_
#define __UTIL_H__EC89223A_854F_4995_AFE7_974D7057922B_INCLUDED_

#include <cmath>

namespace reed
{
	/// Return the accuracy the argument is stored with. \n
	/// It equals the absolute difference between 'arg' and the representable 
	/// value closest to it but different. (In fact, they differ only in the lower 
	/// bit of their mantissas.)\n
	/// It's assumed that arg is an IEEE-compliant normalized double precision number.
	double derr(double arg);

	/// Compare x and y to see if these numbers are 'approximately' equal (have small
	/// absolute difference.\n
	/// x is assumed to be 'approximately' equal to y if
	/// |x - y| < 2.0 * derr(max(|x|, |y|)). (I chose the 2.0 coefficient quite 
	/// arbitrarily. Perhaps it makes some sense.)
	int dequal(double x, double y);

}	// namespace reed


#endif //__UTIL_H__EC89223A_854F_4995_AFE7_974D7057922B_INCLUDED_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions