Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/MySQL/unsupported/test/   (MySQL Server Version 8.1-8.4©)  Datei vom 12.11.2025 mit Größe 57 kB image not shown  

Quelle  cxx11_tensor_symmetry.cpp

  Sprache: C
 

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2013 Christian Seiler <christian@iwakd.de>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "main.h"

#include <Eigen/CXX11/Tensor>
#include <Eigen/CXX11/TensorSymmetry>

#include <map>
#include <set>

using Eigen::Tensor;
using Eigen::SGroup;
using Eigen::DynamicSGroup;
using Eigen::StaticSGroup;
using Eigen::Symmetry;
using Eigen::AntiSymmetry;
using Eigen::Hermiticity;
using Eigen::AntiHermiticity;

using Eigen::NegationFlag;
using Eigen::ConjugationFlag;
using Eigen::GlobalZeroFlag;
using Eigen::GlobalRealFlag;
using Eigen::GlobalImagFlag;

// helper function to determine if the compiler intantiated a static
// or dynamic symmetry group
template<typename... Sym>
bool isDynGroup(StaticSGroup<Sym...> const& dummy)
{
  (void)dummy;
  return false;
}

bool isDynGroup(DynamicSGroup const& dummy)
{
  (void)dummy;
  return true;
}

// helper class for checking that the symmetry groups are correct
struct checkIdx {
  template<typename ArrType>
  static inline int doCheck_(ArrType e, int flags, int dummy, std::set<uint64_t>& found, std::map<uint64_t, intconst& expected)
  {
    // use decimal representation of value
    uint64_t value = e[0];
    for (std::size_t i = 1; i < e.size(); i++)
      value = value * 10 + e[i];

    // we want to make sure that we find each element
    auto it = expected.find(value);
    VERIFY((it != expected.end()));
    VERIFY_IS_EQUAL(it->second, flags);

    // we want to make sure we only have each element once;
    // set::insert returns true for the second part of the pair
    // if the element was really inserted and not already there
    auto p = found.insert(value);
    VERIFY((p.second));

    return dummy;
  }

  static inline int run(std::vector<int> e, int flags, int dummy, std::set<uint64_t>& found, std::map<uint64_t, intconst& expected)
  {
    return doCheck_(e, flags, dummy, found, expected);
  }

  template<std::size_t N>
  static inline int run(std::array<int, N> e, int flags, int dummy, std::set<uint64_t>& found, std::map<uint64_t, intconst& expected)
  {
    return doCheck_(e, flags, dummy, found, expected);
  }
};

static void test_symgroups_static()
{
  std::array<int7> identity{{0,1,2,3,4,5,6}};

  // Simple static symmetry group
  StaticSGroup<
    AntiSymmetry<0,1>,
    Hermiticity<0,2>
  > group;

  std::set<uint64_t> found;
  std::map<uint64_t, int> expected;
  expected[ 123456] = 0;
  expected[1023456] = NegationFlag;
  expected[2103456] = ConjugationFlag;
  expected[1203456] = ConjugationFlag | NegationFlag;
  expected[2013456] = ConjugationFlag | NegationFlag;
  expected[ 213456] = ConjugationFlag;

  VERIFY_IS_EQUAL(group.size(), 6u);
  VERIFY_IS_EQUAL(group.globalFlags(), GlobalImagFlag);
  group.apply<checkIdx, int>(identity, 0, found, expected);
  VERIFY_IS_EQUAL(found.size(), 6u);
}

static void test_symgroups_dynamic()
{
  std::vector<int> identity;
  for (int i = 0; i <= 6; i++)
    identity.push_back(i);

  // Simple dynamic symmetry group
  DynamicSGroup group;
  group.add(0,1,NegationFlag);
  group.add(0,2,ConjugationFlag);

  VERIFY_IS_EQUAL(group.size(), 6u);
  VERIFY_IS_EQUAL(group.globalFlags(), GlobalImagFlag);

  std::set<uint64_t> found;
  std::map<uint64_t, int> expected;
  expected[ 123456] = 0;
  expected[1023456] = NegationFlag;
  expected[2103456] = ConjugationFlag;
  expected[1203456] = ConjugationFlag | NegationFlag;
  expected[2013456] = ConjugationFlag | NegationFlag;
  expected[ 213456] = ConjugationFlag;

  VERIFY_IS_EQUAL(group.size(), 6u);
  VERIFY_IS_EQUAL(group.globalFlags(), GlobalImagFlag);
  group.apply<checkIdx, int>(identity, 0, found, expected);
  VERIFY_IS_EQUAL(found.size(), 6u);
}

