473,834 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code optimization (calc PI)

mm
(Yes, I konw whats an object is...)
BTW. I did a translation of a pi callculation programm in C to Python.
(Do it by your own... ;-)
--------
Calc PI for 800 digs(?). (german: Stellen)
------
int a=10000,b,c=280 0,d,e,f[2801],g;main(){for(; b-c;)f[b++]=a/5;
for(;d=0,g=c*2; c-=14,printf("%.4 d",e+d/a),e=d%a)for(b= c;d+=f[b]*a,
f[b]=d%--g,d/=g--,--b;d*=b);}

$ ./a.exe
314159265358979 323846264338327 950288419716939 937510582097494 459230781640628 62089
986280348253421 170679821480865 132823066470938 446095505822317 253594081284811 17450
284102701938521 105559644622948 954930381964428 810975665933446 128475648233786 78316
527120190914564 856692346034861 045432664821339 360726024914127 372458700660631 55881
748815209209628 292540917153643 678925903600113 305305488204665 213841469519415 11609
433057270365759 591953092186117 381932611793105 118548074462379 962749567351885 75272
489122793818301 194912983367336 244065664308602 139494639522473 719070217986094 37027
705392171762931 767523846748184 676694051320005 681271452635608 277857713427577 89609
173637178721468 440901224953430 146549585371050 792279689258923 542019956112129 02196
086403441815981 362977477130996 051870721134999 999837297804995 105973173281609 63185
--------

But Python is much slower here then C here. I used a while-loop within a
while-loop. Not that much calculation here.
Jan 3 '07
21 2603

Ok, here is the code. It is a translation of the following code, found
on the internet.

* The C is very fast, Python not.
* Target: Do optimization, that Python runs nearly like C.
Auf 800 Stellen in 160 Zeichen...
------
int a=10000,b,c=280 0,d,e,f[2801],g;main(){for(; b-c;)f[b++]=a/5;
for(;d=0,g=c*2; c-=14,printf("%.4 d",e+d/a),e=d%a)for(b= c;d+=f[b]*a,
f[b]=d%--g,d/=g--,--b;d*=b);}

$ ./a.exe
314159265358979 323846264338327 950288419716939 937510582097494 459230781640628 62089
986280348253421 170679821480865 132823066470938 446095505822317 253594081284811 17450
284102701938521 105559644622948 954930381964428 810975665933446 128475648233786 78316
527120190914564 856692346034861 045432664821339 360726024914127 372458700660631 55881
748815209209628 292540917153643 678925903600113 305305488204665 213841469519415 11609
433057270365759 591953092186117 381932611793105 118548074462379 962749567351885 75272
489122793818301 194912983367336 244065664308602 139494639522473 719070217986094 37027
705392171762931 767523846748184 676694051320005 681271452635608 277857713427577 89609
173637178721468 440901224953430 146549585371050 792279689258923 542019956112129 02196
086403441815981 362977477130996 051870721134999 999837297804995 105973173281609 63185

Here the Python:
----------------------------------------------------
#!/usr/bin/python
# -*- coding: utf-8 -*-

## http://de.wikipedia.org/wiki/Pi_(Kreiszahl)
from __future__ import division
from array import array
import decimal
import time
#int a=10000,b,c=280 0,d,e,f[2801],g;main(){for(; b-c;)f[b++]=a/5;
# for(;d=0,g=c*2; c-=14,printf("%.4 d",e+d/a),e=d%a)for(b= c;d+=f[b]*a,
# f[b]=d%--g,d/=g--,--b;d*=b);}
#
print "\nTiming a 1 million loop 'for loop' ..."
start = time.clock()
for x in range(1000000):
y = x # do something
end = time.clock()
print "Time elapsed = ", end - start, "seconds"
start_prg = time.clock()
#pi=[] ## create an empty array
pi=''

a=10000
b=0
c=5600 ## c=2800
d=0
e=0
f=[] # f[2801]
g=0
counter=c
while 0<=counter+4000 :
f.append(2000) # f.append( int(a/5) )
counter=counter-1
# b=b+1

#print "DEBUG: b counter: ", b, counter
while (c*2):
d=0

