473,882 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementation of functions in math.h on clc-wiki

I'm writing a portable implementation of the C standard library for
http://www.clc-wiki.net and I was wondering if someone could check the
functions in math.h for sanity/portability/whatever. I'm almost halfway
through writing the over 200 functions needed to implement C99's
version of math.h, and I would like to have some feedback and/or expert
advice on my implementations .

Sincerely, Gregory Pietsch

Mar 11 '06
110 8661
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
Right. I have no problem with people reading my published code
and using it as inspiration for a new implementation. I've certainly
benefited over the years from reading tons of code; and I continually
garner ideas from competitors' code that I have access to. Copyright
covers the *expression* of an idea, not the idea itself. But that
expression can be hard won -- in programming it's often the difference
between working right in all the corner cases and not quite working
at oddball times. It deserves protection.


Well, in any case - I know this whole episode has probably left a bad
taste in your mouth, so to speak, about the wiki and everything, but
what would your thoughts be on contributing to it? Maybe not to the c
library reimplementatio n, or even code at all, but it could always use
more people even just in general.


I'm not agin it, and I've been know to speak up when the urge
strikes, but I do this sort of thing 60 hours a week as my
profession, not as a hobby. I'm also getting old, and looking
forward to only doing it, say, 40 hours a week. Maybe when
things slow down a bit...

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Mar 12 '06 #51
First, I would like to apologize. My tone did cross a line, and I'm
sincerely sorry.

On 2006-03-12, P.J. Plauger <pj*@dinkumware .com> wrote:
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
On 2006-03-12, P.J. Plauger <pj*@dinkumware .com> wrote:
I consider _Dint one of the more valuable components of the Standard C
library that I originally wrote and that is now being licensed by my
company, Dinkumware, Ltd. (my principal source of income for the past
decade or so). I don't take lightly the notion that it can be copied
and used verbatim in ways that took me quite some time to work out.
That's why something as seemingly lightweight as:
Seemingly? It _is_ lightweight. The heavy lifting takes place in _Dint
itself.


And in structuring the whole library so that ceil can be a one-liner.
Check out some of the ceil functions in glibc before you dismiss
this one-liner so offhandedly.
return _Dint (&x, 0) < 0 && 0.0 < x ? x + 1.0 : x;

is IMO a serious infringement.


It may be EVIDENCE of a serious infringement, but the real much more
serious infringement would be copying of the implementation of _Dint
itself.


Here's where we part company, and where I think you're being
uncharitable at best, naive at worst. Copyright covers a broad
spectrum of expressions. It is weakest at "functional writings"
where there is little latitude for variety. Thus, I don't blink
at a <math.h> header that includes:


My question is this:

Do you think that, if this is infringement, that /1/ is necessarily also
infringement? How about /2/? I think that if the first is, both my
examples are as well, and that's why i'm uncomfortable with the position
that the first is.

1/return _M_d2i(&x,0) >= 0 || x <= 0 ? x : x+1;
2/
if(__dI(&x,0)<0 && x > 0)
return x+1.;
else
return x;
double sin(double);

My eyebrows would go up at:

_CRTIMP double _CDECL sin(double);

because we define those macros to work one way under gcc and
another under Windows (to build DLLs).
I think mine would too, but i'd think of it as being strong evidence of
further 'lifting' rather than being copyright infringement in itself -
whatever you end up naming the macro, there's really only one way to
declare a cdecl function on gcc, and only one way to do so on msvc. /3/,
right? No idea what _CRTIMP does. dllexport? I'm certainly not
disagreeing that it should raise suspicion, just that it's copyright
infringement per se.

3/
#if defined(__GNUC_ _)
#define _CDECL __cdecl
#elif defined(WIN32)
#define _CDECL __attribute__(( __cdecl__))
#endif

And if I saw:

inline double _CDECL sin(double _Left)
{ // return sine
return (_Sin(_Left, 0));
}
It's unlikely you're the first to think of bundling sine and cosine into
a single function. Again, the names very much should raise suspicion,
and I certainly didn't mean to fault you for that - but the core imple-
mentation itself would be the actual infringement. I think part of it is
that I strongly disagree that changing the names should have any effect
on whether it's copyright infringement or not, since identifiers aren't
really the expressive part of code. I'm sure you probably agree that if
someone stole your code it would be made any better if they ran it
through an obfuscator to change all the identifiers.