static void test_symgroups_selection()
{
  std::array<int7> identity7{{0,1,2,3,4,5,6}};
  std::array<int10> identity10{{0,1,2,3,4,5,6,7,8,9}};

  {
    // Do the same test as in test_symgroups_static but
    // require selection via SGroup
    SGroup<
      AntiSymmetry<0,1>,
      Hermiticity<0,2>
    > group;

    std::set<uint64_t> found;
    std::map<uint64_t, int> expected;
    expected[ 123456] = 0;
    expected[1023456] = NegationFlag;
    expected[2103456] = ConjugationFlag;
    expected[1203456] = ConjugationFlag | NegationFlag;
    expected[2013456] = ConjugationFlag | NegationFlag;
    expected[ 213456] = ConjugationFlag;

    VERIFY(!isDynGroup(group));
    VERIFY_IS_EQUAL(group.size(), 6u);
    VERIFY_IS_EQUAL(group.globalFlags(), GlobalImagFlag);
    group.apply<checkIdx, int>(identity7, 0, found, expected);
    VERIFY_IS_EQUAL(found.size(), 6u);
  }

  {
    // simple factorizing group: 5 generators, 2^5 = 32 elements
    // selection should make this dynamic, although static group
    // can still be reasonably generated
    SGroup<
      Symmetry<0,1>,
      Symmetry<2,3>,
      Symmetry<4,5>,
      Symmetry<6,7>,
      Symmetry<8,9>
    > group;

    std::set<uint64_t> found;
    std::map<uint64_t, int> expected;
    expected[ 123456789] = 0; expected[ 123456798] = 0; expected[ 123457689] = 0; expected[ 123457698] = 0;
    expected[ 123546789] = 0; expected[ 123546798] = 0; expected[ 123547689] = 0; expected[ 123547698] = 0;
    expected[ 132456789] = 0; expected[ 132456798] = 0; expected[ 132457689] = 0; expected[ 132457698] = 0;
    expected[ 132546789] = 0; expected[ 132546798] = 0; expected[ 132547689] = 0; expected[ 132547698] = 0;
    expected[1023456789] = 0; expected[1023456798] = 0; expected[1023457689] = 0; expected[1023457698] = 0;
    expected[1023546789] = 0; expected[1023546798] = 0; expected[1023547689] = 0; expected[1023547698] = 0;
    expected[1032456789] = 0; expected[1032456798] = 0; expected[1032457689] = 0; expected[1032457698] = 0;
    expected[1032546789] = 0; expected[1032546798] = 0; expected[1032547689] = 0; expected[1032547698] = 0;

    VERIFY(isDynGroup(group));
    VERIFY_IS_EQUAL(group.size(), 32u);
    VERIFY_IS_EQUAL(group.globalFlags(), 0);
    group.apply<checkIdx, int>(identity10, 0, found, expected);
    VERIFY_IS_EQUAL(found.size(), 32u);

    // no verify that we could also generate a static group
    // with these generators
    found.clear();
    StaticSGroup<
      Symmetry<0,1>,
      Symmetry<2,3>,
      Symmetry<4,5>,
      Symmetry<6,7>,
      Symmetry<8,9>
    > group_static;
    VERIFY_IS_EQUAL(group_static.size(), 32u);
    VERIFY_IS_EQUAL(group_static.globalFlags(), 0);
    group_static.apply<checkIdx, int>(identity10, 0, found, expected);
    VERIFY_IS_EQUAL(found.size(), 32u);
  }

  {
    // try to create a HUGE group
    SGroup<
      Symmetry<0,1>,
      Symmetry<1,2>,
      Symmetry<2,3>,
      Symmetry<3,4>,
      Symmetry<4,5>,
      Symmetry<5,6>
    > group;

    std::set<uint64_t> found;
    uint64_t pre_expected[5040] = {
       1234561023456,  213456201345612034562103456,  1324561032456,  312456301245613024563102456,
       2314562031456,  321456302145623014563201456123045621304561320456312045623104563210456,
       1243561024356,  214356201435612043562104356,  1423561042356,  412356401235614023564102356,
       2413562041356,  421356402135624013564201356124035621403561420356412035624103564210356,
       1342561034256,  314256301425613042563104256,  1432561043256,  413256401325614032564103256,
       3412563041256,  431256403125634012564301256134025631402561430256413025634102564310256,
       2341562034156,  324156302415623041563204156,  2431562043156,  423156402315624031564203156,
       3421563042156,  432156403215634021564302156234015632401562430156423015634201564320156,
      123405621340561324056312405623140563214056124305621430561423056412305624130564213056,
      134205631420561432056413205634120564312056234105632410562431056423105634210564321056,
       1235461023546,  213546201354612035462103546,  1325461032546,  312546301254613025463102546,
       2315462031546,  321546302154623015463201546123054621305461320546312054623105463210546,
       1253461025346,  215346201534612053462105346,  1523461052346,  512346501234615023465102346,
       2513462051346,  521346502134625013465201346125034621503461520346512034625103465210346,
       1352461035246,  315246301524613052463105246,  1532461053246,  513246501324615032465103246,
       3512463051246,  531246503124635012465301246135024631502461530246513024635102465310246,
       2351462035146,  325146302514623051463205146,  2531462053146,  523146502314625031465203146,
       3521463052146,  532146503214635021465302146235014632501462530146523014635201465320146,
      123504621350461325046312504623150463215046125304621530461523046512304625130465213046,
      135204631520461532046513204635120465312046235104632510462531046523104635210465321046,
       1245361024536,  214536201453612045362104536,  1425361042536,  412536401253614025364102536,
       2415362041536,  421536402153624015364201536124053621405361420536412053624105364210536,
       1254361025436,  215436201543612054362105436,  1524361052436,  512436501243615024365102436,
       2514362051436,  521436502143625014365201436125043621504361520436512043625104365210436,
       1452361045236,  415236401523614052364105236,  1542361054236,  514236501423615042365104236,
       4512364051236,  541236504123645012365401236145023641502361540236514023645102365410236,
       2451362045136,  425136402513624051364205136,  2541362054136,  524136502413625041365204136,
       4521364052136,  542136504213645021365402136245013642501362540136524013645201365420136,
      124503621450361425036412503624150364215036125403621540361524036512403625140365214036,
      145203641520361542036514203645120365412036245103642510362541036524103645210365421036,
       1345261034526,  314526301452613045263104526,  1435261043526,  413526401352614035264103526,
       3415263041526,  431526403152634015264301526134052631405261430526413052634105264310526,
       1354261035426,  315426301542613054263105426,  1534261053426,  513426501342615034265103426,
       3514263051426,  531426503142635014265301426135042631504261530426513042635104265310426,
       1453261045326,  415326401532614053264105326,  1543261054326,  514326501432615043265104326,
       4513264051326,  541326504132645013265401326145032641503261540326514032645103265410326,
       3451263045126,  435126403512634051264305126,  3541263054126,  534126503412635041265304126,
       4531264053126,  543126504312645031265403126345012643501263540126534012645301265430126,
      134502631450261435026413502634150264315026135402631540261534026513402635140265314026,
      145302641530261543026514302645130265413026345102643510263541026534102645310265431026,
       2345162034516,  324516302451623045163204516,  2435162043516,  423516402351624035164203516,
       3425163042516,  432516403251634025164302516234051632405162430516423051634205164320516,
       2354162035416,  325416302541623054163205416,  2534162053416,  523416502341625034165203416,
       3524163052416,  532416503241635024165302416235041632504162530416523041635204165320416,
       2453162045316,  425316402531624053164205316,  2543162054316,  524316502431625043165204316,
       4523164052316,  542316504231645023165402316245031642503162540316524031645203165420316,
       3452163045216,  435216403521634052164305216,  3542163054216,  534216503421635042165304216,
       4532164053216,  543216504321645032165403216345021643502163540216534021645302165430216,
      234501632450162435016423501634250164325016235401632540162534016523401635240165324016,
      245301642530162543016524301645230165423016345201643520163542016534201645320165432016,
      123450621345061324506312450623145063214506124350621435061423506412350624135064213506,
      134250631425061432506413250634125064312506234150632415062431506423150634215064321506,
      123540621354061325406312540623154063215406125340621534061523406512340625134065213406,
      135240631524061532406513240635124065312406235140632514062531406523140635214065321406,
      124530621453061425306412530624153064215306125430621543061524306512430625143065214306,
      145230641523061542306514230645123065412306245130642513062541306524130645213065421306,
      134520631452061435206413520634152064315206135420631542061534206513420635142065314206,
      145320641532061543206514320645132065413206345120643512063541206534120645312065431206,
      234510632451062435106423510634251064325106235410632541062534106523410635241065324106,
      245310642531062543106524310645231065423106345210643521063542106534210645321065432106,
       1234651023465,  213465201346512034652103465,  1324651032465,  312465301246513024653102465,
       2314652031465,  321465302146523014653201465123046521304651320465312046523104653210465,
       1243651024365,  214365201436512043652104365,  1423651042365,  412365401236514023654102365,
       2413652041365,  421365402136524013654201365124036521403651420365412036524103654210365,
       1342651034265,  314265301426513042653104265,  1432651043265,  413265401326514032654103265,
       3412653041265,  431265403126534012654301265134026531402651430265413026534102654310265,
       2341652034165,  324165302416523041653204165,  2431652043165,  423165402316524031654203165,
       3421653042165,  432165403216534021654302165234016532401652430165423016534201654320165,
      123406521340651324065312406523140653214065124306521430651423065412306524130654213065,
      134206531420651432065413206534120654312065234106532410652431065423106534210654321065,
       1236451023645,  213645201364512036452103645,  1326451032645,  312645301264513026453102645,
       2316452031645,  321645302164523016453201645123064521306451320645312064523106453210645,
       1263451026345,  216345201634512063452106345,  1623451062345,  612345601234516023456102345,
       2613452061345,  621345602134526013456201345126034521603451620345612034526103456210345,
       1362451036245,  316245301624513062453106245,  1632451063245,  613245601324516032456103245,
       3612453061245,  631245603124536012456301245136024531602451630245613024536102456310245,
       2361452036145,  326145302614523061453206145,  2631452063145,  623145602314526031456203145,
       3621453062145,  632145603214536021456302145236014532601452630145623014536201456320145,
      123604521360451326045312604523160453216045126304521630451623045612304526130456213045,
      136204531620451632045613204536120456312045236104532610452631045623104536210456321045,
       1246351024635,  214635201463512046352104635,  1426351042635,  412635401263514026354102635,
       2416352041635,  421635402163524016354201635124063521406351420635412063524106354210635,
       1264351026435,  216435201643512064352106435,  1624351062435,  612435601243516024356102435,
       2614352061435,  621435602143526014356201435126043521604351620435612043526104356210435,
       1462351046235,  416235401623514062354106235,  1642351064235,  614235601423516042356104235,
       4612354061235,  641235604123546012356401235146023541602351640235614023546102356410235,
       2461352046135,  426135402613524061354206135,  2641352064135,  624135602413526041356204135,
       4621354062135,  642135604213546021356402135246013542601352640135624013546201356420135,
      124603521460351426035412603524160354216035126403521640351624035612403526140356214035,
      146203541620351642035614203546120356412035246103542610352641035624103546210356421035,
       1346251034625,  314625301462513046253104625,  1436251043625,  413625401362514036254103625,
       3416253041625,  431625403162534016254301625134062531406251430625413062534106254310625,
       1364251036425,  316425301642513064253106425,  1634251063425,  613425601342516034256103425,
       3614253061425,  631425603142536014256301425136042531604251630425613042536104256310425,
       1463251046325,  416325401632514063254106325,  1643251064325,  614325601432516043256104325,
       4613254061325,  641325604132546013256401325146032541603251640325614032546103256410325,
       3461253046125,  436125403612534061254306125,  3641253064125,  634125603412536041256304125,
       4631254063125,  643125604312546031256403125346012543601253640125634012546301256430125,
      134602531460251436025413602534160254316025136402531640251634025613402536140256314025,
      146302541630251643025614302546130256413025346102543610253641025634102546310256431025,
       2346152034615,  324615302461523046153204615,  2436152043615,  423615402361524036154203615,
       3426153042615,  432615403261534026154302615234061532406152430615423061534206154320615,
       2364152036415,  326415302641523064153206415,  2634152063415,  623415602341526034156203415,
       3624153062415,  632415603241536024156302415236041532604152630415623041536204156320415,
       2463152046315,  426315402631524063154206315,  2643152064315,  624315602431526043156204315,
       4623154062315,  642315604231546023156402315246031542603152640315624031546203156420315,
       3462153046215,  436215403621534062154306215,  3642153064215,  634215603421536042156304215,
       4632154063215,  643215604321546032156403215346021543602153640215634021546302156430215,
      234601532460152436015423601534260154326015236401532640152634015623401536240156324015,
      246301542630152643015624301546230156423015346201543620153642015634201546320156432015,
      123460521346051324605312460523146053214605124360521436051423605412360524136054213605,
      134260531426051432605413260534126054312605234160532416052431605423160534216054321605,
      123640521364051326405312640523164053216405126340521634051623405612340526134056213405,
      136240531624051632405613240536124056312405236140532614052631405623140536214056321405,
      124630521463051426305412630524163054216305126430521643051624305612430526143056214305,
      146230541623051642305614230546123056412305246130542613052641305624130546213056421305,
      134620531462051436205413620534162054316205136420531642051634205613420536142056314205,
      146320541632051643205614320546132056413205346120543612053641205634120546312056431205,
      234610532461052436105423610534261054326105236410532641052634105623410536241056324105,
      246310542631052643105624310546231056423105346210543621053642105634210546321056432105,
       1235641023564,  213564201356412035642103564,  1325641032564,  312564301256413025643102564,
       2315642031564,  321564302156423015643201564123056421305641320564312056423105643210564,
       1253641025364,  215364201536412053642105364,  1523641052364,  512364501236415023645102364,
       2513642051364,  521364502136425013645201364125036421503641520364512036425103645210364,
       1352641035264,  315264301526413052643105264,  1532641053264,  513264501326415032645103264,
       3512643051264,  531264503126435012645301264135026431502641530264513026435102645310264,
       2351642035164,  325164302516423051643205164,  2531642053164,  523164502316425031645203164,
       3521643052164,  532164503216435021645302164235016432501642530164523016435201645320164,
      123506421350641325064312506423150643215064125306421530641523064512306425130645213064,
      135206431520641532064513206435120645312064235106432510642531064523106435210645321064,
       1236541023654,  213654201365412036542103654,  1326541032654,  312654301265413026543102654,
       2316542031654,  321654302165423016543201654123065421306541320654312065423106543210654,
       1263541026354,  216354201635412063542106354,  1623541062354,  612354601235416023546102354,
       2613542061354,  621354602135426013546201354126035421603541620354612035426103546210354,
       1362541036254,  316254301625413062543106254,  1632541063254,  613254601325416032546103254,
       3612543061254,  631254603125436012546301254136025431602541630254613025436102546310254,
       2361542036154,  326154302615423061543206154,  2631542063154,  623154602315426031546203154,
       3621543062154,  632154603215436021546302154236015432601542630154623015436201546320154,
      123605421360541326054312605423160543216054126305421630541623054612305426130546213054,
      136205431620541632054613205436120546312054236105432610542631054623105436210546321054,
       1256341025634,  215634201563412056342105634,  1526341052634,  512634501263415026345102634,
       2516342051634,  521634502163425016345201634125063421506341520634512063425106345210634,
       1265341026534,  216534201653412065342106534,  1625341062534,  612534601253416025346102534,
       2615342061534,  621534602153426015346201534126053421605341620534612053426105346210534,
       1562341056234,  516234501623415062345106234,  1652341065234,  615234601523416052346105234,
       5612345061234,  651234605123456012346501234156023451602341650234615023456102346510234,
       2561342056134,  526134502613425061345206134,  2651342065134,  625134602513426051346205134,
       5621345062134,  652134605213456021346502134256013452601342650134625013456201346520134,
      125603421560341526034512603425160345216034126503421650341625034612503426150346215034,
      156203451620341652034615203456120346512034256103452610342651034625103456210346521034,
       1356241035624,  315624301562413056243105624,  1536241053624,  513624501362415036245103624,
       3516243051624,  531624503162435016245301624135062431506241530624513062435106245310624,
       1365241036524,  316524301652413065243106524,  1635241063524,  613524601352416035246103524,
       3615243061524,  631524603152436015246301524136052431605241630524613052436105246310524,
       1563241056324,  516324501632415063245106324,  1653241065324,  615324601532416053246105324,
       5613245061324,  651324605132456013246501324156032451603241650324615032456103246510324,
       3561243056124,  536124503612435061245306124,  3651243065124,  635124603512436051246305124,
       5631245063124,  653124605312456031246503124356012453601243650124635012456301246530124,
      135602431560241536024513602435160245316024136502431650241635024613502436150246315024,
      156302451630241653024615302456130246513024356102453610243651024635102456310246531024,
       2356142035614,  325614302561423056143205614,  2536142053614,  523614502361425036145203614,
       3526143052614,  532614503261435026145302614235061432506142530614523061435206145320614,
       2365142036514,  326514302651423065143206514,  2635142063514,  623514602351426035146203514,
       3625143062514,  632514603251436025146302514236051432605142630514623051436205146320514,
       2563142056314,  526314502631425063145206314,  2653142065314,  625314602531426053146205314,
       5623145062314,  652314605231456023146502314256031452603142650314625031456203146520314,
       3562143056214,  536214503621435062145306214,  3652143065214,  635214603521436052146305214,
       5632145063214,  653214605321456032146503214356021453602143650214635021456302146530214,
      235601432560142536014523601435260145326014236501432650142635014623501436250146325014,
      256301452630142653014625301456230146523014356201453620143652014635201456320146532014,
      123560421356041325604312560423156043215604125360421536041523604512360425136045213604,
      135260431526041532604513260435126045312604235160432516042531604523160435216045321604,
      123650421365041326504312650423165043216504126350421635041623504612350426135046213504,
      136250431625041632504613250436125046312504236150432615042631504623150436215046321504,
      125630421563041526304512630425163045216304126530421653041625304612530426153046215304,
      156230451623041652304615230456123046512304256130452613042651304625130456213046521304,
      135620431562041536204513620435162045316204136520431652041635204613520436152046315204,
      156320451632041653204615320456132046513204356120453612043651204635120456312046531204,
      235610432561042536104523610435261045326104236510432651042635104623510436251046325104,
      256310452631042653104625310456231046523104356210453621043652104635210456321046532104,
       1245631024563,  214563201456312045632104563,  1425631042563,  412563401256314025634102563,
       2415632041563,  421563402156324015634201563124056321405631420563412056324105634210563,
       1254631025463,  215463201546312054632105463,  1524631052463,  512463501246315024635102463,
       2514632051463,  521463502146325014635201463125046321504631520463512046325104635210463,
       1452631045263,  415263401526314052634105263,  1542631054263,  514263501426315042635104263,
       4512634051263,  541263504126345012635401263145026341502631540263514026345102635410263,
       2451632045163,  425163402516324051634205163,  2541632054163,  524163502416325041635204163,
       4521634052163,  542163504216345021635402163245016342501632540163524016345201635420163,
      124506321450631425063412506324150634215063125406321540631524063512406325140635214063,
      145206341520631542063514206345120635412063245106342510632541063524106345210635421063,
       1246531024653,  214653201465312046532104653,  1426531042653,  412653401265314026534102653,
       2416532041653,  421653402165324016534201653124065321406531420653412065324106534210653,
       1264531026453,  216453201645312064532106453,  1624531062453,  612453601245316024536102453,
       2614532061453,  621453602145326014536201453126045321604531620453612045326104536210453,
       1462531046253,  416253401625314062534106253,  1642531064253,  614253601425316042536104253,
       4612534061253,  641253604125346012536401253146025341602531640253614025346102536410253,
       2461532046153,  426153402615324061534206153,  2641532064153,  624153602415326041536204153,
       4621534062153,  642153604215346021536402153246015342601532640153624015346201536420153,
      124605321460531426053412605324160534216053126405321640531624053612405326140536214053,
      146205341620531642053614205346120536412053246105342610532641053624105346210536421053,
       1256431025643,  215643201564312056432105643,  1526431052643,  512643501264315026435102643,
       2516432051643,  521643502164325016435201643125064321506431520643512064325106435210643,
       1265431026543,  216543201654312065432106543,  1625431062543,  612543601254316025436102543,
       2615432061543,  621543602154326015436201543126054321605431620543612054326105436210543,
       1562431056243,  516243501624315062435106243,  1652431065243,  615243601524316052436105243,
       5612435061243,  651243605124356012436501243156024351602431650243615024356102436510243,
       2561432056143,  526143502614325061435206143,  2651432065143,  625143602514326051436205143,
       5621435062143,  652143605214356021436502143256014352601432650143625014356201436520143,
      125604321560431526043512604325160435216043126504321650431625043612504326150436215043,
      156204351620431652043615204356120436512043256104352610432651043625104356210436521043,
       1456231045623,  415623401562314056234105623,  1546231054623,  514623501462315046235104623,
       4516234051623,  541623504162345016235401623145062341506231540623514062345106235410623,
       1465231046523,  416523401652314065234106523,  1645231064523,  614523601452316045236104523,
       4615234061523,  641523604152346015236401523146052341605231640523614052346105236410523,
       1564231056423,  516423501642315064235106423,  1654231065423,  615423601542316054236105423,
       5614235061423,  651423605142356014236501423156042351604231650423615042356104236510423,
       4561234056123,  546123504612345061235406123,  4651234065123,  645123604512346051236405123,
       5641235064123,  654123605412356041236504123456012354601234650123645012356401236540123,
      145602341560231546023514602345160235416023146502341650231645023614502346150236415023,
      156402351640231654023615402356140236514023456102354610234651023645102356410236541023,
       2456132045613,  425613402561324056134205613,  2546132054613,  524613502461325046135204613,
       4526134052613,  542613504261345026135402613245061342506132540613524061345206135420613,
       2465132046513,  426513402651324065134206513,  2645132064513,  624513602451326045136204513,
       4625134062513,  642513604251346025136402513246051342605132640513624051346205136420513,
       2564132056413,  526413502641325064135206413,  2654132065413,  625413602541326054136205413,
       5624135062413,  652413605241356024136502413256041352604132650413625041356204136520413,
       4562134056213,  546213504621345062135406213,  4652134065213,  645213604521346052136405213,
       5642135064213,  654213605421356042136504213456021354602134650213645021356402136540213,
      245601342560132546013524601345260135426013246501342650132645013624501346250136425013,
      256401352640132654013625401356240136524013456201354620134652013645201356420136542013,
      124560321456031425603412560324156034215603125460321546031524603512460325146035214603,
      145260341526031542603514260345126035412603245160342516032541603524160345216035421603,
      124650321465031426503412650324165034216503126450321645031624503612450326145036214503,
      146250341625031642503614250346125036412503246150342615032641503624150346215036421503,
      125640321564031526403512640325164035216403126540321654031625403612540326154036215403,
      156240351624031652403615240356124036512403256140352614032651403625140356214036521403,
      145620341562031546203514620345162035416203146520341652031645203614520346152036415203,
      156420351642031654203615420356142036514203456120354612034651203645120356412036541203,
      245610342561032546103524610345261035426103246510342651032645103624510346251036425103,
      256410352641032654103625410356241036524103456210354621034652103645210356421036542103,
       1345621034562,  314562301456213045623104562,  1435621043562,  413562401356214035624103562,
       3415623041562,  431562403156234015624301562134056231405621430562413056234105624310562,
       1354621035462,  315462301546213054623105462,  1534621053462,  513462501346215034625103462,
       3514623051462,  531462503146235014625301462135046231504621530462513046235104625310462,
       1453621045362,  415362401536214053624105362,  1543621054362,  514362501436215043625104362,
       4513624051362,  541362504136245013625401362145036241503621540362514036245103625410362,
       3451623045162,  435162403516234051624305162,  3541623054162,  534162503416235041625304162,
       4531624053162,  543162504316245031625403162345016243501623540162534016245301625430162,
      134506231450621435062413506234150624315062135406231540621534062513406235140625314062,
      145306241530621543062514306245130625413062345106243510623541062534106245310625431062,
       1346521034652,  314652301465213046523104652,  1436521043652,  413652401365214036524103652,
       3416523041652,  431652403165234016524301652134065231406521430652413065234106524310652,
       1364521036452,  316452301645213064523106452,  1634521063452,  613452601345216034526103452,
       3614523061452,  631452603145236014526301452136045231604521630452613045236104526310452,
       1463521046352,  416352401635214063524106352,  1643521064352,  614352601435216043526104352,
       4613524061352,  641352604135246013526401352146035241603521640352614035246103526410352,
       3461523046152,  436152403615234061524306152,  3641523064152,  634152603415236041526304152,
       4631524063152,  643152604315246031526403152346015243601523640152634015246301526430152,
      134605231460521436052413605234160524316052136405231640521634052613405236140526314052,
      146305241630521643052614305246130526413052346105243610523641052634105246310526431052,
       1356421035642,  315642301564213056423105642,  1536421053642,  513642501364215036425103642,
       3516423051642,  531642503164235016425301642135064231506421530642513064235106425310642,
       1365421036542,  316542301654213065423106542,  1635421063542,  613542601354216035426103542,
       3615423061542,  631542603154236015426301542136054231605421630542613054236105426310542,
       1563421056342,  516342501634215063425106342,  1653421065342,  615342601534216053426105342,
       5613425061342,  651342605134256013426501342156034251603421650342615034256103426510342,
       3561423056142,  536142503614235061425306142,  3651423065142,  635142603514236051426305142,
       5631425063142,  653142605314256031426503142356014253601423650142635014256301426530142,
      135604231560421536042513604235160425316042136504231650421635042613504236150426315042,
      156304251630421653042615304256130426513042356104253610423651042635104256310426531042,
       1456321045632,  415632401563214056324105632,  1546321054632,  514632501463215046325104632,
       4516324051632,  541632504163245016325401632145063241506321540632514063245106325410632,
       1465321046532,  416532401653214065324106532,  1645321064532,  614532601453216045326104532,
       4615324061532,  641532604153246015326401532146053241605321640532614053246105326410532,
       1564321056432,  516432501643215064325106432,  1654321065432,  615432601543216054326105432,
       5614325061432,  651432605143256014326501432156043251604321650432615043256104326510432,
       4561324056132,  546132504613245061325406132,  4651324065132,  645132604513246051326405132,
       5641325064132,  654132605413256041326504132456013254601324650132645013256401326540132,
      145603241560321546032514603245160325416032146503241650321645032614503246150326415032,
      156403251640321654032615403256140326514032456103254610324651032645103256410326541032,
       3456123045612,  435612403561234056124305612,  3546123054612,  534612503461235046125304612,
       4536124053612,  543612504361245036125403612345061243506123540612534061245306125430612,
       3465123046512,  436512403651234065124306512,  3645123064512,  634512603451236045126304512,
       4635124063512,  643512604351246035126403512346051243605123640512634051246305126430512,
       3564123056412,  536412503641235064125306412,  3654123065412,  635412603541236054126305412,
       5634125063412,  653412605341256034126503412356041253604123650412635041256304126530412,
       4563124056312,  546312504631245063125406312,  4653124065312,  645312604531246053126405312,
       5643125064312,  654312605431256043126504312456031254603124650312645031256403126540312,
      345601243560123546012534601245360125436012346501243650123645012634501246350126435012,
      356401253640123654012635401256340126534012456301254630124653012645301256430126543012,
      134560231456021435602413560234156024315602135460231546021534602513460235146025314602,
      145360241536021543602514360245136025413602345160243516023541602534160245316025431602,
      134650231465021436502413650234165024316502136450231645021634502613450236145026314502,
      146350241635021643502614350246135026413502346150243615023641502634150246315026431502,
      135640231564021536402513640235164025316402136540231654021635402613540236154026315402,
      156340251634021653402615340256134026513402356140253614023651402635140256314026531402,
      145630241563021546302514630245163025416302146530241653021645302614530246153026415302,
      156430251643021654302615430256143026514302456130254613024651302645130256413026541302,
      345610243561023546102534610245361025436102346510243651023645102634510246351026435102,
      356410253641023654102635410256341026534102456310254631024653102645310256431026543102,
       2345612034561,  324561302456123045613204561,  2435612043561,  423561402356124035614203561,
       3425613042561,  432561403256134025614302561234056132405612430561423056134205614320561,
       2354612035461,  325461302546123054613205461,  2534612053461,  523461502346125034615203461,
       3524613052461,  532461503246135024615302461235046132504612530461523046135204615320461,
       2453612045361,  425361402536124053614205361,  2543612054361,  524361502436125043615204361,
       4523614052361,  542361504236145023615402361245036142503612540361524036145203615420361,
       3452613045261,  435261403526134052614305261,  3542613054261,  534261503426135042615304261,
       4532614053261,  543261504326145032615403261345026143502613540261534026145302615430261,
      234506132450612435061423506134250614325061235406132540612534061523406135240615324061,
      245306142530612543061524306145230615423061345206143520613542061534206145320615432061,
       2346512034651,  324651302465123046513204651,  2436512043651,  423651402365124036514203651,
       3426513042651,  432651403265134026514302651234065132406512430651423065134206514320651,
       2364512036451,  326451302645123064513206451,  2634512063451,  623451602345126034516203451,
       3624513062451,  632451603245136024516302451236045132604512630451623045136204516320451,
       2463512046351,  426351402635124063514206351,  2643512064351,  624351602435126043516204351,
       4623514062351,  642351604235146023516402351246035142603512640351624035146203516420351,
       3462513046251,  436251403625134062514306251,  3642513064251,  634251603425136042516304251,
       4632514063251,  643251604325146032516403251346025143602513640251634025146302516430251,
      234605132460512436051423605134260514326051236405132640512634051623405136240516324051,
      246305142630512643051624305146230516423051346205143620513642051634205146320516432051,
       2356412035641,  325641302564123056413205641,  2536412053641,  523641502364125036415203641,
       3526413052641,  532641503264135026415302641235064132506412530641523064135206415320641,
       2365412036541,  326541302654123065413206541,  2635412063541,  623541602354126035416203541,
       3625413062541,  632541603254136025416302541236054132605412630541623054136205416320541,
       2563412056341,  526341502634125063415206341,  2653412065341,  625341602534126053416205341,
       5623415062341,  652341605234156023416502341256034152603412650341625034156203416520341,
       3562413056241,  536241503624135062415306241,  3652413065241,  635241603524136052416305241,
       5632415063241,  653241605324156032416503241356024153602413650241635024156302416530241,
      235604132560412536041523604135260415326041236504132650412635041623504136250416325041,
      256304152630412653041625304156230416523041356204153620413652041635204156320416532041,
       2456312045631,  425631402563124056314205631,  2546312054631,  524631502463125046315204631,
       4526314052631,  542631504263145026315402631245063142506312540631524063145206315420631,
       2465312046531,  426531402653124065314206531,  2645312064531,  624531602453126045316204531,
       4625314062531,  642531604253146025316402531246053142605312640531624053146205316420531,
       2564312056431,  526431502643125064315206431,  2654312065431,  625431602543126054316205431,
       5624315062431,  652431605243156024316502431256043152604312650431625043156204316520431,
       4562314056231,  546231504623145062315406231,  4652314065231,  645231604523146052316405231,
       5642315064231,  654231605423156042316504231456023154602314650231645023156402316540231,
      245603142560312546031524603145260315426031246503142650312645031624503146250316425031,
      256403152640312654031625403156240316524031456203154620314652031645203156420316542031,
       3456213045621,  435621403562134056214305621,  3546213054621,  534621503462135046215304621,
       4536214053621,  543621504362145036215403621345062143506213540621534062145306215430621,
       3465213046521,  436521403652134065214306521,  3645213064521,  634521603452136045216304521,
       4635214063521,  643521604352146035216403521346052143605213640521634052146305216430521,
       3564213056421,  536421503642135064215306421,  3654213065421,  635421603542136054216305421,
       5634215063421,  653421605342156034216503421356042153604213650421635042156304216530421,
       4563214056321,  546321504632145063215406321,  4653214065321,  645321604532146053216405321,
       5643215064321,  654321605432156043216504321456032154603214650321645032156403216540321,
      345602143560213546021534602145360215436021346502143650213645021634502146350216435021,
      356402153640213654021635402156340216534021456302154630214653021645302156430216543021,
      234560132456012435601423560134256014325601235460132546012534601523460135246015324601,
      245360142536012543601524360145236015423601345260143526013542601534260145326015432601,
      234650132465012436501423650134265014326501236450132645012634501623450136245016324501,
      246350142635012643501624350146235016423501346250143625013642501634250146325016432501,
      235640132564012536401523640135264015326401236540132654012635401623540136254016325401,
      256340152634012653401625340156234016523401356240153624013652401635240156324016532401,
      245630142563012546301524630145263015426301246530142653012645301624530146253016425301,
      256430152643012654301625430156243016524301456230154623014652301645230156423016542301,
      345620143562013546201534620145362015436201346520143652013645201634520146352016435201,
      356420153642013654201635420156342016534201456320154632014653201645320156432016543201,
      123456021345601324560312456023145603214560124356021435601423560412356024135604213560,
      134256031425601432560413256034125604312560234156032415602431560423156034215604321560,
      123546021354601325460312546023154603215460125346021534601523460512346025134605213460,
      135246031524601532460513246035124605312460235146032514602531460523146035214605321460,
      124536021453601425360412536024153604215360125436021543601524360512436025143605214360,
      145236041523601542360514236045123605412360245136042513602541360524136045213605421360,
      134526031452601435260413526034152604315260135426031542601534260513426035142605314260,
      145326041532601543260514326045132605413260345126043512603541260534126045312605431260,
      234516032451602435160423516034251604325160235416032541602534160523416035241605324160,
      245316042531602543160524316045231605423160345216043521603542160534216045321605432160,
      123465021346501324650312465023146503214650124365021436501423650412365024136504213650,
      134265031426501432650413265034126504312650234165032416502431650423165034216504321650,
      123645021364501326450312645023164503216450126345021634501623450612345026134506213450,
      136245031624501632450613245036124506312450236145032614502631450623145036214506321450,
      124635021463501426350412635024163504216350126435021643501624350612435026143506214350,
      146235041623501642350614235046123506412350246135042613502641350624135046213506421350,
      134625031462501436250413625034162504316250136425031642501634250613425036142506314250,
      146325041632501643250614325046132506413250346125043612503641250634125046312506431250,
      234615032461502436150423615034261504326150236415032641502634150623415036241506324150,
      246315042631502643150624315046231506423150346215043621503642150634215046321506432150,
      123564021356401325640312564023156403215640125364021536401523640512364025136405213640,
      135264031526401532640513264035126405312640235164032516402531640523164035216405321640,
      123654021365401326540312654023165403216540126354021635401623540612354026135406213540,
      136254031625401632540613254036125406312540236154032615402631540623154036215406321540,
      125634021563401526340512634025163405216340126534021653401625340612534026153406215340,
      156234051623401652340615234056123406512340256134052613402651340625134056213406521340,
      135624031562401536240513624035162405316240136524031652401635240613524036152406315240,
      156324051632401653240615324056132406513240356124053612403651240635124056312406531240,
      235614032561402536140523614035261405326140236514032651402635140623514036251406325140,
      256314052631402653140625314056231406523140356214053621403652140635214056321406532140,
      124563021456301425630412563024156304215630125463021546301524630512463025146305214630,
      145263041526301542630514263045126305412630245163042516302541630524163045216305421630,
      124653021465301426530412653024165304216530126453021645301624530612453026145306214530,
      146253041625301642530614253046125306412530246153042615302641530624153046215306421530,
      125643021564301526430512643025164305216430126543021654301625430612543026154306215430,
      156243051624301652430615243056124306512430256143052614302651430625143056214306521430,
      145623041562301546230514623045162305416230146523041652301645230614523046152306415230,
      156423051642301654230615423056142306514230456123054612304651230645123056412306541230,
      245613042561302546130524613045261305426130246513042651302645130624513046251306425130,
      256413052641302654130625413056241306524130456213054621304652130645213056421306542130,
      134562031456201435620413562034156204315620135462031546201534620513462035146205314620,
      145362041536201543620514362045136205413620345162043516203541620534162045316205431620,
      134652031465201436520413652034165204316520136452031645201634520613452036145206314520,
      146352041635201643520614352046135206413520346152043615203641520634152046315206431520,
      135642031564201536420513642035164205316420136542031654201635420613542036154206315420,
      156342051634201653420615342056134206513420356142053614203651420635142056314206531420,
      145632041563201546320514632045163205416320146532041653201645320614532046153206415320,
      156432051643201654320615432056143206514320456132054613204651320645132056413206541320,
      345612043561203546120534612045361205436120346512043651203645120634512046351206435120,
      356412053641203654120635412056341206534120456312054631204653120645312056431206543120,
      234561032456102435610423561034256104325610235461032546102534610523461035246105324610,
      245361042536102543610524361045236105423610345261043526103542610534261045326105432610,
      234651032465102436510423651034265104326510236451032645102634510623451036245106324510,
      246351042635102643510624351046235106423510346251043625103642510634251046325106432510,
      235641032564102536410523641035264105326410236541032654102635410623541036254106325410,
      256341052634102653410625341056234106523410356241053624103652410635241056324106532410,
      245631042563102546310524631045263105426310246531042653102645310624531046253106425310,
      256431052643102654310625431056243106524310456231054623104652310645231056423106542310,
      345621043562103546210534621045362105436210346521043652103645210634521046352106435210,
      356421053642103654210635421056342106534210456321054632104653210645321056432106543210
    };
    std::map<uint64_t, int> expected;
    for (std::size_t i = 0; i < 5040; i++)
      expected[pre_expected[i]] = 0// flags are 0, everything is symmetric here

    VERIFY(isDynGroup(group));
    VERIFY_IS_EQUAL(group.size(), 5040u);
    VERIFY_IS_EQUAL(group.globalFlags(), 0);
    group.apply<checkIdx, int>(identity7, 0, found, expected);
    VERIFY_IS_EQUAL(found.size(), 5040u);
  }
}