g=c*2 ## see while condition
## ---------------------------
b=c ## anzahl elemente
#print "DEBUG: before 3 while loop..."
#print "DEBUG: b=", b
while (b-1):
d = d + f[b]*a
g=g-1
f[b] = d%g
d = int(d/g) ## needs cast to int
g=g-1

d=d*b

b=b-1 ## see while condition

#print "DEBUG: d=", d
c = c-14;
#pi.append(str( "%04d" % int(e + d/a))) # append to it
pi = pi + str("%04d" % int(e + d/a))
#print "%04d" % int(e + d/a),
## need cast to int
#print int(e + int(d/a))
e = d%a;

#print "".join(pi)
print pi

end_prg = time.clock()
print "Total Time elapsed = ", end_prg - start_prg, "seconds"
## EOF.
-------------------------------

Matimus wrote:
>>If someone is really interested in speed optimization, I can publish my
PI-calc code.


I wouldn't mind seeing it. Chances are you will get much better help if
you post your code anyway.

-Matt
Jan 4 '07 #11
At Wednesday 3/1/2007 22:10, Michael M. wrote:
>Ok, here is the code. It is a translation of the following code, found
on the internet.

* The C is very fast, Python not.
* Target: Do optimization, that Python runs nearly like C.
Why? Python is strong in other aspects, *not* on computation speed.

Anyway, for a nice and rather fast Python implementation (yielding
unlimited digits *without* unlimited storage), see
http://mail.python.org/pipermail/pyt...er/414347.html
The code, for reference:

def pi():
k, a, b, a1, b1 = 2, 4, 1, 12, 4
while 1:
# Next approximation
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
# Yield common digits
d, d1 = a/b, a1/b1
while d == d1:
yield str(d)
a, a1 = 10*(a%b), 10*(a1%b1)
d, d1 = a/b, a1/b1

import sys
sys.stdout.writ elines(pi())

(The converted C code does a lot of nonsense in Python terms - maybe
you should try to interpret *what* it does and then reimplement that
using Python)
--
Gabriel Genellina
Softlab SRL


_______________ _______________ _______________ _____
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 4 '07 #12
Michael M.:
* The C is very fast, Python not.
* Target: Do optimization, that Python runs nearly like C.
Python can't be fast as C for that kind of programs.
Note that your original C program gives less digits than the Python
program.
Your original takes about ~15.2 s on my PC. The following version (I
have just cleaned it up a bit, probably it can be improved) needs about
~0.7 seconds with Psyco and ~5.7 s without (Psyco compilation time and
Python startup times aren't included, if you include them the timings
are ~0.94 s and ~5.96 s).
Compiled with ShedSkin this program needs ~0.29 s (redirecting the
output to a file, because ShedSkin printing is slow still).
from time import clock