I think that if inline double _CDECL sin(double _Left) { return (_Sin
(_Left, 0)); } is infringement, it is implicit that inline double
__cdecl__ sin(double _M_angle) { return (_M_sin(_M_angl e,0)); } must
also be. That is what makes me uncomfortable about your position.
I'd consider it a full-bore ripoff, because there's a lot of
technology behind those few lines.
Yes, but in my opinion you'd have to look behind them, not in them, to
find the actual ripoff.
This is not just EVIDENCE of a serious infringement, IMO. The point
is, with each stage there's less function and more unique expression,
hence less excuse for somebody else expressing a thing the way I did,
and hence more evidence that they're piggybacking on what's well
protected by copyright.
Unless you have either a trademark on the name or a patent on the
idea of the function, someone could just as well implement their own.
Right, and I've never said otherwise. In fact, I observed in an
earlier post that the alleged perp put more work than average
into reimplementing _Dint (_Fint to be precise), though I still
consider it arguably infringing because of all the unique
expression that's still copied.
Given the specification of "_Dint", this looks like a perfectly obvious
way of implementing ceil. If we lived in some bizarre parallel universe
where _Dint is in the standard C library and ceil is not, that's how _I_
would implement ceil.


Fine, but we don't. It became obvious only after lots of work and
rework on my part, some of it dating back over 40 years.


ceil itself did? The idea of having a _Dint() function [and the details
of its specification, etc] did? or are we talking about the implement-
ation of _Dint()? No offense intended, I'm just confused here.
I'm not saying you're wrong, but equating the copying of a small and
possibly uncopyrightable mathematical formula that _uses_ _Dint, with
copying of the implementation of _Dint itself, seems dishonest.


You're lucky that I chose to take a walk to Starbucks before replying
to this post. You pervert what I actually said, then use it as an
excuse to accuse *me* of being dishonest. Nary a word against the
clear-cut case of infringement that's there for anyone with a copy
of my book to verify.


Sorry - I don't have a copy of your book so I didn't feel qualified to
comment on that in either direction. I still don't believe that there's
that much variation possible in ceil() itself, and i hadn't even looked
at either the _Dint implementation on there, or, obviously, yours [since
i don't have the book]

To clarify my position: I think that the whole of what was there was
clearly infringement, just that ceil(), had it been present in isolation
with nothing else but an entirely reimplemented _Dint() wouldn't have
been. (though, the broader idea of using a function like _Dint() in the
implementation of other functions still might have been. I don't yet
have an opinion on that)
You're stretching the bounds of both "uncharitab le" and "naive" at
this point, and bordering on arrogant and rude. (That wasn't what I
intended to say before my daily latte.)


Again, i'm sorry.
Mar 12 '06 #52
"P.J. Plauger" wrote:
"John F" <sp**@127.0.0.1 > wrote:
"P.J. Plauger" wrote:
"John F" <sp**@127.0.0.1 > wrote:

> _Dint(&x, -1) truncates x to the nearest *even* value, a
> critical
> test in function pow that's messy to write otherwise.

nice hack!

I prefer to think of it as a logical completion of the original
specification, but thanks.
I did mean it the right way round :-)
.....
> I consider _Dint one of the more valuable components of the
> Standard C library that I originally wrote and that is now
> being licensed by my company, Dinkumware, Ltd. (my
> principal source of income for the past decade or so).

It is, indeed! I hav not had a look at the implementation of
_Dint in the current case. But it looks quite obvious.

It's not as obvious as you might think. In fairness to Pietsch,
it looks like he did try to re-engineer the guts of the function
(so far he has only the float version). Still, copying the file
names, many internal implementation names, and the arbitrary
values for the return code is pushing things. In other cases,
you'll find dozens of lines of code copied almost verbatim,
including the coefficients of economized polynomials down to
the last digit. Some of those "small" modules represented days
or weeks of work, over a period of a couple of years -- they
are not the "one right way" to do things.


Numerical optimisation is a though subject where propagation of
errors is one of the biggest issues which is non trivial at
least...
Which optimisazions did you use? I have done three methods so far
with intermediate success (no time to use MatLab for extended
simulation...). Chebychev is one of my favourites. I'm trying to
catch up with more numerics but I just don't have enough time to.


For single-argument functions, we favor piecewise minimax fits
(ratio of polynomials) using Maplesoft.


