/usr/include/TiledArray/expressions/scal_expr.h is in libtiledarray-dev 0.4.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /*
* This file is a part of TiledArray.
* Copyright (C) 2014 Virginia Tech
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Justus Calvin
* Department of Chemistry, Virginia Tech
*
* scal_expr.h
* Mar 16, 2014
*
*/
#ifndef TILEDARRAY_EXPRESSIONS_SCAL_EXPR_H__INCLUDED
#define TILEDARRAY_EXPRESSIONS_SCAL_EXPR_H__INCLUDED
#include <TiledArray/expressions/unary_expr.h>
#include <TiledArray/expressions/scal_engine.h>
namespace TiledArray {
namespace expressions {
template <typename Arg>
struct ExprTrait<ScalExpr<Arg> > :
public UnaryExprTrait<Arg, ScalEngine>
{ };
/// Scaling expression
/// \tparam Arg The argument expression type
template <typename Arg>
class ScalExpr : public UnaryExpr<ScalExpr<Arg> > {
public:
typedef ScalExpr<Arg> ScalExpr_; ///< This class type
typedef UnaryExpr<ScalExpr_> UnaryExpr_; ///< Unary base class type
typedef typename ExprTrait<ScalExpr_>::argument_type argument_type; ///< The argument expression type
typedef typename ExprTrait<ScalExpr_>::engine_type engine_type; ///< Expression engine type
typedef typename ExprTrait<ScalExpr_>::scalar_type scalar_type; ///< Scalar type
private:
scalar_type factor_; ///< The scaling factor
// Not allowed
ScalExpr_& operator=(const ScalExpr_&);
public:
/// Scaled expression constructor
/// \param arg The argument expression
/// \param factor The scalar type
ScalExpr(const argument_type& arg, const scalar_type factor) :
UnaryExpr_(arg), factor_(factor)
{ }
/// Rescale expression constructor
/// \param other The expression to be copied
/// \param factor The scaling factor applied to the new expression
ScalExpr(const ScalExpr_& other, const scalar_type factor) :
UnaryExpr_(other), factor_(other.factor_ * factor)
{ }
/// Copy constructor
/// \param other The expression to be copied
ScalExpr(const ScalExpr_& other) : UnaryExpr_(other), factor_(other.factor_) { }
/// Scaling factor accessor
/// \return The scaling factor
scalar_type factor() const { return factor_; }
}; // class ScalExpr
/// Scaled expression factor
/// \tparam D The expression type
/// \tparam Scalar A scalar type
/// \param expr The expression object
/// \param factor The scaling factor
/// \return A scaled expression object
template <typename D, typename Scalar>
inline typename std::enable_if<TiledArray::detail::is_numeric<Scalar>::value,
ScalExpr<D> >::type
operator*(const Expr<D>& expr, const Scalar& factor) {
return ScalExpr<D>(expr.derived(), factor);
}
/// Scaled expression factor
/// \tparam D The expression type
/// \tparam Scalar A scalar type
/// \param factor The scaling factor
/// \param expr The expression object
/// \return A scaled expression object
template <typename D, typename Scalar>
inline typename std::enable_if<TiledArray::detail::is_numeric<Scalar>::value,
ScalExpr<D> >::type
operator*(const Scalar& factor, const Expr<D>& expr) {
return ScalExpr<D>(expr.derived(), factor);
}
/// Scaled expression factor
/// \tparam Arg The argument expression type
/// \tparam Scalar A scalar type
/// \param expr The scaled expression object
/// \param factor The scaling factor
/// \return A scaled expression object
template <typename Arg, typename Scalar>
inline typename std::enable_if<TiledArray::detail::is_numeric<Scalar>::value,
ScalExpr<Arg> >::type
operator*(const ScalExpr<Arg>& expr, const Scalar& factor) {
return ScalExpr<Arg>(expr, factor);
}
/// Scaled expression factor
/// \tparam Arg The argument expression type
/// \tparam Scalar A scalar type
/// \param factor The scaling factor
/// \param expr The scaled expression object
/// \return A scaled expression object
template <typename Arg, typename Scalar>
inline typename std::enable_if<TiledArray::detail::is_numeric<Scalar>::value,
ScalExpr<Arg> >::type
operator*(const Scalar& factor, const ScalExpr<Arg>& expr) {
return ScalExpr<Arg>(expr, factor);
}
/// Negated expression factor
/// \tparam D The expression type
/// \param expr The expression object
/// \return A scaled expression object
template <typename D>
inline ScalExpr<D> operator-(const Expr<D>& expr) {
return ScalExpr<D>(expr.derived(), -1);
}
/// Negated expression factor
/// \tparam Arg The argument expression type
/// \param expr The scaled expression object
/// \return A scaled expression object
template <typename Arg>
inline ScalExpr<Arg> operator-(const ScalExpr<Arg>& expr) {
return ScalExpr<Arg>(expr, -1);
}
} // namespace expressions
} // namespace TiledArray
#endif // TILEDARRAY_EXPRESSIONS_SCAL_EXPR_H__INCLUDED
|