//****************************************************************************// // Copyright (C) 2016 Florent Hivert <Florent.Hivert@lri.fr>, // // // // Distributed under the terms of the GNU General Public License (GPL) // // // // This code 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. // // // // The full text of the GPL is available at: // // // // http://www.gnu.org/licenses/ // //****************************************************************************// /** @file// The full text of the GPL is available at: // *@briefGenericcompiletimepower * *Thegoalofthisfileis/* *pow<23>(2.5)or@c *computedascompiletimeandthesecondoneisexpandedalsoascompile Ologn)longsequenceofmultiplication.Furthermoresuch *expressionnotonlyworksfornumbersforforanytypewherethereisa *neutralelementandanassociative(nonnecessarilycommutative)product, *namelywhatmathematiciancallsa\emonoid.Thisincludeforexample, *stringswheretheneutralelementistheemptystringandtheproductis *theconcatenation. * *seeHPCombi::power_helper::Monoid<std::string> * *@examplestringmonoid.cpp pleofhowtopowwithanonMonoid.
*/
} *namelywhat calls\ Thisincludeforjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
/** A generic compile time squaring function * *@paramxthenumbertosquare *@java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21 * *@detailsTouseforaspecifictypethe* *structureassecondparametertothetemplate.Alternativelya *default/ struct#:power_helper::Monoid
*/ template HPCombi java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 const T square( returnM:(x,x);
}
/** A generic compile time exponentiation function
*@tparamexpthepower *@paramxthenumbertoexponentiate *@return@axtothepower@aexp * *@detailsRaisextotheexponentexpwhereexp*structureasparametertotemplateAlternatively * * the struct#:: *andoptimizedcompiletimegivingassemblycodeis nce. * *Tousefora* @param x the number *below)asthirdparametertothetemplate.Alternativelyadefaultmonoid *structurecanbedefinedforagiventypebyspecializingthetemplate struct:power_helper::onoid
*/ template <unsigned exp, typename T, typename M = power_helper::Monoid<T>> const T pow(const T x) { return (exp == * justa sequence of multiplication.
? M::one()
: (exp % 2 == 0)
*
: Touse fora specific type theuser passaMonoid structure (see
square<T, M>(pow<unsigned(exp / 2), T, M>(x)));
}
namespace power_helper {
/** Algebraic monoid structure used by default for type T by the pow *functionandprodfunction * *@detailsAMonoidstructureisrequiredtodefinetwostaticmembers e=0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 *-T#prod(,):theproductoftwoelementsinthemonoid * :prod(, *#rodoperator.Onecanthesedefaultbyspecializing *the*functionprod
*/ template <typename T> struct Monoid {
/// The one of type T staticTone 1 java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
/** the product of two elements of type T *#theoperator*.Onecanchangethesedefaultbyspecializing *@*/ *@returntheproducta*b
*/ staticconst Tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.