Maple is a good tool, I'll try to get back to those interesting stuff.
We patch around zeros
at irrational argument values with truncated Taylor series.
We use extended precision as needed, implemented as an array
of half-precision values of arbitrary length.
This could lead to almost infinite precision when used iteratively.
Would be interesting to see a high precision scientific library ...
maybe it will need some speed optimisazion then ... *thoughts running
through my head*
We've also developed special test generators that know about the
graininess of floating-point values, and the inherent sensitivity
in functions due both to high slopes and artifacts of
floating-point representation.
That could come in handy now and then when it comes to tweaking
control algorithms for µm precision lab instrumentory.. .
What could be simpler?


Good question ;-) If you know how to do it, nothing is complicated ...
Devil is in details and I'm as sure as I am real that you had a few
puzzles to solve on the algorithms (especially to make them
efficient...)

regards
John
Mar 12 '06 #53

"P.J. Plauger" <pj*@dinkumware .com> wrote in message
news:bY******** ************@gi ganews.com...
"Rod Pemberton" <do*********@so rry.bitbuck.cmm > wrote in message
news:dv******** ***@news3.infoa ve.net...

I don't mind the copying of ideas, but I strongly oppose the
copying of expression. I make my living licensing, enhancing,
and supporting that expression.


So, one can use the exact same idea that you presented, as long as that
exact same idea is expressed in a completely different manner?

If everyone was held to that, it would essentially make all of mathematics,
physics, and most of computer programming, unuseable. I guess what I'm
trying to get at is: at what point does a certain author's presentation of
say, the Pythagorean Theorem, become copyrightable? How many ways can one
express this idea: "the rose is red," before it becomes uniquely
distinquishable enough to be copyrighted? Your use of _Dint was unique IMO.
But, how exactly could one use that same idea without expressing it in the
same unique manner? You seem to contradict yourself. You said you opposed
software patents, but yet it is very unlikely someone will be able to come
up with a different manner to express the ideas of _Dint without using your
exact form of expression. Essentially, you have a software patent through
copyright.
Rod Pemberton
Mar 12 '06 #54
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
First, I would like to apologize. My tone did cross a line, and I'm
sincerely sorry.
Apology accepted. Thanks.
.....
My question is this:

Do you think that, if this is infringement, that /1/ is necessarily also
infringement? How about /2/? I think that if the first is, both my
examples are as well, and that's why i'm uncomfortable with the position
that the first is.

1/return _M_d2i(&x,0) >= 0 || x <= 0 ? x : x+1;
2/
if(__dI(&x,0)<0 && x > 0)
return x+1.;
else
return x;
You can fuzz the line until the cows come home. My initial
observation was that the one-liner ceil was pretty clearly
infringing in its own right because:

a) it differed only in whitespace and redundant parens from the
expression I used, down to the funny name for the internal function
_Dint, and

b) it was built around an inventive approach to ceil that I've
never seen in another implementation (down to the nuts and bolts,
even though said nuts and bolts did not appear in the one-liner)

Changing names is a step away, as is restating the algorithm.
How far is far enough? Operationally, it's probably when you've
made enough changes that you have a new debugging task on your
hands, and you're not just piggybacking on the testing and
debugging done for the prototype that inspired you. I don't
pretend it's a bright line in general. But I think it was in
the originally presented particular case for ceil.
double sin(double);

My eyebrows would go up at:

_CRTIMP double _CDECL sin(double);

because we define those macros to work one way under gcc and
another under Windows (to build DLLs).


I think mine would too, but i'd think of it as being strong evidence of
further 'lifting' rather than being copyright infringement in itself -


Uh, to me that's a distinction without a difference. You still
seem to think that infringement only occurs after a certain
number of yards of code have been replicated. In literature,
you can infringe:

a book copyright by copying half a page without attribution or
permission

a screenplay by imitating the principal characters and plot outline

a poem by quoting one plangent line

It depends more on the creative freight than the length of the
train.
whatever you end up naming the macro, there's really only one way to
declare a cdecl function on gcc, and only one way to do so on msvc. /3/,
right?
No, there are several. Part of my point.
No idea what _CRTIMP does. dllexport? I'm certainly not
disagreeing that it should raise suspicion, just that it's copyright
infringement per se.

