My Project
Loading...
Searching...
No Matches
Macros | Functions
semic.cc File Reference
#include "kernel/mod2.h"
#include <stdio.h>
#include <string.h>
#include "misc/intvec.h"
#include "misc/mylimits.h"
#include "kernel/spectrum/GMPrat.h"
#include "kernel/spectrum/semic.h"

Go to the source code of this file.

Macros

#define SEMIC_CC
 

Functions

spectrum operator+ (const spectrum &s1, const spectrum &s2)
 
spectrum operator* (int k, const spectrum &spec)
 
ostream & operator<< (ostream &s, const spectrum &spec)
 

Macro Definition Documentation

◆ SEMIC_CC

#define SEMIC_CC

Definition at line 8 of file semic.cc.

Function Documentation

◆ operator*()

spectrum operator* ( int  k,
const spectrum spec 
)

Definition at line 219 of file semic.cc.

220{
221 if( k == 0 )
222 {
224
225 return result;
226 }
227 else
228 {
229 spectrum result( spec );
230
231 result.mu *= k;
232 result.pg *= k;
233
234 for( int i=0; i<result.n; i++ )
235 {
236 result.w[i] *= k;
237 }
238
239 return result;
240 }
241}
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
Definition: semic.h:64
return result
Definition: facAbsBiFact.cc:75

◆ operator+()

spectrum operator+ ( const spectrum s1,
const spectrum s2 
)

Definition at line 134 of file semic.cc.

135{
136 int i1=0, i2=0, i3=0;
137
139
140 do
141 {
142 if( i1 >= s1.n )
143 {
144 i2++;
145 }
146 else if( i2 >= s2.n )
147 {
148 i1++;
149 }
150 else if( s1.s[i1] < s2.s[i2] )
151 {
152 i1++;
153 }
154 else if( s1.s[i1] == s2.s[i2] )
155 {
156 i1++;
157 i2++;
158 }
159 else
160 {
161 i2++;
162 }
163 i3++;
164 }
165 while( i1 < s1.n || i2 < s2.n );
166
167 result.copy_new( i3 );
168 result.n = i3;
169
170 i1 = i2 = i3 = 0;
171
172 do
173 {
174 if( i1 >= s1.n )
175 {
176 result.s[i3] = s2.s[i2];
177 result.w[i3] = s2.w[i2];
178 i2++;
179 }
180 else if( i2 >= s2.n )
181 {
182 result.s[i3] = s1.s[i1];
183 result.w[i3] = s1.w[i1];
184 i1++;
185 }
186 else if( s1.s[i1] < s2.s[i2] )
187 {
188 result.s[i3] = s1.s[i1];
189 result.w[i3] = s1.w[i1];
190 i1++;
191 }
192 else if( s1.s[i1] == s2.s[i2] )
193 {
194 result.s[i3] = s1.s[i1];
195 result.w[i3] = s1.w[i1] + s2.w[i2];
196 i1++;
197 i2++;
198 }
199 else
200 {
201 result.s[i3] = s2.s[i2];
202 result.w[i3] = s2.w[i2];
203 i2++;
204 }
205 i3++;
206 }
207 while( i1 < s1.n || i2 < s2.n );
208
209 result.mu = s1.mu + s2.mu;
210 result.pg = s1.pg + s2.pg;
211
212 return result;
213}
int mu
Definition: semic.h:67
Rational * s
Definition: semic.h:70
int n
Definition: semic.h:69
int pg
Definition: semic.h:68
int * w
Definition: semic.h:71

◆ operator<<()

ostream & operator<< ( ostream &  s,
const spectrum spec 
)

Definition at line 249 of file semic.cc.

250{
251 for( int i=0; i<spec.n; i++ )
252 {
253 if( i>0 )
254 {
255 #ifdef SEMIC_STDOUT
256 s << "+";
257 #else
258 fprintf( stdout,"+" );
259 #endif
260 }
261
262 #ifdef SEMIC_STDOUT
263 s << spec.w[i] << "*t^";
264 #else
265 fprintf( stdout,"%d*t^",spec.w[i] );
266 #endif
267
268 s << spec.s[i];
269 }
270
271 return s;
272}
const CanonicalForm int s
Definition: facAbsFact.cc:51