MCPcopy Create free account
hub / github.com/Singular/Singular / id_SimpleAdd

Function id_SimpleAdd

libpolys/polys/simpleideals.cc:789–827  ·  view source on GitHub ↗

concat the lists h1 and h2 without zeros

Source from the content-addressed store, hash-verified

787
788/// concat the lists h1 and h2 without zeros
789ideal id_SimpleAdd (ideal h1,ideal h2, const ring R)
790{
791 id_Test(h1, R);
792 id_Test(h2, R);
793
794 if ( idIs0(h1) )
795 {
796 ideal res=id_Copy(h2,R);
797 if (res->rank<h1->rank) res->rank=h1->rank;
798 return res;
799 }
800 if ( idIs0(h2) )
801 {
802 ideal res=id_Copy(h1,R);
803 if (res->rank<h2->rank) res->rank=h2->rank;
804 return res;
805 }
806
807 int j = IDELEMS(h1)-1;
808 while ((j >= 0) && (h1->m[j] == NULL)) j--;
809
810 int i = IDELEMS(h2)-1;
811 while ((i >= 0) && (h2->m[i] == NULL)) i--;
812
813 const int r = si_max(h1->rank, h2->rank);
814
815 ideal result = idInit(i+j+2,r);
816
817 int l;
818
819 for (l=j; l>=0; l--)
820 result->m[l] = p_Copy(h1->m[l],R);
821
822 j = i+j+1;
823 for (l=i; l>=0; l--, j--)
824 result->m[j] = p_Copy(h2->m[l],R);
825
826 return result;
827}
828
829/// insert h2 into h1 (if h2 is not the zero polynomial)
830/// return TRUE iff h2 was indeed inserted

Callers 6

id_AddFunction · 0.85
rSumInternalFunction · 0.85
idPrepare_printFunction · 0.85
idPrepareFunction · 0.85
id_Sat_principalFunction · 0.85
hFirstSeries0pFunction · 0.85

Calls 5

idIs0Function · 0.85
id_CopyFunction · 0.85
si_maxFunction · 0.85
idInitFunction · 0.85
p_CopyFunction · 0.85

Tested by

no test coverage detected