Skip to content

Commit d449ea3

Browse files
committed
Merge branch 'dev'
2 parents cf9a099 + fca0da6 commit d449ea3

File tree

2 files changed

+5
-101
lines changed

2 files changed

+5
-101
lines changed

src/mad_tpsa_comp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ FUN(compose) (ssz_t sa, const T *ma[sa], ssz_t sb, const T *mb[sb], T *mc[sa])
233233
printf("mb:\n"); print_damap(sb, mb, 0);
234234
#endif
235235

236-
if (hi_ord == 1) compose_ord1(sa,ma, sb,mb, mc);
236+
if (hi_ord == 1) compose_ord1(sa,ma, sb,mb, mc_);
237237

238238
#ifdef _OPENMP // TODO: find pcomp heuristic at desc init...
239239
else if (d->pcomp && hi_ord >= 6 && d->ord2idx[hi_ord+1] >= d->pcomp) {
@@ -249,6 +249,10 @@ FUN(compose) (ssz_t sa, const T *ma[sa], ssz_t sb, const T *mb[sb], T *mc[sa])
249249

250250
else compose(sa,ma, sb,mb, mc_, hi_ord, mo_ord);
251251

252+
#if DEBUG_COMPOSE
253+
printf("mc:\n"); print_damap(sa, TC mc_, 0);
254+
#endif
255+
252256
// copy back
253257
FOR(ia,sa) if (amc[ia]) {
254258
FUN(copy)(mc_[ia], mc[ia]);

src/madl_damap.mad

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -669,105 +669,6 @@ end
669669

670670
-- map logarithm of exponential poisson bracket: r = exp(:log(x):) y
671671

672-
local function fgrad (x, t)
673-
local r = t:same()
674-
for i=1,#x do r = r + x[i]*t:deriv(i) end
675-
return r
676-
end
677-
678-
local function liebra (x, y)
679-
local r = x:same()
680-
for i=1,#x do
681-
for j=1,#x do
682-
local t1 = y[j] * x[i]:deriv(j)
683-
local t2 = x[j] * y[i]:deriv(j)
684-
r[i] = r[i] + t2 - t1
685-
end end
686-
return r
687-
end
688-
689-
local function mnrm (x)
690-
local nrm = 0
691-
for i=1,#x do nrm = nrm + x[i]:nrm() end
692-
return nrm
693-
end
694-
695-
local function logpb (x, r, eps) -- c_logf + c_flofacg
696-
-- c_logf
697-
local x0 = x:copy():set0(0)
698-
699-
local fid = 1262 -- ..1289
700-
x0:write("fort/fort_n."..fid, "x0") ; fid = fid+1 ; -- 1263
701-
702-
-- c_flofacg
703-
local v = x:same():eye() -- identity
704-
705-
x0:write("fort/fort_n."..fid, "x") ; fid = fid+1 ; -- 1264
706-
707-
-- special case where eps = -no
708-
if eps and eps <= 0 then
709-
for k=1,round(eps)-1 do
710-
local y = (-r):exppb(x0)
711-
local t = y - v
712-
r = r+t
713-
714-
t:write("fort/fort_n."..fid, "t_0 @ "..k) ; fid = fid+1 ;
715-
r:write("fort/fort_n."..fid, "r_0 @ "..k) ; fid = fid+1 ;
716-
end
717-
return r
718-
end
719-
720-
local nrm0 = mnrm(x0)
721-
local epsone = eps or nrm0/1000
722-
local xn, xn0 = 1e4, 1e36
723-
local nrmax = 1000
724-
local conv = false
725-
726-
for k=1,nrmax do
727-
local y = (-r):exppb(x0)
728-
local t = y - v
729-
730-
t:write("fort/fort_n."..fid, "t_1 @ "..k) ; fid = fid+1 ; -- 1265
731-
732-
if xn < epsone then -- CBH (* == c_bra_v_ct)
733-
local e2, e3 = x:same(), x:same()
734-
for i=1,#x do e2[i] = -0.5*fgrad(t ,t[i]) end
735-
for i=1,#x do e3[i] = -0.5*fgrad(e2,t[i])-(1/6)*fgrad(t,e2[i]) end
736-
t = t+e2+e3
737-
738-
t:write("fort/fort_n."..fid, "t_2 @ "..k) ; fid = fid+1 ; -- 1266
739-
740-
local z = liebra(r,t) -- <r,t>
741-
local e2 = liebra(r,z) -- <r,<r,t>>
742-
local e3 = liebra(t,z) -- <t,<r,t>>
743-
t = t + 0.5*z + (1/12)*(e2-e3)
744-
745-
t:write("fort/fort_n."..fid, "t_3 @ "..k) ; fid = fid+1 ; -- 1267
746-
747-
local e4 = liebra(t,e2) -- <t,<r,<r,t>>>
748-
t = t - (1/24)*e4
749-
750-
t:write("fort/fort_n."..fid, "t_4 @ "..k) ; fid = fid+1 ; -- 1268
751-
752-
end
753-
r = r+t
754-
755-
r:write("fort/fort_n."..fid, "r_1 @ "..k) ; fid = fid+1 ;
756-
757-
local nrm = mnrm(t)
758-
xn = nrm/nrm0
759-
760-
print("xn=", xn, "epsone=", epsone, "nrm=", nrm, "nrm0=", nrm0)
761-
762-
-- same scheme as exppb
763-
if xn < 1e-14 or conv and xn >= xn0 then break end
764-
if xn < 1e-10 then conv = true end
765-
xn0 = xn
766-
end
767-
768-
return r
769-
end
770-
771672
function MR.logpb (x, y0, r)
772673
if is_string(r) and r == 'in' then r = x end -- in place
773674
r = r or map_alloc(x)
@@ -1259,7 +1160,6 @@ function MR.__pow (x, n, r)
12591160
if n == 0 then break end
12601161
t:compose(t,t) -- t = t^2
12611162
end
1262-
12631163
return r
12641164
end
12651165

0 commit comments

Comments
 (0)