# Singular

##### 7.7.1.0. CompDecomp
Procedure from library `bimodules.lib` (see bimodules_lib).

Usage:
CompDecomp(p); p poly

Note:
This procedure only works if the basering is an enveloping algebra A^{env} of a (non-commutative) ring A. Thus also the polynomial in the argument has to be in A^{env}.

Return:
Returns an ideal I in A^{env}, where the sum of all terms of the argument with the same right side (of the tensor summands) are stored as a generator of I.
Let b != c, then for p = (a (X) b) + (c (X) b) + (a (X) c) the ideal I := CompDecomp(p) is given by: I[1] = (a (X) b) + (c (X) b); I[2] = a (X) c.

Purpose:
By decomposing the polynomial we can easily check whether the given polynomial is a pure tensor.

Example:
 ```LIB "bimodules.lib"; ring r = 0,(x,s),dp; def R = nc_algebra(1,s); setring R; //1st shift algebra def Re = envelope(R); setring Re; //basering is now R^{env} = R (X) R^{opp} poly f = X*S*x^2+5*x*S*X+S*X; f; ==> x2SX+x2S+5xSX+SX ideal I = CompDecomp(f); print(matrix(I)); // what means that f = (x2+5x+1)*SX + x2*S ==> x2SX+5xSX+SX,x2S poly p = x*S+X^2*S+2*s+x*X^2*s+5*x*s; p; ==> xsX2+5xs+xS+2s+SX2+2SX+S ideal Q = CompDecomp(p); print(matrix(Q)); ==> xsX2,5xs+2s,xS+S,SX2,2SX ```