Wednesday, January 3, 2018

Digest for comp.lang.c++@googlegroups.com - 14 updates in 8 topics

Intelli2 <intelli2@mama.com>: Jan 03 04:36PM -0500

Hello..
 
Another new scalable algorithm of mine is here..
 
I think Embarcadero will be happy with this, because my new scalable
algorithm is a scalable reference counting algorithm, i have just
finished implementing it and it is working very well and i will present
it to Embarcadero , i want to sell it to them, also i am finishing my
other scalable algorithms that are a scalable Threadpool engine that i
want to sell it to them, it is scalable on NUMA and multicore systems ,
also i want to sell to them another almost scalable Threadpool of mine
that supports priorities , a high and a normal and a low, also i want to
sell also my scalable FIFO queues , i want to sell my scalable
algorithms to Embarcadero , but if they don't want to buy , i will sell
my scalable algorithms and there implementations to Microsoft or to
other software companies.
 
Stay tuned because i think Embarcadero will become soon much better with
my scalable algorithms and there implementations.
 
Thank you,
Amine Moulay Ramdane.
Juha Nieminen <nospam@thanks.invalid>: Jan 03 08:21AM


> There is a guy call "Rick C. Hodgin" living in Indiana and said muslim will go to hell. Please see his post https://groups.google.com/forum/#!topic/comp.lang.c/j4fTTKv2Ycs
 
> Please call the police and stop him, his email is rickc...@gmail.com
 
> I will fire a complaint to US goveronment
 
Stop him from doing what? There's still freedom of speech in the United States.
Cholo Lennon <chololennon@hotmail.com>: Jan 03 09:11AM -0300

On 03/01/18 05:21, Juha Nieminen wrote:
> There's still freedom of speech in the United States.
 
Hahaha
 
 
--
Cholo Lennon
Bs.As.
ARG
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 02 08:06PM

On 2 Jan 2018 16:30:44 GMT
> >templates for generic programming
 
> Today, we sometimes can /replace/ the use of templates by
> more readable constexpr functions.
 
And for type computation (as opposed to constexpr value computation),
you can sometimes replace C++98-style templated structs containing
typedefs by decltype with the C++14 auto return type used with
(non-constexpr) template functions. When you call decltype on a
function application the function is not executed: only its return type
is deduced.
 
You can use decltype with function templates in C++14 to iterate over
and manipulate type lists at compile time, for example.
 
Excluding signature overloading, there are I suppose four kinds of
compile-time computation available to the user now in C++14: sizeof,
decltype, constexpr and templates. Of these, C++98 had only sizeof and
templates. Possibly there are more: I would need to think about that.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 03 10:40AM

>> programming, move semantics, lambdas, and the like?
 
 
> This helped me:
 
> http://shop.oreilly.com/product/0636920033707.do
 
Why not spell it out? Scott Meyers: "Effective Modern C++:
42 Specific Ways to Improve Your Use of C++11 and C++14".
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Intelli2 <intelli2@mama.com>: Jan 02 02:07PM -0500

Hello,
 
 
Read this about the LMAX Disruptor, it is not a general purpose
mechanism, it is not suited for all applications.
 
"You can see this in the way that producers add values to the ring: they
first reserve a slot, then later publish it. If there are two
publishers, and one pauses in the middle (e.g. because the operating
system or virtual machine does a context switch), it stalls all
consumers. A second example is that if you want to distribute work
across a pool of threads, the Disruptor can't help. The FAQ suggests
distributing work modulo the number of workers, but what happens when
one work unit is much more expensive than others for some reason? It
ends up stalling all the future work assigned to that task.
ArrayBlockingQueue, which they clobber in their benchmarks, is much more
forgiving.
 
My point is that even though their ring buffer is very well designed and
tuned for high performance, it isn't an appropriate choice for all
applications. However, if you have producer/consumer queues in your
code, you probably should look to see if Disruptors will match your
needs, and anyone interested in high performance code should read their
paper and/or blog posts."
 
Read more here:
 
http://www.evanjones.ca/lmax-disruptor.html
 
 
This is why i have come with my scalable C++ FIFO queues here:
 
https://sites.google.com/site/aminer68/scalable-fifo-queues-for-c
 
 
And I am actually finishing implemeting my new inventions that are a
scalable Waifree FIFO queue and a scalable Lockfree FIFO queue.
 
 
Please stay tuned !
 
Thank you,
Amine Moulay Ramdane.
Intelli2 <intelli2@mama.com>: Jan 02 02:00PM -0500

Hello,
 
 
Read this about the LMAX Distruptor, it is not a general purpose
mechanism, it is not suited for all applications.
 
"You can see this in the way that producers add values to the ring: they
first reserve a slot, then later publish it. If there are two
publishers, and one pauses in the middle (e.g. because the operating
system or virtual machine does a context switch), it stalls all
consumers. A second example is that if you want to distribute work
across a pool of threads, the Disruptor can't help. The FAQ suggests
distributing work modulo the number of workers, but what happens when
one work unit is much more expensive than others for some reason? It
ends up stalling all the future work assigned to that task.
ArrayBlockingQueue, which they clobber in their benchmarks, is much more
forgiving.
 
My point is that even though their ring buffer is very well designed and
tuned for high performance, it isn't an appropriate choice for all
applications. However, if you have producer/consumer queues in your
code, you probably should look to see if Disruptors will match your
needs, and anyone interested in high performance code should read their
paper and/or blog posts."
 
Read more here:
 
http://www.evanjones.ca/lmax-disruptor.html
 
 
This is why i have come with my scalable C++ FIFO queues here:
 
https://sites.google.com/site/aminer68/scalable-fifo-queues-for-c
 
 
And I am actually finishing implemeting my new inventions that are a
scalable Waifree FIFO queue and a scalable Lockfree FIFO queue.
 
 
Please stay tuned !
 
Thank you,
Amine Moulay Ramdane.
wij@totalbb.net.tw: Jan 02 07:10PM -0800

On Wednesday, January 3, 2018 at 2:30:20 AM UTC+8, Marcel Mueller wrote:
> But the standard guarantees that the implementation of std::complex<T>
> is binary compatible to T[2] and this is compatible to C's _Complex. So
> it works even if you need to work with a C API.
 
My old implement is like below:

template<typename T> class MyComplex {
T m_re,m_im;
public:
...
};

It also guarantees binary compatible with std::complex<T> (so far).
 
Somehow, when I recently looked back at MyComplex codes, decided
to reimplement(refactor) it. The choices are 1) wrap std::complex<T>
2) wrap C's _Complex type. Choice 1) was tried... finally gave up
(difficult probably,file deleted). So what left is choice 2) wrap
C's _Complex type. Currently I use template specialization, it works.
 
> Btw: what do you want to define your own complex class. Doesn't
> complex<> fit your needs?
 
> Marcel
The requirement dates back around year 2000, when people are enthusiastic
making 1.44M bootable(Linux) floppy disk containing a demo GUI program,..
Program size was the primary concern. That program should link as little
codes as possible from c++ library. Though this restrict is relaxed, API
consistency is still a must. "Link to clib" is still a good property.
Real Troll <real.troll@trolls.com>: Jan 02 11:59PM -0400

> public:
> ...
> };
 
Microsoft way of doing things is like so:
 
|template <> class complex<double> { public: constexpr complex( double
RealVal = 0, double ImagVal = 0); constexpr complex(const
complex<double>& complexNum); constexpr explicit complex(const
complex<long double>& complexNum); // rest same as template class
complex }; |
 
They also give you an example:
 
|// complex_comp_dbl.cpp // compile with: /EHsc #include <complex>
#include <iostream> int main( ) { using namespace std; double pi =
3.14159265359; // The first constructor specifies real & imaginary parts
complex <double> c1 ( 4.0 , 5.0 ); cout << "Specifying initial real &
imaginary parts,\n" << " as type double gives c1 = " << c1 << endl; //
The second constructor initializes values of the real & // imaginary
parts using those of complex number of type float complex <float>
c2float ( 4.0 , 5.0 ); complex <double> c2double ( c2float ); cout <<
"Implicit conversion from type float to type double," << "\n gives
c2double = " << c2double << endl; // The third constructor initializes
values of the real & // imaginary parts using those of a complex number
// of type long double complex <long double> c3longdouble ( 4.0 , 5.0 );
complex <double> c3double ( c3longdouble ); cout << "Explicit conversion
from type float to type double," << "\n gives c3longdouble = " <<
c3longdouble << endl; // The modulus and argument of a complex number
can be recovered double absc3 = abs ( c3longdouble ); double argc3 = arg
( c3longdouble ); cout << "The modulus of c3 is recovered from c3 using:
abs ( c3 ) = " << absc3 << endl; cout << "Argument of c3 is recovered
from c3 using:\n arg ( c3 ) = " << argc3 << " radians, which is " <<
argc3 * 180 / pi << " degrees." << endl; } \* Output: Specifying initial
real & imaginary parts, as type double gives c1 = (4,5) Implicit
conversion from type float to type double, gives c2double = (4,5)
Explicit conversion from type float to type double, gives c3longdouble =
(4,5) The modulus of c3 is recovered from c3 using: abs ( c3 ) = 6.40312
Argument of c3 is recovered from c3 using: arg ( c3 ) = 0.896055
radians, which is 51.3402 degrees. *\ |
Real Troll <real.troll@trolls.com>: Jan 02 11:59PM -0400

On 03/01/2018 03:59, Real Troll wrote:
> Microsoft way of doing things is like so:
 
The formatting didn't work in the previous post so here it is again:
 
Microsoft way of doing things is like so:
 
template <>
class complex<double> {
public:
constexpr complex(
double RealVal = 0,
double ImagVal = 0);
 
constexpr complex(const complex<double>& complexNum);
 
constexpr explicit complex(const complex<long double>& complexNum);
// rest same as template class complex
};
 
 
 