static void test_tensor_epsilon()
{
  SGroup<AntiSymmetry<0,1>, AntiSymmetry<1,2>> sym;
  Tensor<int3> epsilon(3,3,3);

  epsilon.setZero();
  sym(epsilon, 012) = 1;

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        VERIFY_IS_EQUAL((epsilon(i,j,k)), (- (j - i) * (k - j) * (i - k) / 2) );
      }
    }
  }
}

static void test_tensor_sym()
{
  SGroup<Symmetry<0,1>, Symmetry<2,3>> sym;
  Tensor<int4> t(10,10,10,10);

  t.setZero();

  for (int l = 0; l < 10; l++) {
    for (int k = l; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = j; i < 10; i++) {
          sym(t, i, j, k, l) = (i + j) * (k + l);
        }
      }
    }
  }

  for (int l = 0; l < 10; l++) {
    for (int k = 0; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 10; i++) {
          VERIFY_IS_EQUAL((t(i, j, k, l)), ((i + j) * (k + l)));
        }
      }
    }
  }

}

static void test_tensor_asym()
{
  SGroup<AntiSymmetry<0,1>, AntiSymmetry<2,3>> sym;
  Tensor<int4> t(10,10,10,10);

  t.setZero();

  for (int l = 0; l < 10; l++) {
    for (int k = l + 1; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = j + 1; i < 10; i++) {
          sym(t, i, j, k, l) = ((i * j) + (k * l));
        }
      }
    }
  }

  for (int l = 0; l < 10; l++) {
    for (int k = 0; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 10; i++) {
          if (i < j && k < l)
            VERIFY_IS_EQUAL((t(i, j, k, l)), (((i * j) + (k * l))));
          else if (i > j && k > l)
            VERIFY_IS_EQUAL((t(i, j, k, l)), (((i * j) + (k * l))));
          else if (i < j && k > l)
            VERIFY_IS_EQUAL((t(i, j, k, l)), (- ((i * j) + (k * l))));
          else if (i > j && k < l)
            VERIFY_IS_EQUAL((t(i, j, k, l)), (- ((i * j) + (k * l))));
          else
            VERIFY_IS_EQUAL((t(i, j, k, l)), 0);
        }
      }
    }
  }
}

static void test_tensor_dynsym()
{
  DynamicSGroup sym;
  sym.addSymmetry(0,1);
  sym.addSymmetry(2,3);
  Tensor<int4> t(10,10,10,10);

  t.setZero();

  for (int l = 0; l < 10; l++) {
    for (int k = l; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = j; i < 10; i++) {
          sym(t, i, j, k, l) = (i + j) * (k + l);
        }
      }
    }
  }

  for (int l = 0; l < 10; l++) {
    for (int k = 0; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 10; i++) {
          VERIFY_IS_EQUAL((t(i, j, k, l)), ((i + j) * (k + l)));
        }
      }
    }
  }
}

static void test_tensor_randacc()
{
  SGroup<Symmetry<0,1>, Symmetry<2,3>> sym;
  Tensor<int4> t(10,10,10,10);

  t.setZero();

  // set elements 1 million times, that way we access the
  // entire matrix
  for (int n = 0; n < 1000000; n++) {
    int i = rand() % 10;
    int j = rand() % 10;
    int k = rand() % 10;
    int l = rand() % 10;
    // only access those indices in a given order
    if (i < j)
      std::swap(i, j);
    if (k < l)
      std::swap(k, l);
    sym(t, i, j, k, l) = (i + j) * (k + l);
  }

  for (int l = 0; l < 10; l++) {
    for (int k = 0; k < 10; k++) {
      for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 10; i++) {
          VERIFY_IS_EQUAL((t(i, j, k, l)), ((i + j) * (k + l)));
        }
      }
    }
  }
}

EIGEN_DECLARE_TEST(cxx11_tensor_symmetry)
{
  CALL_SUBTEST(test_symgroups_static());
  CALL_SUBTEST(test_symgroups_dynamic());
  CALL_SUBTEST(test_symgroups_selection());
  CALL_SUBTEST(test_tensor_epsilon());
  CALL_SUBTEST(test_tensor_sym());
  CALL_SUBTEST(test_tensor_asym());
  CALL_SUBTEST(test_tensor_dynsym());
  CALL_SUBTEST(test_tensor_randacc());
}

/*
 * kate: space-indent on; indent-width 2; mixedindent off; indent-mode cstyle;
 */


Messung V0.5 in Prozent
C=92 H=91 G=91

¤ Dauer der Verarbeitung: 0.54 Sekunden  (vorverarbeitet am  2026-06-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.