summaryrefslogtreecommitdiff
path: root/sci-libs/linbox/files/linbox-1.7.0-gcc14.patch
blob: f35f1072955d433078182ce97ef298cff0761ae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
https://bugs.gentoo.org/930923
https://github.com/linbox-team/linbox/commit/b8f2d4ccdc0af4418d14f72caf6c4d01969092a3
https://src.fedoraproject.org/rpms/linbox/c/7389d46e81dc00dcb952b2ccbbbec3fb4fcc6c8b

From c614c401386ee8db014a9be56244888f7b282a18 Mon Sep 17 00:00:00 2001
From: Jean-Guillaume Dumas <Jean-Guillaume.Dumas@imag.fr>
Date: Fri, 26 Jan 2024 16:31:56 +0100
Subject: [PATCH] const_cast missing faster empty init

---
 linbox/algorithms/gauss/gauss-nullspace.inl   |  10 +-
 .../matrix/sparsematrix/sparse-ell-matrix.h   |   8 +-
 .../matrix/sparsematrix/sparse-ellr-matrix.h  |  18 +--
 linbox/ring/ntl/ntl-lzz_p.h                   |  11 +-
 linbox/ring/ntl/ntl-lzz_pe.h                  | 143 +++++++++---------
 linbox/ring/ntl/ntl-zz_px.h                   |   6 +
 6 files changed, 104 insertions(+), 92 deletions(-)

diff --git a/linbox/algorithms/gauss/gauss-nullspace.inl b/linbox/algorithms/gauss/gauss-nullspace.inl
index 0b70e1d7c..2d6032563 100644
--- a/linbox/algorithms/gauss/gauss-nullspace.inl
+++ b/linbox/algorithms/gauss/gauss-nullspace.inl
@@ -2,7 +2,7 @@
  * Copyright (C) LinBox 2008
  *
  * Written by Jean-Guillaume Dumas <Jean-Guillaume.Dumas@imag.fr>
- * Time-stamp: <27 Aug 20 15:17:09 Jean-Guillaume.Dumas@imag.fr>
+ * Time-stamp: <26 Jan 24 16:05:55 Jean-Guillaume.Dumas@imag.fr>
  *
  *
  * ========LICENCE========
@@ -104,11 +104,11 @@ namespace LinBox
 
 		Permutation<Field> P(field(),(int)Nj);
 
-		// A.write( std::cerr << "A:=", Tag::FileFormat::Maple ) << ';' << std::endl;
+// A.write( std::cerr << "A:=", Tag::FileFormat::Maple ) << ';' << std::endl;
 		this->InPlaceLinearPivoting(Rank, Det, A, P, Ni, Nj );
 
-		// P.write( std::cerr << "P:=", Tag::FileFormat::Maple ) << ';' << std::endl;
-		// A.write( std::cerr << "Ua:=", Tag::FileFormat::Maple ) << ';' << std::endl;
+// P.write( std::cerr << "P:=", Tag::FileFormat::Maple ) << ';' << std::endl;
+// A.write( std::cerr << "Ua:=", Tag::FileFormat::Maple ) << ';' << std::endl;
 
 		for(size_t i=0; i< Ni; ++i) {
 			if (A[i].size() == 0) {
@@ -123,7 +123,7 @@ namespace LinBox
 			}
 		}
 
-		// A.write( std::cerr << "Ub:=", Tag::FileFormat::Maple ) << ';' << std::endl;
+// A.write( std::cerr << "Ub:=", Tag::FileFormat::Maple ) << ';' << std::endl;
 
 		return this->nullspacebasis(x, Rank, A, P);
 	}
diff --git a/linbox/matrix/sparsematrix/sparse-ell-matrix.h b/linbox/matrix/sparsematrix/sparse-ell-matrix.h
index 59006d6c5..2604f47b8 100644
--- a/linbox/matrix/sparsematrix/sparse-ell-matrix.h
+++ b/linbox/matrix/sparsematrix/sparse-ell-matrix.h
@@ -1210,10 +1210,10 @@ namespace LinBox
 				_colid_beg = iter._colid_beg ;
 				_colid_it  = iter._colid_it ;
 				_data_it   = iter._data_it  ;
