Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4e3ac8f1 authored by hhakim's avatar hhakim
Browse files

Start the python port of demo_fact_hadamard.m into pyfaust.demo.hadamardfact class.

At this stage the hadamard transform and its full matrix are properly generated through FaustFactory, then the factorization operates with a non-significant relative error (so it works).
parent dea257d4
No related branches found
No related tags found
No related merge requests found
...@@ -453,4 +453,28 @@ class runtimecmp: ...@@ -453,4 +453,28 @@ class runtimecmp:
#tight_layout() #tight_layout()
#show() #show()
class hadamardfact:
def run():
from pyfaust import FaustFactory
from pyfaust.factparams import ParamsHierarchicalFact, ConstraintInt, \
ConstraintName, StoppingCriterion
n = 5
d = 2**n
H = FaustFactory.hadamard(n)
full_H = H.toarray()
params = ParamsHierarchicalFact(n, is_update_way_R2L=True, init_lambda=1.0,
fact_constraints=[ConstraintInt(ConstraintName(ConstraintName.SPLINCOL),d,d,2)
for i in range(0,n-1)],
res_constraints=[ConstraintInt(ConstraintName(ConstraintName.SPLINCOL),d,d,int(d/2.**(i+1)))
for i in range(0,n-1)],
data_num_rows=d, data_num_cols=d,
stop_crits=[StoppingCriterion(num_its=30),StoppingCriterion(num_its=30)],
is_verbose=False)
had_faust = FaustFactory.fact_hierarchical(H.toarray(), params)
full_had_faust = had_faust.toarray()
rel_err = norm(full_had_faust-full_H)/norm(full_H)
print("\n\nRelative error between hadamard matrix and its transform: ",
rel_err)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment