Singular

D.5.10.2 truncateFast

Procedure from library `sheafcoh.lib` (see sheafcoh_lib).

Usage:
truncateFast(M,d); M module, d int

Assume:
`M` is graded, and it comes assigned with an admissible degree vector as an attribute 'isHomog'

Return:
module

Note:
Output is a presentation matrix for the truncation of coker(M) at d.
Fast + experimental version. M shoud be a SB!

Display:
If `printlevel`>=1, step-by step timings will be printed. If `printlevel`>=2 we add progress debug messages if `printlevel`>=3, even all intermediate results...

Example:
 ```LIB "sheafcoh.lib"; ring R=0,(x,y,z,u,v),dp; module M=maxideal(3); homog(M); ==> 1 // compute presentation matrix for truncated module (R/^3)_(>=2) int t=timer; module M2t=truncate(M,2); t = timer - t; "// Simple truncate: ", t; ==> // Simple truncate: 0 t=timer; module M2=truncateFast(std(M),2); t = timer - t; "// Fast truncate: ", t; ==> // Fast truncate: 0 print(M2); ==> v,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,z, 0, 0,\ 0, 0, ==> 0, 0, 0, 0, 0,0,0,0,0,0,y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,x, 0,\ 0, 0, ==> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ==> 0,v,0,0,0,0,0,0,0,0,0,0,0,0,0,-v,u, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0, z, 0,\ 0, 0, ==> 0, 0, 0, 0, 0,0,0,0,0,0,0, y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, x,\ 0, 0, ==> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ==> 0,0,v,0,0,0,0,0,0,0,0,0,0,0,0,0, 0, u, 0, 0, 0,0,0,0,0,0,0,0,0,0,-v,0, z,\ 0, 0, ==> 0, 0, 0, 0, 0,0,0,0,0,0,0, 0, y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0,\ x, 0, ==> 0, 0, 0, 0, 0, 0, 0, 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, 0,0,0,0,0,0,0,0,u,0,0, 0, 0,\ 0, 0, ==> 0, 0, 0, 0, 0,0,0,0,z,0,0, 0, 0, 0, -v,0, 0, 0, -u,0, 0, -z,0,y,0,0, 0,\ 0, -v, ==> 0, 0, 0, -u,0, 0, -z,0, -y,x, 0, ==> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,v,0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,u,0, 0, 0,\ 0, 0, ==> 0, 0, 0, 0, 0,0,0,0,0,z,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,y,0, 0,\ 0, 0, ==> -v,0, 0, 0, -u,0, 0, -z,0, -y,x "// Check: M2t == M2?: ", size(NF(M2, std(M2t))) + size(NF(M2t, std(M2))); ==> // Check: M2t == M2?: 0 dimGradedPart(M2,1); ==> 0 dimGradedPart(M2,2); ==> 15 // this should coincide with: dimGradedPart(M,2); ==> 15 // shift grading by 1: intvec v=1; attrib(M,"isHomog",v); t=timer; M2t=truncate(M,2); t = timer - t; "// Simple truncate: ", t; ==> // Simple truncate: 0 t=timer; M2=truncateFast(std(M),2); t = timer - t; "// Fast truncate: ", t; ==> // Fast truncate: 0 print(M2); ==> u, z, 0, y, 0, 0, x, 0, 0, 0, v2,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\ , 0, ==> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ==> -v,0, z, 0, y, 0, 0, x, 0, 0, 0, v2,0, 0, 0, uv,0, 0, 0, 0, 0, 0, 0, 0, 0\ , u2, ==> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ==> 0, -v,-u,0, 0, y, 0, 0, x, 0, 0, 0, v2,0, 0, 0, uv,0, 0, zv,0, 0, 0, 0, 0\ , 0, ==> u2,0, 0, zu,0, 0, 0, 0, 0, z2,0, 0, 0, 0, 0, 0, 0, 0, 0, ==> 0, 0, 0, -v,-u,-z,0, 0, 0, x, 0, 0, 0, v2,0, 0, 0, uv,0, 0, zv,0, yv,0, 0\ , 0, ==> 0, u2,0, 0, zu,0, yu,0, 0, 0, z2,0, yz,0, 0, y2,0, 0, 0, ==> 0, 0, 0, 0, 0, 0, -v,-u,-z,-y,0, 0, 0, 0, v2,0, 0, 0, uv,0, 0, zv,0, yv,x\ v,0, ==> 0, 0, u2,0, 0, zu,0, yu,xu,0, 0, z2,0, yz,xz,0, y2,xy,x2 "// Check: M2t == M2?: ", size(NF(M2, std(M2t))) + size(NF(M2t, std(M2))); //? ==> // Check: M2t == M2?: 20 dimGradedPart(M2,3); ==> 15 ```