-				_data_beg  = iter._data_beg ;
-				_data_end  = iter._data_end  ;
-				_field     = iter._field ;
-				_ld        = iter._ld ;
+				const_cast<data_it>(_data_beg)  = iter._data_beg ;
+				const_cast<data_it>(_data_end)  = iter._data_end  ;
+				const_cast<Field &>(_field)     = iter._field ;
+				const_cast<size_t&>(ld)         = iter._ld ;
 				_row       = iter._row ;
 
 				return *this;
diff --git a/linbox/matrix/sparsematrix/sparse-ellr-matrix.h b/linbox/matrix/sparsematrix/sparse-ellr-matrix.h
index 498a5525d..a60943868 100644
--- a/linbox/matrix/sparsematrix/sparse-ellr-matrix.h
+++ b/linbox/matrix/sparsematrix/sparse-ellr-matrix.h
@@ -1102,11 +1102,11 @@ namespace LinBox
 			_Iterator &operator = (const _Iterator &iter)
 			{
 				_data_it  = iter._data_it  ;
-				_data_beg  = iter._data_beg  ;
-				_data_end  = iter._data_end  ;
-				_field  = iter._field  ;
-				_rowid = iter._rowid;
-				_ld = iter._ld ;
+				const_cast<element_iterator>(_data_beg) = iter._data_beg  ;
+				const_cast<element_iterator>(_data_end)= iter._data_end  ;
+				const_cast<Field &>(_field) = iter._field  ;
+				const_cast<std::vector<size_t>&>(_rowid) = iter._rowid;
+				const_cast<size_t&>(ld) = iter._ld ;
 				_row = iter._row ;
 
 				return *this;
@@ -1252,10 +1252,10 @@ namespace LinBox
 				_colid_beg = iter._colid_beg ;
 				_colid_it  = iter._colid_it ;
 				_data_it   = iter._data_it  ;
-				_data_beg  = iter._data_beg ;
-				_data_end  = iter._data_end  ;
-				_field     = iter._field ;
-				_ld        = iter._ld ;
+				const_cast<data_it>(_data_beg) = iter._data_beg ;
+				const_cast<data_it>(_data_end) = iter._data_end  ;
+				const_cast<Field &>(_field)    = iter._field ;
+				const_cast<size_t&>(ld)= iter._ld ;
 				_row       = iter._row ;
 
 				return *this;
diff --git a/linbox/ring/ntl/ntl-lzz_p.h b/linbox/ring/ntl/ntl-lzz_p.h
index 201baaa35..def3a23f7 100644
--- a/linbox/ring/ntl/ntl-lzz_p.h
+++ b/linbox/ring/ntl/ntl-lzz_p.h
@@ -85,7 +85,7 @@ namespace Givaro
          * @param x reference to Integer to contain output (reference returned).
          * @param y constant reference to field element.
          */
- 	template <>
+    template <>
 	Integer& Caster(Integer& x, const NTL::zz_p& y)
 	{
 		return x = int64_t(rep(y));
@@ -130,7 +130,7 @@ namespace LinBox
 		typedef NTL::zz_p Element ;
 		typedef Givaro::UnparametricOperations<Element> Father_t ;
 		typedef UnparametricRandIter<NTL::zz_p> RandIter;
-		
+
 		const Element zero,one,mOne ;
 
 
@@ -145,6 +145,11 @@ namespace LinBox
 			,zero( NTL::to_zz_p(0)),one( NTL::to_zz_p(1)),mOne(-one)
             {}
 
+		Element &init (Element &x) const
+            {
+                return x = NTL::to_zz_p(0);
+            }
+
 		Element& init(Element& x, const double& y) const
             {
                 double z = fmod(y,(double)Element::modulus());
@@ -153,7 +158,7 @@ namespace LinBox
                 return x = NTL::to_zz_p(static_cast<long>(z)); //rounds towards 0
             }
 
-		Element &init (Element &x, const integer &y=0) const
+		Element &init (Element &x, const integer &y) const
             {
                 NTL::ZZ tmp= NTL::to_ZZ(std::string(y).data());
                 return x = NTL::to_zz_p(tmp);
diff --git a/linbox/ring/ntl/ntl-lzz_pe.h b/linbox/ring/ntl/ntl-lzz_pe.h
index 60b132a06..d53444b69 100644
--- a/linbox/ring/ntl/ntl-lzz_pe.h
+++ b/linbox/ring/ntl/ntl-lzz_pe.h
@@ -96,18 +96,18 @@ namespace LinBox
 			NTL::zz_pE::init(irredPoly);
 			_f = irredPoly;
 		}
-		
+
 		NTL_zz_pE_Initialiser( const Integer & p, const NTL::zz_pX & f) {
 			NTL::zz_p::init((int64_t) p);
 			NTL::zz_pE::init(f);
 			_f = f;
 		}
-		
+
 		NTL_zz_pE_Initialiser(const NTL::zz_pX &f) {
 			NTL::zz_pE::init(f);
 			_f = f;
 		}
-		
+
 		const NTL::zz_pX& modulus() const {
 			return _f;
 		}
@@ -143,22 +143,22 @@ namespace LinBox
 		NTL_zz_pE (const integer &p, const integer &k) :
                 NTL_zz_pE_Initialiser(p,k),Father_t ()
         {
-        	init(const_cast<Element &>(zero), 0);
-		 	init(const_cast<Element &>(one), 1);
-		 	init(const_cast<Element &>(mOne), p-1);
+            init(const_cast<Element &>(zero), 0);
+            init(const_cast<Element &>(one), 1);
+            init(const_cast<Element &>(mOne), p-1);
 		}
-        
+
 		NTL_zz_pE (const integer &p, const NTL::zz_pX &f) :
                 NTL_zz_pE_Initialiser(p,f), Father_t()
         {
             init(const_cast<Element &>(zero), 0);
-		 	init(const_cast<Element &>(one), 1);
-		 	init(const_cast<Element &>(mOne), p-1);
+            init(const_cast<Element &>(one), 1);
+            init(const_cast<Element &>(mOne), p-1);
         }
-        
+
         NTL_zz_pE(const NTL_zz_pE &F) :
-        	NTL_zz_pE_Initialiser(F.modulus()), Father_t(),
-        	zero(NTL::to_zz_pE(0)), one(NTL::to_zz_pE(1)), mOne(-one)
+                NTL_zz_pE_Initialiser(F.modulus()), Father_t(),
+                zero(NTL::to_zz_pE(0)), one(NTL::to_zz_pE(1)), mOne(-one)
 		{
         }
 
@@ -182,15 +182,15 @@ namespace LinBox
 
 		bool isUnit (const Element& x) const
             {
-            	if (isZero(x)) {
-            		return false;
-            	} 
-            	
-            	NTL::zz_pX g, tmp;
-            	tmp = NTL::conv<NTL::zz_pX>(x);
-            	NTL::GCD(g, tmp, modulus());
-            	
-            	return g == 1;
+                if (isZero(x)) {
+                    return false;
+                }
+
+                NTL::zz_pX g, tmp;
+                tmp = NTL::conv<NTL::zz_pX>(x);
+                NTL::GCD(g, tmp, modulus());
+
+                return g == 1;
             }
 
 		bool isMOne (const Element& x) const
@@ -207,7 +207,9 @@ namespace LinBox
 			return f;
             }
 
-		Element & init(Element & x, integer n = 0) const
+		Element & init(Element & x) const { return x; }
+
+		Element & init(Element & x, integer n) const
             {   // assumes n >= 0.
                 int e = exponent();
                 n %= cardinality();
@@ -215,14 +217,14 @@ namespace LinBox
                     //write(std::cout << "init-ed ", x) << std::endl;
                 return x;
             }
-        
+
         // documentation of NTL::conv:
         // http://www.shoup.net/ntl/doc/conversions.txt
         // XXX = long, ZZ, ZZ_p, ZZ_pE, ZZ_pX
         template<class XXX>
         Element &init(Element &x, const XXX &y) const {
-        	x = NTL::conv<NTL::zz_pE>(y);
-        	return x;
+            x = NTL::conv<NTL::zz_pE>(y);
+            return x;
         }
 
         integer & convert(integer & x, const Element & y) const
@@ -279,81 +281,80 @@ namespace LinBox
                 x=one/x;
                 return x;
             }