// complex_comp_dbl.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>
 
int main( )
{
using namespace std;
double pi = 3.14159265359;
 
// The first constructor specifies real & imaginary parts
complex <double> c1 ( 4.0 , 5.0 );
cout << "Specifying initial real & imaginary parts,\n"
<< " as type double gives c1 = " << c1 << endl;
 
// The second constructor initializes values of the real &
// imaginary parts using those of complex number of type float
complex <float> c2float ( 4.0 , 5.0 );
complex <double> c2double ( c2float );
cout << "Implicit conversion from type float to type double,"
<< "\n gives c2double = " << c2double << endl;
 
// The third constructor initializes values of the real &
// imaginary parts using those of a complex number
// of type long double
complex <long double> c3longdouble ( 4.0 , 5.0 );
complex <double> c3double ( c3longdouble );
cout << "Explicit conversion from type float to type double,"
<< "\n gives c3longdouble = " << c3longdouble << endl;
 
// The modulus and argument of a complex number can be recovered
double absc3 = abs ( c3longdouble );
double argc3 = arg ( c3longdouble );
cout << "The modulus of c3 is recovered from c3 using: abs ( c3 ) = "
<< absc3 << endl;
cout << "Argument of c3 is recovered from c3 using:\n arg ( c3 ) = "
<< argc3 << " radians, which is " << argc3 * 180 / pi
<< " degrees." << endl;
}
\* Output:
Specifying initial real & imaginary parts,
as type double gives c1 = (4,5)
Implicit conversion from type float to type double,
gives c2double = (4,5)
Explicit conversion from type float to type double,
gives c3longdouble = (4,5)
The modulus of c3 is recovered from c3 using: abs ( c3 ) = 6.40312
Argument of c3 is recovered from c3 using:
arg ( c3 ) = 0.896055 radians, which is 51.3402 degrees.
*\
Marcel Mueller <news.5.maazl@spamgourmet.org>: Jan 02 07:30PM +0100

> I am implementing a Complex template using C's _Complex, like below:
[...]
> T _Complex m_z;
> ^~~
 
> How to go around this issue? Thanks.
 
std::complex<T> m_z;
 
C++ does not support C's complex type, as David mentioned.
But the standard guarantees that the implementation of std::complex<T>
is binary compatible to T[2] and this is compatible to C's _Complex. So
it works even if you need to work with a C API.
 
Btw: what do you want to define your own complex class. Doesn't
complex<> fit your needs?
 
 
Marcel
Real Troll <real.troll@trolls.com>: Jan 02 05:34PM

On 27/12/2017 21:14, Ian Collins wrote:
 
> Why oh why do tutorial still use that obsolete term (STL)?
 
Because you didn't bother to tell them directly what they should be
using or for that matter, you should write to them to update their website.
 
Most websites don't update anything these days because the rate of
change is so rapid that one person's hobby can't keep up with them.
 
Microsoft has got an army of web editors who are spending all their time
updating their pages but this can't be forever. A time will come when
Microsoft will concentrate sorely on C#
Real Troll <real.troll@trolls.com>: Jan 02 06:24PM

On 27/12/2017 15:50, 唐彬 wrote:
> where can i find the code or tutorial to learn from, which can better my coding style and let me learn more about how they work?
> thx a lot
 
You need to provide specific problems for anybody to help you here. You
started with STL but the body is about general coding styles and how to
"learn more".
 
To give an example, the area of a triangle can be computed as follows:
 
<!================== Function 01 ==================!>
int AreaofTriangle (int base, int height)
{
return base * height * 1/2;
}
 
This will work if the dimensions are all integers. What about when
dimensions are in decimals? So you might be tempted to write another
function like so:
 
<!================== Function 02 ==================!>
double AreaofTriangle2 (double base, double height)
{
return base * height * 1/2;
}
 
So this will work with numbers like 3.5, 4.5
 
However, some nit-pickers will come out with some other measurements.
 
So you could apply a template that can work with most sizes as long as
the logic remains the same as to how to calculate the Area of a
Triangle. So you could use this template:
 
<!================== Function 03 ==================!>
template <typename T>
T AreaofTriangle3 (T base, T height)
{
return base * height * 1/2;
}
Andrea Venturoli <ml.diespammer@netfence.it>: Jan 02 04:11PM +0100

On 01/02/18 01:57, jacobnavia wrote:
> Hi
> Has anyone here used this static analyzer?
 
Yes.
 
 
 
> For C projects it seems to work, but for C++ code it hangs (I stopped
> after waiting for 6 hours for any output).
 
I'm using it on C++, and it's doing partly its job: I get a lot of false
positives (always of the same 2 or 3 types however), but it did find
some faults in the code.
 
 
 
> I am using it in an ARM64, about 5 times slower than a high end PC.
 
> Is this normal?
 
No.
While it's slow, I never had to wait 6 hours.
 
 
 
bye
av.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: