-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMult_table.h
60 lines (46 loc) · 1.65 KB
/
Mult_table.h
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
#ifndef _MULT_TABLE_H_
#define _MULT_TABLE_H_
/*******************************************************************/
/*** FILE : Mult_table.h ***/
/*** AUTHOR: Sekhar Muddana ***/
/*** DATE WRITTEN: May 1990 ***/
/*** MODIFICATION: 9/93 - Trent Whiteley ***/
/*** changed Terms_list and terms from ***/
/*** arrays to pointers ***/
/*******************************************************************/
#include <vector>
#include <map>
#include "Build_defs.h"
#include "Alg_elements.h"
typedef std::map<std::pair<Basis, Basis>, std::vector<std::pair<Basis, Scalar> > > mult_table_t;
extern mult_table_t mult_table;
void DestroyMultTable();
void Print_MultTable(FILE *filePtr);
bool save_mult_table(FILE *f);
bool restore_mult_table(FILE *f);
inline bool EnterProduct(Basis B1, Basis B2, const std::vector<std::pair<Basis, Scalar> > &tl)
{
const std::pair<Basis, Basis> bb = std::make_pair(B1, B2);
if(mult_table.find(bb) == mult_table.end()) {
mult_table[bb] = tl;
} else {
puts("already present");
}
return true;
}
inline bool Mult2basis(Basis B1, Basis B2, Scalar x, Alg_element &P)
{
const std::pair<Basis, Basis> bb = std::make_pair(B1, B2);
auto ii = mult_table.find(bb);
if(ii == mult_table.end()) {
return false;
}
for(const auto & jj : ii->second) {
const Basis w = jj.first;
const Scalar coef = jj.second;
SetAE(P, w, S_add(GetAE(P, w), S_mul(x, coef)));
//AccumAE(P, w, S_mul(x, coef));
}
return true;
}
#endif