-        
+
         Element& div(Element &x, const Element &y, const Element &z) const {
-        	NTL::zz_pX g, zx;
-        	conv(zx, z);
-        	NTL::GCD(g, zx, modulus());
-        	
-        	NTL::zz_pE zg;
-        	conv(zg, zx / g);
-        	x = NTL::conv<NTL::zz_pE>(NTL::conv<NTL::zz_pX>(y) / g);
-        	x /= zg;
-        	
-        	return x;
+            NTL::zz_pX g, zx;
+            conv(zx, z);
+            NTL::GCD(g, zx, modulus());
+
+            NTL::zz_pE zg;
+            conv(zg, zx / g);
+            x = NTL::conv<NTL::zz_pE>(NTL::conv<NTL::zz_pX>(y) / g);
+            x /= zg;
+
+            return x;
         }
-        
+
         Element& divin(Element &x, const Element &y) const {
-        	Element r;
-        	div(r, x, y);
-        	return x = r;
+            Element r;
+            div(r, x, y);
+            return x = r;
         }
 
         bool isDivisor(const Element &x, const Element &y) const {
-        	if (isZero(y)) {
-        		return false;
-        	}
-        	
-        	if (isUnit(y)) {
-        		return true;
-        	}
-        	
-        	NTL::zz_pX a, b;
-        	conv(a, x);
-        	conv(b, y);
-        	
-        	NTL::zz_pX ga, gb;
-        	NTL::GCD(ga, a, modulus());
-        	NTL::GCD(gb, b, modulus());
-        	
-        	NTL::zz_pX r;
-        	r = ga % gb;
-        	return isZero(NTL::conv<Element>(r));
+            if (isZero(y)) {
+                return false;
+            }
+
+            if (isUnit(y)) {
+                return true;
+            }
+
+            NTL::zz_pX a, b;
+            conv(a, x);
+            conv(b, y);
+
+            NTL::zz_pX ga, gb;
+            NTL::GCD(ga, a, modulus());
+            NTL::GCD(gb, b, modulus());
+            NTL::zz_pX r;
+            r = ga % gb;
+            return isZero(NTL::conv<Element>(r));
         }
-		
+
 		Element& gcd(Element &g, const Element &a, const Element &b) const {
 			NTL::zz_pX r1, r2, x, y;
 			conv(x, a);
 			conv(y, b);
-			
+
 			NTL::GCD(r1, x, modulus());
 			NTL::GCD(r2, y, r1);
-			
+
 			return g = NTL::conv<Element>(r2);
 		}
-		
+
 		Element& gcdin(Element &a, const Element &b) const {
 			NTL::zz_pE g;
 			gcd(g, a, b);
 			return a = g;
 		}
-		
+
 		Element& dxgcd(Element &g, Element &s, Element &t, Element &u, Element &v, const Element &a, const Element &b) const {
 			NTL::zz_pX gx, sx, tx, ux, vx, ax, bx;
 			conv(ax, a);
 			conv(bx, b);
-			
+
 			NTL::XGCD(gx, sx, tx, ax, bx);
-			
+
 			ux = ax / gx;
 			vx = bx / gx;
-			
+
 			conv(g, gx);
 			conv(s, sx);
 			conv(t, tx);
 			conv(u, ux);
 			conv(v, vx);
-			
+
 			return g;
 		}
 
@@ -364,12 +365,12 @@ namespace LinBox
                 x=NTL::to_zz_pE(tmp);
                 return is;
             }
-            
+
 		std::ostream& write( std::ostream& os ) const
             {
                 return os << "Polynomial quotient ring using NTL::zz_pE";
             }
-            
+
 		std::ostream& write( std::ostream& os, const Element& x) const {
 			os << x;
 			return os;
@@ -429,7 +430,7 @@ namespace LinBox
 		uint64_t _seed;
         const NTL_zz_pE& _ring;
 	}; // class UnparametricRandIters
-	
+
 } // LinBox
 
 #endif //__LINBOX_ntl_lzz_pe_H
diff --git a/linbox/ring/ntl/ntl-zz_px.h b/linbox/ring/ntl/ntl-zz_px.h
index 6e7d5b2fd..340df9f95 100644
--- a/linbox/ring/ntl/ntl-zz_px.h
+++ b/linbox/ring/ntl/ntl-zz_px.h
@@ -104,6 +104,12 @@ namespace LinBox
 			,_CField(cf)
 		{}
 
+		/** Initialize p to 0 */
+		Element& init( Element& p ) const
+		{
+			return p = 0;
+		}
+
 		/** Initialize p to the constant y (p = y*x^0) */
 		template <class ANY>
 		Element& init( Element& p, const ANY& y ) const
-- 
2.43.0