def compute_pi():
pi = []
a = 10000
b = d = e = g = 0
c = 5600
f = [2000] * (c + 4000 + 1)
while c:
d = 0
g = c * 2
b = c
while b 1:
d += f[b] * a
g -= 1
f[b] = d % g
d = d // g
g -= 1
d *= b
b -= 1
c -= 14
pi.append("%04d " % int(e + d // a))
e = d % a
return "".join(pi)

import psyco; psyco.bind(comp ute_pi)
start_time = clock()
print compute_pi()
print "Total time elapsed:", round(clock() - start_time, 2), "s"

Bye,
bearophile

Jan 4 '07 #13
On Thu, 04 Jan 2007 02:10:44 +0100, Michael M. wrote:
print "\nTiming a 1 million loop 'for loop' ..."
start = time.clock()
for x in range(1000000):
y = x # do something
Why not "pass # do nothing"?

end = time.clock()
print "Time elapsed = ", end - start, "seconds"
Are you aware that you're timing the CREATION of a rather large list, as
well as the loop?

[snip code]
#print "".join(pi)
print pi

end_prg = time.clock()
and also the time taken for I/O printing the digits? That can be quite
slow.

For timing functions and small snippets of code, you should investigate
the timeit module. It is very flexible, and will often give more accurate
results than roll-you-own timing.

For example:
>>import timeit
t = timeit.Timer("f or i in range(1000000): pass", "pass")
t.timeit(10 0) # time the loop one hundred times
29.367985010147 095

Now compare it to the speed where you only create the list once.
>>t = timeit.Timer("f or i in L: pass", "L = range(1000000)" )
t.timeit(10 0)
16.155359983444 214
--
Steven D'Aprano

Jan 4 '07 #14

Michael M. wrote:
Ok, here is the code. It is a translation of the following code, found
on the internet.

* The C is very fast, Python not.
* Target: Do optimization, that Python runs nearly like C.
There is an error in the translated code. It returns 1600 digits
instead of 800 digits.
>
counter=c
while 0<=counter+4000 :
f.append(2000) # f.append( int(a/5) )
counter=counter-1
# b=b+1
This creates a list f with length 9601. It should have a length of
2801.

I found an explanation of the original C program at
http://rooster.stanford.edu/~ben/maths/pi/code.html

Using the variable names from the above explanation and editing the
code posted by bearophile to match the explanation, I have the
following:

from time import clock

def compute_pi():
pi = []
a = 10000
i = k = b = d = c = 0
k = 2800
r = [2000] * 2801
while k:
d = 0
i = k
while True:
d += r[i] * a
b = 2 * i - 1
r[i] = d % b
d //= b
i -= 1
if i == 0: break
d *= i
k -= 14
pi.append("%04d " % int(c + d // a))
c = d % a
return "".join(pi)

start_time = clock()
pi = compute_pi()
print pi
print "Total time elapsed:", round(clock() - start_time, 2), "s"
print len(pi)

You're original version takes 2.8 seconds on my computer. The above
version takes .36 seconds. I tried a couple of optimizations but
couldn't make any more improvements.

casevh

Jan 4 '07 #15
In <cu************ ***@nntpserver. swip.net>, Michael M. wrote:
* The C is very fast, Python not.
* Target: Do optimization, that Python runs nearly like C.
As someone else already asked: Why? You can't beat a compiled to machine
code language with an interpreted one when doing integer arithmetic.
counter=c
while 0<=counter+4000 :
f.append(2000) # f.append( int(a/5) )
counter=counter-1
# b=b+1
Why do you count so complicated here? It's hard to see that this creates
a list with 2801 elements.
d = int(d/g) ## needs cast to int
Instead of converting the numbers to float by "real" division and then
converting back the result you should do integer division:

d = d // g

or

d //= g
pi = pi + str("%04d" % int(e + d/a))
The `str()` call is unnecessary. And again: try to stick to integer
arithmetic with ``//``.

Here is my attempt to convert the C code, not written with speed in mind
and I was too lazy too time it. :-)

from itertools import izip

def pi():
result = list()
d = 0
e = 0
f = [2000] * 2801
for c in xrange(2800, 0, -14):
for b, g in izip(xrange(c, 1, -1), xrange((c * 2) - 1, 0, -2)):
d += f[b] * 10000
h, f[b] = divmod(d, g)
d = h * b
h, i = divmod(d, 10000)
result.append(' %.4d' % (e + h))
e = i
return ''.join(result)

Ciao,
Marc 'BlackJack' Rintsch
Jan 4 '07 #16
Here is my attempt to convert the C code, not written with speed in mind
and I was too lazy too time it. :-)

from itertools import izip

def pi():
result = list()
d = 0
e = 0
f = [2000] * 2801
for c in xrange(2800, 0, -14):
for b, g in izip(xrange(c, 1, -1), xrange((c * 2) - 1, 0, -2)):
d += f[b] * 10000
h, f[b] = divmod(d, g)
d = h * b
h, i = divmod(d, 10000)
result.append(' %.4d' % (e + h))
e = i
return ''.join(result)
Your version: .36 seconds

It's ugly, but unrolling the divmod into two separate statements is
faster for small operands. The following takes .28 seconds:

from time import clock
from itertools import izip

def pi():
result = list()
d = 0
e = 0
f = [2000] * 2801
for c in xrange(2800, 0, -14):
for b, g in izip(xrange(c, 1, -1), xrange((c * 2) - 1, 0, -2)):
d += f[b] * 10000
f[b] = d % g
h = d // g
d = h * b
h, i = divmod(d, 10000)
result.append(' %.4d' % (e + h))
e = i
return ''.join(result)

start_time = clock()
pi = pi()
print pi
print "Total time elapsed:", round(clock() - start_time, 2), "s"
print len(pi)

casevh

Jan 4 '07 #17
mm <mi*****@mustun .chwrote:
(Yes, I konw whats an object is...)
BTW. I did a translation of a pi callculation programm in C to Python.
(Do it by your own... ;-)
Calc PI for 800 digs(?). (german: Stellen)
int a=10000,b,c=280 0,d,e,f[2801],g;main(){for(; b-c;)f[b++]=a/5;
for(;d=0,g=c*2; c-=14,printf("%.4 d",e+d/a),e=d%a)for(b= c;d+=f[b]*a,
f[b]=d%--g,d/=g--,--b;d*=b);}
Below you'll find my translation. Note that I improved the algorithm
greatly. Note the nice easy to read algorithm also! This calculated
800 digits of pi in 0.1 seconds and 10,000 digits in 20 seconds.

------------------------------------------------------------
"""
Standalone Program to calculate PI using python only

Nick Craig-Wood <ni**@craig-wood.com>
"""

import sys
from time import time

class FixedPoint(obje ct):
"""A minimal immutable fixed point number class"""
__slots__ = ['value'] # __weakref__
digits = 25 # default number of digits
base = 10**digits

def __init__(self, value=0):
"""Initiali se the FixedPoint object from a numeric type"""
try:
self.value = long(value * self.base)
except (TypeError, ValueError), e:
raise TypeError("Can' t convert %r into long", value)

def set_digits(cls, digits):
"""Set the default number of digits for new FixedPoint numbers"""
cls.digits = digits
cls.base = 10**digits
set_digits = classmethod(set _digits)

def copy(self):
"Copy self into a new object"
new = FixedPoint.__ne w__(FixedPoint)
new.value = self.value
return new
__copy__ = __deepcopy__ = copy

def __add__(self, other):
"""Add self to other returning the result in a new object"""
new = self.copy()
new.value = self.value + other.value
return new
__radd__ = __add__

def __sub__(self, other):
"""Subtract self from other returning the result in a new object"""
new = self.copy()
new.value = self.value - other.value
return new
def __rsub__(self, other):
new = self.copy()
new.value = other.value - self.value
return new

def __mul__(self, other):
"""
Multiply self by other returning the result in a new object. The
number of digits is that of self.

Note that FixedPoint(x) * int(y) is much more efficient than
FixedPoint(x) * FixedPoint(y)
"""
new = self.copy()
if isinstance(othe r, (int, long)):
# Multiply by scalar
new.value = self.value * other
else:
new.value = (self.value * other.value) // other.base
return new
__rmul__ = __mul__

def __div__(self, other):
"""
Divide self by other returning the result in a new object. The
number of digits is that of self.

Note that FixedPoint(x) / int(y) is much more efficient than
FixedPoint(x) / FixedPoint(y)
"""
new = self.copy()
if isinstance(othe r, (int, long)):
# Divide by scalar
new.value = self.value // other
else:
new.value = (self.value * other.base) // other.value
return new
def __rdiv__(self, other):
if not isinstance(othe r, FixedPoint):
other = FixedPoint(othe r, self.digits)
return other.__div__(s elf)

def __str__(self):
"""
Convert self into a string. This will be the integral part of
the number possibly preceded by a - sign followed by a . then
exactly n digits where n is the number of digits specified on
creation.
"""
if self.value < 0:
s = str(-self.value)
else:
s = str(self.value)
s = s.zfill(self.di gits + 1)
s = s[:-self.digits] + "." + s[-self.digits:]
if self.value < 0:
s = "-" + s
return s

def __abs__(self):
"""Return the absolute value of self"""
new = self.copy()
if new.value < 0:
new.value = - new.value
return new

def __cmp__(self, other):
"""Compare self with other"""
return cmp(self.value, other.value)

def sqrt(n):
"""
Return the square root of n. It uses a second order
Newton-Raphson convgence. This doubles the number of significant
figures on each iteration. This will work for any finite
precision numeric type.
"""
x = n / 2 # FIXME find a better guess!
old_delta = None
while 1:
x_old = x
x = (x + n / x) / 2
delta = abs(x - x_old)
if old_delta is not None and delta >= old_delta:
break
old_delta = delta
return x

def pi_agm(one = 1.0, sqrt=sqrt):
"""
Brent-Salamin Arithmetic-Geometric Mean formula for pi. This
converges quadratically.

FIXME can increase the number of digits in each iteration to speed up?
"""
_1 = one
_2 = _1 + _1
a = _1
b = _1/sqrt(_2)
t = _1/2
k = 1
two_to_the_k = 2L
old_delta = None

while 1:
s = (a + b ) / 2
d = a - s
d = d * d
a = s
s = s * s
t = t - two_to_the_k * d
b = sqrt(s - d)
delta = abs(a - b)
# print k, delta, old_delta
if old_delta is not None and delta >= old_delta:
break
old_delta = delta
k = k + 1
two_to_the_k *= 2

a = a + b
return ( a * a ) / ( _2 * t)

if __name__ == "__main__":
try:
digits = int(sys.argv[1])
except:
digits = 100
print "Calculating",d igits,"digits of pi"
start = time()
FixedPoint.set_ digits(digits)
_1 = FixedPoint(1)
print pi_agm(_1, sqrt=sqrt)
dt = time() - start
print "That took",dt,"secon ds"
------------------------------------------------------------
But Python is much slower here then C here. I used a while-loop within a
while-loop. Not that much calculation here.
There is more than one way to skin this cat. A better algorithm helps
a lot.

If I really wanted lots of digits of pi from python I'd do it like
this. This is an example of the right tool for the job. 0.5ms looks
pretty good to me!
>>import math, gmpy
bits = int(800/math.log10(2))
start = time(); pi=gmpy.pi(bits ); dt = time()-start
print "That took",dt,"secon ds"
That took 0.0005519390106 2 seconds
>>pi
mpf('3.14159265 358979323846264 338327950288419 716939937510582 097494459230781 640628620899862 803482534211706 798214808651328 230664709384460 955058223172535 940812848111745 028410270193852 110555964462294 895493038196442 881097566593344 612847564823378 678316527120190 914564856692346 034861045432664 821339360726024 914127372458700 660631558817488 152092096282925 409171536436789 259036001133053 054882046652138 414695194151160 943305727036575 959195309218611 738193261179310 511854807446237 996274956735188 575272489122793 818301194912983 367336244065664 308602139494639 522473719070217 986094370277053 921717629317675 238467481846766 940513200056812 714526356082778 577134275778960 917363717872146 844090122495343 014654958537105 079227968925892 354201995611212 902196086403441 815981362977477 130996051870721 134999999837297 804995105973173 281609631859502 4459455e0',2657 )
>>>
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jan 4 '07 #18

Mainly, it was fload-div. Changed to int-div (python //) runs faster.

Yes, this "gmpy" sounds good for calc things like that.
But not available on my machine.
ImportError: No module named gmpy

Anyway, thanks for posting. This gmpy module can be very intersting.
But right now, the focus was, if it's possible to translate a strange C
code into Python. And it is. Sure ;-)

Maybe, someone can also translate a very simple algorithm for calc a
range of PI in Python. (Available Code for C.)
http://crd.lbl.gov/~dhbailey/

http://crd.lbl.gov/~dhbailey/bbp-codes/piqpr8.c

But seems to be removed? It was working last days. (Maybe removed from
server.)
An other well known is: (but someone implemented this already in Python,
slow, and, depends on the previouse calc values, like most other
algorithmes.)

pi 01 01 01 01 01 01 01 01 01 01
__ = __ - __ + __ - __ + __-__+__-__+__-__
04 01 03 05 07 09 11 13 15 17 19 ...

pi/4 = 1/1 - 1/3 + 1/5 - 1/7 + 1/9 ...
Or things like that:
http://numbers.computation.free.fr/C...am/pifast.html

There is more than one way to skin this cat. A better algorithm helps
a lot.

If I really wanted lots of digits of pi from python I'd do it like
this. This is an example of the right tool for the job. 0.5ms looks
pretty good to me!
>>import math, gmpy
>>bits = int(800/math.log10(2))
>>start = time(); pi=gmpy.pi(bits ); dt = time()-start
>>print "That took",dt,"secon ds"
That took 0.0005519390106 2 seconds
>>pi
mpf('3.14159265 358979323846264 338327950288419 716939937510582 097494459230781 640628620899862 803482534211706 798214808651328 230664709384460 955058223172535 940812848111745 028410270193852 110555964462294 895493038196442 881097566593344 612847564823378 678316527120190 914564856692346 034861045432664 821339360726024 914127372458700 660631558817488 152092096282925 409171536436789 259036001133053 054882046652138 414695194151160 943305727036575 959195309218611 738193261179310 511854807446237 996274956735188 575272489122793 818301194912983 367336244065664 308602139494639 522473719070217 986094370277053 921717629317675 238467481846766 940513200056812 714526356082778 577134275778960 917363717872146 844090122495343 014654958537105 079227968925892 354201995611212 902196086403441 815981362977477 130996051870721 134999999837297 804995105973173 281609631859502 4459455e0',2657 )
>>>
Jan 4 '07 #19
Yes, this "gmpy" sounds good for calc things like that.
But not available on my machine.
ImportError: No module named gmpy
What type of machine?

The home page for gmpy is http://sourceforge.net/projects/gmpy/

I have Windows versions available at http://home.comcast.net/~casevh/

casevh

Jan 4 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1539
by: Astra | last post by:
Hi All Wonder if you can help me with the following calc, which I want to create to check whether or not a user has entered a valid credit card expiry date: 1) I have retrieve a value from 2 x SELECTs. One value is the month in a 2 DIGIT form, eg 01, 02, 03, 04, etc, and the other is the year in a 4 DIGIT form, ie 2004, 2005, 2006, 2007, etc. 2) My Maths for this was going to be that I do a calc on the figures
3
1582
by: enfis.the.paladin | last post by:
Hi to all! I have something like this: class FWrap { public: virtual void READ (void) = 0; } class Optimized { private:
2
2512
by: Mountain Bikn' Guy | last post by:
This code is used in a simple example calculator. It has a text box that displays the result. It performs addition, subtraction, multiplication, etc. on two operands. For the operands it accepts digits 0..9 and a decimal point. The insert() method isn't very clear to me. Can anyone help me convert the code shown below to C#? Thanks! enum { PRECISION = 14 }; //-------------------------------------------------------------------
10
2149
by: Mike | last post by:
Is it still true that the managed C++ compiler will produce much better opimizations than the C# compiler, or have some of the more global/aggressive opimizations been rolled into the 2005 compiler? Are simple common sub-expressions and loop invariants optimized out in the current optimizer? thanks, m
0
3428
by: jdavidson | last post by:
I have not worked with VB at all and wondered if perhaps there was an all knowing SQL DBA out there that also spoke fluent VB. I am trying to come up with the equilivant T-SQL code for the following VB script (it is a portion of an old Access query) and certainly appreciate any help offered!! Thanks (and sorry about the table names....i didn't create the database) 1) & " " & IIf( Is Not Null, & ". ","") & AS , 2)...
4
4849
by: Patrick Sullivan | last post by:
dim s_err as stringbuilder dim xx(6) as double dim ret_flag as integer ' This is a function to call an unmanaged C-style library function. ' The lib function fills an array of 6 doubles or error string. Declare Auto Function calc Lib "calc32.dll" Alias "calc32.dll"( ByRef xx() As Double, ByVal serr As System.Text.StringBuilder) As Integer
11
4927
by: Osiris | last post by:
I have these pieces of C-code (NOT C++ !!) I want to call from Python. I found Boost. I have MS Visual Studio 2005 with C++. is this the idea: I write the following C source file: ============================ #include <iostream> #include <stdafx.h>
4
1351
by: wutzke | last post by:
I started working on a script that would take the cost of something and suggest a retail amount. I usually figure Retail on Margins. So Retail equals Cost divided by (Margin-100)% plus Cost. So if Cost is $50 and Margin is 40% 50/(40-100)%+50=80 or (50/60%)+50=80
7
1449
by: colin | last post by:
Hi, Is there a way of doing simple code generation inside visual c# express such as similar to preprocessing in c++ ? I need to generate a library for some vector maths, but I need to implement it for different types wich would be difficult to do with generic types and/or interfaces for numerous reasons and would probaly sufer a considerable performance hit.
0
10793
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10509
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5626
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3977
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.