3/
#if defined(__GNUC_ _)
#define _CDECL __cdecl
#elif defined(WIN32)
#define _CDECL __attribute__(( __cdecl__))
#endif
Good guess, but off the mark. The creativity can also come in
*where* you put the _CDECL decorations, as well as what they
expand to.
And if I saw:

inline double _CDECL sin(double _Left)
{ // return sine
return (_Sin(_Left, 0));
}


It's unlikely you're the first to think of bundling sine and cosine into
a single function.


Right, but making the second argument a quadrant offset is not
widely done. Nor is the naming convention. Nor, necessarily, is
the direct call to the common internal function from a C++ inline
and a C macro. etc. etc.
Again, the names very much should raise suspicion,
and I certainly didn't mean to fault you for that - but the core imple-
mentation itself would be the actual infringement. I think part of it is
that I strongly disagree that changing the names should have any effect
on whether it's copyright infringement or not, since identifiers aren't
really the expressive part of code. I'm sure you probably agree that if
someone stole your code it would be made any better if they ran it
through an obfuscator to change all the identifiers.
Sorry, but it's both. We all know that a good set of naming
conventions can materially aid the readability of code, and
hence contribute to its worth. At the same time, it's not
the whole value added, so mechanically altering the names
and retaining the code structure doesn't cut it either.
You can't say one aspect is the arena for determining
infringment and the other is not.
I think that if inline double _CDECL sin(double _Left) { return (_Sin
(_Left, 0)); } is infringement, it is implicit that inline double
__cdecl__ sin(double _M_angle) { return (_M_sin(_M_angl e,0)); } must
also be. That is what makes me uncomfortable about your position.
Well, it doesn't have to. See above.
I'd consider it a full-bore ripoff, because there's a lot of
technology behind those few lines.


Yes, but in my opinion you'd have to look behind them, not in them, to
find the actual ripoff.


Another distinction without a difference. *Both* the foreground
and the background are part of the expression.
.....
Given the specification of "_Dint", this looks like a perfectly obvious
way of implementing ceil. If we lived in some bizarre parallel universe
where _Dint is in the standard C library and ceil is not, that's how _I_
would implement ceil.


Fine, but we don't. It became obvious only after lots of work and
rework on my part, some of it dating back over 40 years.


ceil itself did? The idea of having a _Dint() function [and the details
of its specification, etc] did? or are we talking about the implement-
ation of _Dint()? No offense intended, I'm just confused here.


IIRC, _Dint first arose as a safe way to perform the common operation
of ceil and floor, safely for large and semi-numeric values. It then
became apparent that several internal functions were so similar that
they should be merged, if only to lower the cost of porting. So
ceil and _Dint evolved back and forth, not in any simply directed
fashion (as top-down advocates would have you believe).
I'm not saying you're wrong, but equating the copying of a small and
possibly uncopyrightable mathematical formula that _uses_ _Dint, with
copying of the implementation of _Dint itself, seems dishonest.


You're lucky that I chose to take a walk to Starbucks before replying
to this post. You pervert what I actually said, then use it as an
excuse to accuse *me* of being dishonest. Nary a word against the
clear-cut case of infringement that's there for anyone with a copy
of my book to verify.


Sorry - I don't have a copy of your book so I didn't feel qualified to
comment on that in either direction. I still don't believe that there's
that much variation possible in ceil() itself, and i hadn't even looked
at either the _Dint implementation on there, or, obviously, yours [since
i don't have the book]


I just grabbed three implementations of ceil from glibc. (There are
about two dozen.) They're attached below. Which one do you think looks
most like my implementation?

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
----
double
__ceil (double x)
{
if (isless (fabs (x), 900719925474099 2.0)) /* 1 << DBL_MANT_DIG */
{
double tmp1, new_x;

new_x = -x;
__asm (
#ifdef _IEEE_FP_INEXAC T
"cvttq/svim %2,%1\n\t"
#else
"cvttq/svm %2,%1\n\t"
#endif
"cvtqt/m %1,%0\n\t"
: "=f"(new_x) , "=&f"(tmp1)
: "f"(new_x)) ;

/* Fix up the negation we did above, as well as handling -0 properly.
*/
x = copysign(new_x, x);
}
return x;
}

----
#include <machine/asm.h>

RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $")

ENTRY(__ceil)
fldl 4(%esp)
subl $8,%esp

fstcw 4(%esp) /* store fpu control word */

/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
than the 16 bit operations. */
movl $0x0800,%edx /* round towards +oo */
orl 4(%esp),%edx
andl $0xfbff,%edx
movl %edx,(%esp)
fldcw (%esp) /* load modified control word */

frndint /* round */

fldcw 4(%esp) /* restore original control word */

addl $8,%esp
ret

----
#include "math.h"
#include "math_private.h "

#ifdef __STDC__
static const double huge = 1.0e300;
#else
static double huge = 1.0e300;
#endif

#ifdef __STDC__
double __ceil(double x)
#else
double __ceil(x)
double x;
#endif
{
int32_t i0,i1,j0;
u_int32_t i,j;
EXTRACT_WORDS(i 0,i1,x);
j0 = ((i0>>20)&0x7ff )-0x3ff;
if(j0<20) {
if(j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
if(i0<0) {i0=0x80000000; i1=0;}
else if((i0|i1)!=0) { i0=0x3ff00000;i 1=0;}
}
} else {
i = (0x000fffff)>>j 0;
if(((i0&i)|i1)= =0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0>0) i0 += (0x00100000)>>j 0;
i0 &= (~i); i1=0;
}
}
} else if (j0>51) {
if(j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
i = ((u_int32_t)(0x ffffffff))>>(j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0>0) {
if(j0==20) i0+=1;
else {
j = i1 + (1<<(52-j0));
if(j<i1) i0+=1; /* got a carry */
i1 = j;
}
}
i1 &= (~i);
}
}
INSERT_WORDS(x, i0,i1);
return x;
}
Mar 12 '06 #55
[sci.math removed]

On 2006-03-12, P.J. Plauger <pj*@dinkumware .com> wrote:
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
double sin(double);

My eyebrows would go up at:

_CRTIMP double _CDECL sin(double);

because we define those macros to work one way under gcc and
another under Windows (to build DLLs).
I think mine would too, but i'd think of it as being strong evidence of
further 'lifting' rather than being copyright infringement in itself - [>...] It depends more on the creative freight than the length of the
train.
I think we're still in disagreement about how much "creative freight"
a wrapper function or a declaration [regardless of how much conditional
macro baggage may be present] has. But we'll have to agree to disagree I
guess. Again, sorry for my tone before.
whatever you end up naming the macro, there's really only one way to
declare a cdecl function on gcc, and only one way to do so on msvc. /3/,
right?


No, there are several. Part of my point.


But you have to choose one, and the choice of which one is pretty much
arbitrary, isn't it?
The creativity can also come in *where* you put the _CDECL
decorations, as well as what they expand to.
Normally, I'd agree, but... again, it has to go somewhere. [well,
realistically, cdecl is the default, so you _could_ leave it off if
you can guarantee that it won't be compiled with options that will
change the default calling convention] there are a limited number of
choices, and when it comes down to it, the choice is pretty much
arbitrary. personally, i'd have put it after the prototype, unless
there was a compelling reason otherwise (say, some windows compiler
doesn't allow it there. but then there's no longer a choice.)
And if I saw:

inline double _CDECL sin(double _Left)
{ // return sine
return (_Sin(_Left, 0));
}
It's unlikely you're the first to think of bundling sine and cosine into
a single function.


Right, but making the second argument a quadrant offset is not
widely done.


I didn't even realize that - does that mean that one can pass 2 to it to
get -sin(x) as well?
Nor is the naming convention.
_Word is one of a limited number of sane reserved identifier formats...
it's the one used by the new keywords in c99. I have no idea what the
significance of "left" is.
Nor, necessarily, is the direct call to the common internal function
from a C++ inline and a C macro. etc. etc.
That I'll buy. But inlines in headers as a general technique are common
enough.
Again, the names very much should raise suspicion, and I certainly
didn't mean to fault you for that - but the core implementation it-
self would be the actual infringement. I think part of it is that I
strongly disagree that changing the names should have any effect on
whether it's copyright infringement or not, since identifiers aren't
really the expressive part of code. I'm sure you probably agree that
if someone stole your code it would be made any better if they ran it
through an obfuscator to change all the identifiers.


Sorry, but it's both. We all know that a good set of naming
conventions can materially aid the readability of code, and hence
contribute to its worth. At the same time, it's not the whole value
added, so mechanically altering the names and retaining the code
structure doesn't cut it either. You can't say one aspect is the
arena for determining infringment and the other is not.
I think that if inline double _CDECL sin(double _Left) { return (_Sin
(_Left, 0)); } is infringement, it is implicit that inline double
__cdecl__ sin(double _M_angle) { return (_M_sin(_M_angl e,0)); } must
also be. That is what makes me uncomfortable about your position.


Well, it doesn't have to. See above.


I think we'll have to agree to disagree, and if that means that I end
up letting more things slide if I [unlikely] get famous and write a C
book, that's my loss.
IIRC, _Dint first arose as a safe way to perform the common operation
of ceil and floor, safely for large and semi-numeric values. It then
became apparent that several internal functions were so similar that
they should be merged, if only to lower the cost of porting. So
ceil and _Dint evolved back and forth, not in any simply directed
fashion (as top-down advocates would have you believe).


OK.
Sorry - I don't have a copy of your book so I didn't feel qualified to
comment on that in either direction. I still don't believe that there's
that much variation possible in ceil() itself, and i hadn't even looked
at either the _Dint implementation on there, or, obviously, yours [since
i don't have the book]


I just grabbed three implementations of ceil from glibc. (There are
about two dozen.) They're attached below. Which one do you think looks
most like my implementation?


<snipped>

fair enough.
Mar 13 '06 #56
"Rod Pemberton" <do*********@so rry.bitbuck.cmm > wrote in message
news:dv******** ***@news3.infoa ve.net...
"P.J. Plauger" <pj*@dinkumware .com> wrote in message
news:bY******** ************@gi ganews.com...
"Rod Pemberton" <do*********@so rry.bitbuck.cmm > wrote in message
news:dv******** ***@news3.infoa ve.net...

I don't mind the copying of ideas, but I strongly oppose the
copying of expression. I make my living licensing, enhancing,
and supporting that expression.
So, one can use the exact same idea that you presented, as long as that
exact same idea is expressed in a completely different manner?


Yes. That is sufficient, if not always necessary. I think you're
accusing me of saying it's always absolutely necessary. There
are degrees of acceptable difference, depending on the uniqueness
of each part of the expression.
If everyone was held to that, it would essentially make all of
mathematics,
physics, and most of computer programming, unuseable.
Nonsense. Perhaps you didn't notice what I said about functional
writings. If you ask three people to draw a floor plan for a warehouse,
you're going to get three pretty similar drawings (assuming they're
all basically competent). About the only way to infringe a blueprint
is to stuff it through a copier. Most of math and physics, and
great swaths of computer programming, aren't much different from
blueprints. But those parts of computer programming that are
deserve greater protection.
I guess what I'm
trying to get at is: at what point does a certain author's presentation of
say, the Pythagorean Theorem, become copyrightable?
A common touchstone is to ask, "Do you have to say it exacty
that way?" If there's only one sensible way to say something,
like x^2 + y^2 = z^2, then there's very little protection in
copyright law. But if you take the road less traveled, as it
were, you'd better not quote much more than the cliched part
of Robert Frost's great poem without getting permission.
How many ways can one
express this idea: "the rose is red," before it becomes uniquely
distinquishable enough to be copyrighted?
Good question. That's what poetry magazines traffic in, for
example.
Your use of _Dint was unique IMO.
But, how exactly could one use that same idea without expressing it in the
same unique manner?
Do you have to call it _Dint? There's no standard that says such
a critter exists. Does the first argument have to be a pointer
to double, and the second argument a signed integer bit offset?
Nothing like that in Fortran, IIRC. Do the return values have to
be defined in <math.h> as:

#define FP_INFINITE 2
#define FP_NAN 1
#define FP_NORMAL (-1)
#define FP_SUBNORMAL (-2)
#define FP_ZERO 0

(which was on the internet until a few hours ago, placed there
by a guy who asserted, "I'm writing a portable implementation of
the C standard library")? You might compare to this excerpt from
my <ymath.h>:

#define _DENORM (-2) /* C9X only */
#define _FINITE (-1)
#define _INFCODE 1
#define _NANCODE 2

(A little creativity there, but not much.) And so on, and so on.
None of these things *have* to be that way to implement the
clever idea of a fraction stripping function. So if you see a
ceil function that depends critically on a function spelled
the same way as yours, with the same signature as yours, with
almost identically the same return codes as yours -- with, in
fact, practically the same token sequence as yours -- is this
merely *evidence* of the possibility of infringement or is this
frigging infringement? I'd trust my fate to a dozen jurors
with no programming knowledge, just common sense, on that one.
You seem to contradict yourself.
No, it's more that you seem to want me to. I've been
reimplementing other people's software for decades, and
I've got a keen moral sense about when I think I've done
it fairly. Moreover, I've been double checked by the
likes of AT&T and tens of thousands of critical readers.
I work *hard* to make sure I have a consistent position
on infringement, one that I can apply equally to myself
and others.
You said you opposed
software patents, but yet it is very unlikely someone will be able to come
up with a different manner to express the ideas of _Dint without using
your
exact form of expression.
Hardly. See above.
Essentially, you have a software patent through
copyright.


Bullshit.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Mar 13 '06 #57
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
.....
whatever you end up naming the macro, there's really only one way to
declare a cdecl function on gcc, and only one way to do so on msvc. /3/,
right?
No, there are several. Part of my point.


But you have to choose one, and the choice of which one is pretty much
arbitrary, isn't it?


Yep. All the more reason to be suspicious when someone makes
all the same arbitrary decisions you did. In arbitrariness
there is creative expression.
.....
And if I saw:

inline double _CDECL sin(double _Left)
{ // return sine
return (_Sin(_Left, 0));
}

It's unlikely you're the first to think of bundling sine and cosine into
a single function.
Right, but making the second argument a quadrant offset is not
widely done.


I didn't even realize that - does that mean that one can pass 2 to it to
get -sin(x) as well?


Yep. In fact, a quick grep of our code shows that we use at least
four different forms for the second argument.
Nor is the naming convention.


_Word is one of a limited number of sane reserved identifier formats...
it's the one used by the new keywords in c99. I have no idea what the
significance of "left" is.


True, but _Dint for a fraction stripping function, and _Left for the
left or only operand, etc.? The mere fact that the significance of
_Left doesn't leap out at you should make you wonder why some other
implementer should choose exactly the same funny name, neh?
Nor, necessarily, is the direct call to the common internal function
from a C++ inline and a C macro. etc. etc.


That I'll buy. But inlines in headers as a general technique are common
enough.


So does that mean that you dismiss all declarations, macros, and
inlines as possible sources of infringement because all the other
teens at the sock hop are doin' it too?
.....


P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Mar 13 '06 #58
On 2006-03-13, P.J. Plauger <pj*@dinkumware .com> wrote:
I guess what I'm trying to get at is: at what point does a certain
author's presentation of say, the Pythagorean Theorem, become
copyrightable?
A common touchstone is to ask, "Do you have to say it exacty that
way?" If there's only one sensible way to say something, like x^2 +
y^2 = z^2, then there's very little protection in copyright law. But
if you take the road less traveled, as it were, you'd better not quote
much more than the cliched part of Robert Frost's great poem without
getting permission.


If there is truly only one way to do something, we all agree (At least,
if i'm reading you correctly) that it's not copyrightable. What if there
are only two ways to do something? Are they both copyrightable? Is only
one? If there are more than two, are all but one copyrightable?

Does "well, you can say z^2-x^2=y^2", make x^2+y^2=z^2 copyrightable?
how about z=sqrt(x^2+y^2) ?

[aside: given that the poem was written in 1920, it probably wasn't the
best example you might have used. But your point still stands, in
general]

[>...] Nothing like that in Fortran, IIRC. Do the return values have to
be defined in <math.h> as:

#define FP_INFINITE 2
#define FP_NAN 1
#define FP_NORMAL (-1)
#define FP_SUBNORMAL (-2)
#define FP_ZERO 0

(which was on the internet until a few hours ago, placed there
by a guy who asserted, "I'm writing a portable implementation of
the C standard library")? You might compare to this excerpt from
my <ymath.h>:

#define _DENORM (-2) /* C9X only */
#define _FINITE (-1)
#define _INFCODE 1
#define _NANCODE 2

(A little creativity there, but not much.) And so on, and so on. None
of these things *have* to be that way to implement the clever idea of
a fraction stripping function. So if you see a ceil function that
depends critically on a function spelled the same way as yours, with
the same signature as yours, with almost identically the same return
codes as yours -- with, in fact, practically the same token sequence
as yours -- is this merely *evidence* of the possibility of
infringement or is this frigging infringement? I'd trust my fate to a
dozen jurors with no programming knowledge, just common sense, on that
one.


The question is whether the idea of "a function, whose first argument is
a pointer to double and whose second argument is int, returning int [0
if the double pointed at was zero, -1 if it is a normal number, -2 if it
is denormalized, 1 if it is infinite, 2 if it is not a number], and mod-
ifying the double pointed at, if normal or denormalized, such that it is
truncated to the number of bits right of the radix point specified in
the second argument" (this was intended to be an accurate and complete
description of your _Dint() function) is copyrightable. My description
of it may be, and your implementation is. But is the idea itself
copyrightable? Copyright law doesn't generally traffic in *ideas* - it's
like recipes - the set of steps themselves aren't copyrightable, only
the physical text of the recipe [the expression of those steps] is.
Mar 13 '06 #59
On 2006-03-13, P.J. Plauger <pj*@dinkumware .com> wrote:
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** **************@ random.yi.org.. .
Nor, necessarily, is the direct call to the common internal function
from a C++ inline and a C macro. etc. etc.


That I'll buy. But inlines in headers as a general technique are
common enough.


So does that mean that you dismiss all declarations, macros, and
inlines as possible sources of infringement because all the other
teens at the sock hop are doin' it too?


I just meant that if everything else were shown [however unlikely] to be
something someone came up with independently, that they're both inline
on top of that doesn't bring much to the party, so to speak.
Mar 13 '06 #60

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

Similar topics

1
2087
by: Robert Mark Bram | last post by:
Howdy All! I am trying to write a very brief comparison of the Date and Math objects in terms of instance v static objects. What I have below is my best so far. Any criticisms or suggestions are most welcome! Date is an instance object. You use Date by creating instances of it - you call methods on those instances. - you change data to do with each instance.
9
4664
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
17
3638
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels deep. In that case you need much more ram than a PC has to store functions calculated in loops so that you do not have to recalculate every time you cycle through the nest of loops. Using a HD for storage to extend ram is much too slow for many...
6
2146
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject "string" in google comp.lang.c archives.Hope this helps.Hope I am not bothering any one. am I? =================================Start=========================== subject: Return to Start of Line? Question: I'd like printf, the next printf, to return...
6
4483
by: Thomas Lumley | last post by:
What does the standard guarantee about the accuracy of eg the trigonometric functions? There is obviously an implementation-dependent upper bound on the accuracy, since the answer is stored in a double, but is this bound actually achieved? First, a simple example Suppose I want the arc cosine of -1, and use acos(-1.0) to compute it. The correct answer to 25 hexadecimal digits is -3.243F6A8885A308D313198A2E. This falls between two ...
8
2926
by: Sensei | last post by:
I have a quick question about the math library included in the standard C90 (and 99). The gcc, xlc and possibly other compilers/linkers on some unix platforms cannot use any math functions in math.h if a switch (-lm) is used, so *explicitly* having the linker use a file called libm.so or libm.a/dylib/whatever. Is it true on all the platforms? (answer: probably no)
5
2260
by: Ark | last post by:
Hi everyone, Does anyone know if Direct3D overloads System.Math functions? Also is it possible to access the base functions of the overloaded function (in other words restore original of the overlaoded function)? Thank you
1
2065
by: silellak | last post by:
I have found an odd error when using an XSL stylesheet transform. We have a Notes/Domino application with the following line of code in one of the stylesheets: <xsl:value-of select="format-number(number(ActEmpMoneyValue),'###,###0.00')" /> After transforming an XML document object with this stylesheet, the value in the XML node ActEmpMoneyValue is not calculated, but a flat value such as "19.31". After being processed as above on...
35
2363
by: Francine.Neary | last post by:
I'm finding it really hard to keep some of these things straight... For example, fputs is to puts as fprintf is to printf, except that fputs has the file handle at the end and fprintf at the beginning! Very illogical! And hard to remember. Now this can quite easily be corrected by macros, for example: #include <stdio.h> #define fputs(X,Y) fputs(Y,X)
17
2484
by: Jason Doucette | last post by:
I am converting a C-style unit into a C++ class. I have an implementation function that was defined in the .cpp file (so it was hidden from the interface that exists in the .h file). It uses a structure that is only needed by the implementation, so it were declared in the .cpp file, as well. Now, when converting this into a class, the class definition exists in the .h file, since it's required by the interface. The implementation...
0
9931
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9777
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10725
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...
0
10403
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
9557
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...
1
7956
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5978
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4601
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
3
3226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.