📄 inverse.hpp
字号:
// Copyright 2006. Peter Gottschling, Matthias Troyer, Rolf Bonderer// Software License for MTL// // Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.// Authors: Peter Gottschling and Andrew Lumsdaine// // This file is part of the Matrix Template Library// // See also license.mtl.txt in the distribution.#ifndef MATH_INVERSE_INCLUDE#define MATH_INVERSE_INCLUDE#include <boost/numeric/linear_algebra/operators.hpp>#include <boost/numeric/linear_algebra/identity.hpp>namespace math {template <typename Operation, typename Element>struct inverse_t {} ;template <typename Element>struct inverse_t< add<Element>, Element > : public std::binary_function<add<Element>, Element, Element>{ Element operator()(const add<Element>&, const Element& v) const { return zero(v) - v; } };template <typename Element>struct inverse_t< mult<Element>, Element > : public std::binary_function<mult<Element>, Element, Element>{ Element operator()(const mult<Element>&, const Element& v) const { return one(v) / v ; } };// Function is shorter than typetrait-like functortemplate <typename Operation, typename Element>inline Element inverse(const Operation& op, const Element& v){ return inverse_t<Operation, Element>() (op, v);}// Short-cut for multiplicative inversetemplate <typename Element>inline Element reciprocal(const Element& v){ return inverse(math::mult<Element>(), v);}} // namespace math#endif // MATH_INVERSE_INCLUDE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -