472,347 Members | 2,409 Online

# Accelerated C++: [1,rows] Not so fast

I've finally gotten around to reading Accelerated C++ by Andrew Koenig and
Barbara Moo. There's a lot of good stuff in what I've read so far. Even
though it is _very_ basic, they present some concepts I have not
encountered elsewhere, or explain ones I have encountered in ways that add
to my understanding. There are a few points of style with which I take
issue, such as not consistently using braces around the body of an if or
loop, etc.

There is one point, however, I have to take exception too. They assert that
"...the number of elements in [0, rows) is obvious(i.e., rows -0, or rows)
but the number of elements in [1,rows[ is less so." If you agree with
these authors, please turn off the computer and reflect for a moment on
your preschool and kindergarden years. Hold up your hand and look at your
fingers. Remember? "One", "two", "three"....? ;-)
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #1
27 1806
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:Xf********************@speakeasy.net...
There is one point, however, I have to take exception too. They assert
that
"...the number of elements in [0, rows) is obvious(i.e., rows -0, or rows)
but the number of elements in [1,rows[ is less so." If you agree with
these authors, please turn off the computer and reflect for a moment on
your preschool and kindergarden years. Hold up your hand and look at your
fingers. Remember? "One", "two", "three"....? ;-)

Indeed -- People form bad habits early.

If you are in the habit of representing ranges by storing the first and last
element of the range, our experience from years of teaching is that you are
much more likely to run into trouble than you are if you form the habit of
representing ranges by storing the first and one past the last element.

Moreover, once you graduate from ranges of integers to ranges of iterators,
you no longer have a choice in the matter, because there is no way to
represent an empty range if you insist on referring to the last element
rather than one past the last.
Jul 22 '05 #2
Andrew Koenig wrote:

fingers. Remember? "One", "two", "three"....? ;-)

Indeed -- People form bad habits early.

If you are in the habit of representing ranges by storing the first and
last element of the range, our experience from years of teaching is that
you are much more likely to run into trouble than you are if you form the
habit of representing ranges by storing the first and one past the last
element.

Moreover, once you graduate from ranges of integers to ranges of
iterators, you no longer have a choice in the matter, because there is no
way to represent an empty range if you insist on referring to the last
element rather than one past the last.

I don't disagree with what you're saying. I've never thought about the issue
from that perspective. I simply accepted that C and hence C++ works that
way because it's more consistent with the hardware representation. I know
I can get pretty disoriented if I start working with Mathematica after a
long period of exclusively working with C++. Mathematica starts indexing
at 1, sort of. The zeroth element of a List is 'List'.

I was really commenting on the impact that counting from 0 has on our
thinking. I worked with vectors an matrices for years in mathematics
before I started working with computers. Now the idea of indexing from 1
seems a bit foreign. I sometimes wonder if mathematics will every recover
from computer science.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #3
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:Xf********************@speakeasy.net...
I've finally gotten around to reading Accelerated C++ by Andrew Koenig and
Barbara Moo. There's a lot of good stuff in what I've read so far. Even
though it is _very_ basic, they present some concepts I have not
encountered elsewhere, or explain ones I have encountered in ways that add
to my understanding.

One comment that I've come across many times is that it's hard going for
beginners, i.e., not basic enough, though I don't know what level it's
aimed at. I have not actually read it. The bookshops here don't have it.
They prefer to stock "Learn C++ in 30 seconds", or whatever it's called.

DW

Jul 22 '05 #4
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:GO********************@speakeasy.net...

I've never thought about the issue
from that perspective. I simply accepted that C and hence C++ works that
way because it's more consistent with the hardware representation.

Neither have I. And I was quite impressed by the representation of an empty
range by [n, n). The book shows some fundametal but easy-to-ignore points.

--
ES Kim
Jul 22 '05 #5
"David White" <no@email.provided> wrote in message
news:lR*****************@nasal.pacific.net.au...
One comment that I've come across many times is that it's hard going for
beginners, i.e., not basic enough, though I don't know what level it's
aimed at. I have not actually read it. The bookshops here don't have it.
They prefer to stock "Learn C++ in 30 seconds", or whatever it's called.

Accelerated C++ covers more material in its 320 pages than many 1000-page
introductory books. It does so by not dwelling on unimportant details and
avoiding needless repetition. As a result, you have to read it thoroughly:
You can't just open it at random and expect that you'll be able to
understand whatever you see without first having read what precedes it.

On the other hand, if you do take the time to read it thoroughly, I believe
you will learn more in less time than if you were to use a more conventional
book. The reason is that one of its organizing principles is "Teach the
most useful ideas first." That is, at each point in the book, we present
the idea that we think will add the most to your programming skills beyond
what you have already learned up to that point.

Who is the intended audience? Someone who already has some programming
experience (not necessarily a lot), and who can figure out the mechanics of
writing and running C++ programs. I know that several people are using it
as textbooks in introductory college computer-science courses. It would
also be well suited for software developers who have never used C++ but who
have programmed in other languages.

I think it might even be useful for a complete novice, provided that there
was someone around to help as needed. I think it's a little steep for
self-study by a nonprogrammer.

Jul 22 '05 #6

"ES Kim" <no@spam.mail> wrote in message
news:cm**********@news1.kornet.net...
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:GO********************@speakeasy.net...

I've never thought about the issue
from that perspective. I simply accepted that C and hence C++ works that
way because it's more consistent with the hardware representation.

Neither have I. And I was quite impressed by the representation of an
empty
range by [n, n). The book shows some fundametal but easy-to-ignore points.

I find that notation to be rather silly. Something more like [] would be
better, in my opinion, except that of course we're dealing with takng that
representation and applying it to something real (assuming you can call C++
"real" :-)).
What does [n,n) mean, if translated into everyday language? It's the range
of integers starting at and including n, up to but NOT including n. Umm...
what??? The first part says to include n, and the second says to not
include n. Very weird.
It's obvious, as a programer, how that representation can be implemented in,
for example, a for loop. But it's no different, really, from saying
something like [100,-5]. That's just as "emtpy" as [n,n), isn't it?

Just my \$0.02 (and as valueless as that is).

-Howard
Jul 22 '05 #7
Howard wrote:

"ES Kim" <no@spam.mail> wrote in message
news:cm**********@news1.kornet.net...
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:GO********************@speakeasy.net...

I've never thought about the issue
from that perspective. I simply accepted that C and hence C++ works
that way because it's more consistent with the hardware representation.

Neither have I. And I was quite impressed by the representation of an
empty
range by [n, n). The book shows some fundametal but easy-to-ignore
points.

I find that notation to be rather silly. Something more like [] would be
better, in my opinion, except that of course we're dealing with takng that
representation and applying it to something real (assuming you can call
C++ "real" :-)).
What does [n,n) mean, if translated into everyday language? It's the
range
of integers starting at and including n, up to but NOT including n.
Umm...
what??? The first part says to include n, and the second says to not
include n. Very weird.
It's obvious, as a programer, how that representation can be implemented
in,
for example, a for loop. But it's no different, really, from saying
something like [100,-5]. That's just as "emtpy" as [n,n), isn't it?

Just my \$0.02 (and as valueless as that is).

-Howard

It's really standard mathematical notation for a set. There's nothing novel
to me in the notation itself. What I found a bit amusing was the idea that
it is easier to determine the number of elements in the set {0,1,2,...,n-1}
than in the set {1,2,3,...,n}.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #8
Andrew Koenig wrote:
I think it might even be useful for a complete novice, provided that there
was someone around to help as needed. I think it's a little steep for
self-study by a nonprogrammer.

I'm finding that it is fairly 'self-contained'. That is, it makes very few
assumptions about prior programming knowledge, and presents every necessary
concept as appropriate. Though it presents the material at a basic level,
it doesn't condescend to the reader. It also presents - as I previously
indicated - some ideas I haven't encountered elsewhere. I'm certainly
getting more from the book than simply a review of the material covered in
TC++PL(SE).

I suspect the hardest part of working through the book for a person with
little programming experience would be the challenge of figuring out the
mechanics of working with the particular implementation. IDE's can add a
lot of distracting content to even the simplest of programs, and the
g++(for example) command line interface is not what I would call intuitive.

Of course they could use Emacs... :o vi? My own opinion is that a person
would be well served by fetching Cygwin - or installing an operating system
- and learning to work with their compiler from the command line. I'd
suggest TextPad (ShareWare) as an editor if they are restricted to a
Windows environment.

One advantage I got from using KDevelop when I started programming in C++ is
that it created my header/source file pairs in a useful way.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #9
"Howard" <al*****@hotmail.com> wrote in message
news:8d*******************@bgtnsc05-news.ops.worldnet.att.net...
I find that notation to be rather silly. Something more like [] would be
better, in my opinion, except that of course we're dealing with takng that
representation and applying it to something real (assuming you can call
C++ "real" :-)).
What does [n,n) mean, if translated into everyday language? It's the
range of integers starting at and including n, up to but NOT including n.
Umm... what??? The first part says to include n, and the second says to
not include n. Very weird.
The notation has many years of usage in mathematics. I didn't invent it.
It's obvious, as a programer, how that representation can be implemented
in, for example, a for loop. But it's no different, really, from saying
something like [100,-5]. That's just as "emtpy" as [n,n), isn't it?

Yes it is. However, the number of elements in [m,n) is n-m; the number of
elements in [m,n] is n+1-m (assuming zero in both cases if the count is
negative). The "+1" is the source of untold off-by-one errors in programs.
Jul 22 '05 #10

"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:H-********************@speakeasy.net...
Howard wrote:

"ES Kim" <no@spam.mail> wrote in message
news:cm**********@news1.kornet.net...
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:GO********************@speakeasy.net...

issue
from that perspective. I simply accepted that C and hence C++ works
that way because it's more consistent with the hardware representation.

Neither have I. And I was quite impressed by the representation of an
empty
range by [n, n). The book shows some fundametal but easy-to-ignore
points.

I find that notation to be rather silly. Something more like [] would be
better, in my opinion, except that of course we're dealing with takng
that
representation and applying it to something real (assuming you can call
C++ "real" :-)).
What does [n,n) mean, if translated into everyday language? It's the
range
of integers starting at and including n, up to but NOT including n.
Umm...
what??? The first part says to include n, and the second says to not
include n. Very weird.
It's obvious, as a programer, how that representation can be implemented
in,
for example, a for loop. But it's no different, really, from saying
something like [100,-5]. That's just as "emtpy" as [n,n), isn't it?

Just my \$0.02 (and as valueless as that is).

-Howard

It's really standard mathematical notation for a set. There's nothing
novel
to me in the notation itself. What I found a bit amusing was the idea
that
it is easier to determine the number of elements in the set
{0,1,2,...,n-1}
than in the set {1,2,3,...,n}.
--

Actually, as you've just shown, sets us curly bracket notation. And, the
notation for an empty set is {}, not [n,n).

All I'm saying is that it's incredibly odd to use this specific instance of
the notation: [n,n), because the left square bracket here explicitly means
to include the number following it (n), and the right paren just as
explicitly states to NOT include the number to its left (n). So... the
notation contradicts itself. Undoubtedly, it's convenient to say [n,n) in
order to construct a programming model from the mathematical model, and
maybe it's even commonly used (although I sure don't recall seeing it in my
degree studies), but there's no way to deny that this *particular* use of

-Howard

Jul 22 '05 #11
Howard wrote:
Actually, as you've just shown, sets us curly bracket notation. And, the
notation for an empty set is {}, not [n,n).
There are multiple forms of notation for sets. To say sets use curly
brackets does not exclude the use of the use of square brackets and
parentheses. The latter is commonly used in analysis (the Calculus).
All I'm saying is that it's incredibly odd to use this specific instance
of the notation: [n,n), because the left square bracket here explicitly
means to include the number following it (n), and the right paren just as
explicitly states to NOT include the number to its left (n). So... the
Ok, now I understand what you were getting at. I agree that it seems a bit
odd. OTOH, it does follow naturally from the notation, and seems to
communicate something of meaning. I'd argue that it actually says more
than simply [n,n) = {}; It says we are talking about an empty range
located (beginning) at n. It's kind of like the empty string used in
regular expressions such as the empty string at the beginning of a word.
Undoubtedly, it's convenient to say [n,n) in
order to construct a programming model from the mathematical model, and
maybe it's even commonly used (although I sure don't recall seeing it in
my degree studies), but there's no way to deny that this *particular* use

-Howard

Well..., it really depends on the subtelties of your definitions. There is
always the escape of defining the special case to mean such and such, e.g.,
x^0===1. I would argue that [n,n) is a degenerate case which
reasonably /suggests/ [n,n)==={}. But we're heading off topic.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #12
Steven T. Hatton wrote:
Howard wrote:

[...]

See what you can make of this:

http://mathworld.wolfram.com/Interval.html

I haven't formed a conclusive opinion as to whether they address the case of
[n,n).
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #13
In article <tf********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
Steven T. Hatton wrote:
Howard wrote:

[...]

See what you can make of this:

http://mathworld.wolfram.com/Interval.html

I haven't formed a conclusive opinion as to whether they address the case of
[n,n).

It's called a "half-open" or "half-closed" interval. A half-open
interval has very good properties, especially on the integers.
Especially that the union of the two intervals:

[a,b) U [b,c)

is also a half-open interval: [a,c)

See: http://mathworld.wolfram.com/Half-ClosedInterval.html
--
Mark Ping
em****@soda.CSUA.Berkeley.EDU
Jul 22 '05 #14
E. Mark Ping wrote:
In article <tf********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
Steven T. Hatton wrote:
Howard wrote:

[...]

See what you can make of this:

http://mathworld.wolfram.com/Interval.html

I haven't formed a conclusive opinion as to whether they address the case
of
[n,n).

It's called a "half-open" or "half-closed" interval. A half-open
interval has very good properties, especially on the integers.
Especially that the union of the two intervals:

[a,b) U [b,c)

is also a half-open interval: [a,c)

See: http://mathworld.wolfram.com/Half-ClosedInterval.html

We are specifically interested in the case of [a,a) i.e., [a,b) where b = a.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #15
"Howard" <al*****@hotmail.com> wrote in message
news:As*******************@bgtnsc05-news.ops.worldnet.att.net...
All I'm saying is that it's incredibly odd to use this specific instance
of the notation: [n,n), because the left square bracket here explicitly
means to include the number following it (n), and the right paren just as
explicitly states to NOT include the number to its left (n). So... the
notation contradicts itself. Undoubtedly, it's convenient to say [n,n) in
order to construct a programming model from the mathematical model, and
maybe it's even commonly used (although I sure don't recall seeing it in
my degree studies), but there's no way to deny that this *particular* use

Either that or your notion of what the notation represents should be

Here's another way to look at it: For all integers m, n, the notation "[m,
n)" is the ascending sequence of integer values k, with the property that m
<= k and k < n. Now the contradiction vanishes.
Jul 22 '05 #16
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:tf********************@speakeasy.net...
See what you can make of this:

http://mathworld.wolfram.com/Interval.html
It talks about real numbers, not integers, but is relvant aside from that.
Note that there are lots of issues, such as compactness, that apply to reals
but not to integers.
I haven't formed a conclusive opinion as to whether they address the case
of
[n,n).

They do, by saying that treating the empty set as an integral makes a bunch
of other properties equivalent. By implication, they could choose to define
the notion of interval to exclude the empty set, but they feel it is more
useful to do otherwise.
Jul 22 '05 #17
In article <Qc********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
E. Mark Ping wrote:
Especially that the union of the two intervals:

[a,b) U [b,c)

is also a half-open interval: [a,c)

See: http://mathworld.wolfram.com/Half-ClosedInterval.html
We are specifically interested in the case of [a,a) i.e., [a,b) where
b = a.

My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

Similarly, 0! is commenly defined as 1 becuase it's most useful with
that definition in combinatorics, but AFAIK it's not a universally
accepted definition.
--
Mark Ping
em****@soda.CSUA.Berkeley.EDU
Jul 22 '05 #18
E. Mark Ping wrote:
My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

Similarly, 0! is commenly defined as 1 becuase it's most useful with
that definition in combinatorics, but AFAIK it's not a universally
accepted definition.

I have a serious reservation about accepting the idea of [a,a) = {}. After
thinking it over, it seems to me that [a,a) carries more information than
{}. In order for [a,a) = {} to be true, [a,a) = [b,b) where a != b; I'm
not sure I'm willing to accept that proposition. In particular, I'm not
sure I'm willing to extend it to the concept of indexing of memory
locations.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #19
In article <1v********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
E. Mark Ping wrote:
My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

Similarly, 0! is commenly defined as 1 becuase it's most useful with
that definition in combinatorics, but AFAIK it's not a universally
accepted definition.
I have a serious reservation about accepting the idea of [a,a) = {}. After
thinking it over, it seems to me that [a,a) carries more information than
{}.
In order for [a,a) = {} to be true, [a,a) = [b,b) where a != b; I'm
not sure I'm willing to accept that proposition.
I don't know why not. Note the equivalence:

[a,a) U [a,b) = [a,b)
[b,b) U [a,b) = [a,b)

Definining [a,a) = {} is just as useful as defining 0! = 1.
In particular, I'm not sure I'm willing to extend it to the concept
of indexing of memory locations.

Why not?

while (p!=q)
{
*p++ = *q++;
}

Is meaningful for p and q even if p==q at the beginning of the loop.
--
Mark Ping
em****@soda.CSUA.Berkeley.EDU
Jul 22 '05 #20
E. Mark Ping wrote:
In article <1v********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
E. Mark Ping wrote:
My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

Similarly, 0! is commenly defined as 1 becuase it's most useful with
that definition in combinatorics, but AFAIK it's not a universally
accepted definition.

I have a serious reservation about accepting the idea of [a,a) = {}.
After thinking it over, it seems to me that [a,a) carries more information
than
{}.

In order for [a,a) = {} to be true, [a,a) = [b,b) where a != b; I'm
not sure I'm willing to accept that proposition.

I don't know why not. Note the equivalence:

[a,a) U [a,b) = [a,b)
[b,b) U [a,b) = [a,b)

Definining [a,a) = {} is just as useful as defining 0! = 1.
In particular, I'm not sure I'm willing to extend it to the concept
of indexing of memory locations.

Why not?

while (p!=q)
{
*p++ = *q++;
}

Is meaningful for p and q even if p==q at the beginning of the loop.

If I am discussing a finite range of indices [0,n) and choose some index m
such that 0 < m < n, I can write [m,m) to signify an empty sequence
beginning at m. Hence I can indicate the mth element with the notation
[m,m+1). If I assume [m,m) = [p,p) where p!=m, I am in effect saying
[m,m+1) = [p,p+1) which is false.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #21
Dave Townsend wrote:

"E. Mark Ping" <em****@soda.csua.berkeley.edu> wrote in message
Okay, that makes sense that [a,a) != [b,b) but that just means that
[a,a) != {}. It's not the empty set, it's /an/ empty /sequence/,
starting at a. That's how it's used typically anyway.

Surely [a,a) == [b,b) = {} in the same way that {1} ^ { 2 } = {} = {duck }
^
{ fox },etc ,
ie, any number of expression may evaluate to the empty set, even if the
expressions
have little relationship with each other.
I don't know what you mean here. The point I was making, and which Mark
seems to agree with is that [a,a) != [b,b).
I'm not following why this is such a big deal, the notation [) makes
perfect sense when dealing with ranges, as Andrew Koenig pointed out.

I marked the thread OT because I didn't find the topic overly relevant to
the general topic of C++, but it seemed to be something others were
interested in. I agree that the notation works for ranges, and calling
[a,a) the empty sequence (or interval) beginning at /a/ makes sense. It is
actually a fairly useful concept. For example, the notation \< in Emacs
regular expression syntax denotes the empty string at the beginning of a
word. My point was one of mathematical rigor. I don't believe Accelerated
C++ actually says [a,a) denotes the empty /set/. That wording arose in the
context of this discussion.

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #22
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:K5********************@speakeasy.net...
I don't know what you mean here. The point I was making, and which Mark
seems to agree with is that [a,a) != [b,b).

The question is whether you want to talk about equality of ranges in terms
of their bounds, or in terms of the elements they represent. Both ways of
viewing ranges are useful in different contexts, so it's a matter of choice.

The usual mathematical usage is to talk about ranges solely in terms of
their elements, because there are other ways of talking about the bounds if
that's what you want. So the usual usage is to note that, for example, [3,
3) and [5, 5) are two different representations of the empty set. The
representations are different, but they represent the same set.
Jul 22 '05 #23
Andrew Koenig wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:K5********************@speakeasy.net...
I don't know what you mean here. The point I was making, and which Mark
seems to agree with is that [a,a) != [b,b).
The question is whether you want to talk about equality of ranges in terms
of their bounds, or in terms of the elements they represent. Both ways of
viewing ranges are useful in different contexts, so it's a matter of
choice.

Understood. The ultimate test of a mathematical proposition is consistency
with the axioms assumed. Unfortunately, much of mathematical literature is
not as clear about fundamental assumptions as it should be. I have
discovered that, not infrequently, mathematicians tend to operate on the
basis of preconceived and nebulous foundations, deriving from these
foundations what I hold to be axiomatic, or assuming things which I derive
to be axiomatic.
The usual mathematical usage is to talk about ranges solely in terms of
their elements, because there are other ways of talking about the bounds
if
that's what you want. So the usual usage is to note that, for example,
[3,
3) and [5, 5) are two different representations of the empty set. The
representations are different, but they represent the same set.

I will have to leave my opinion unformed on this matter since I don't have
time to investigate a sufficient number of resources to form a conclusion.
I certainly will grant that defining [a,a) === {} is likely to be
consistent with a substantial mathematical theory. I find attempting to
represent such expressions in software to be an interesting exercise. For
example, what is it that we are actually saying is 'empty'? The set of
indices, or the set of things to which these indices refer?

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #24
em****@soda.csua.berkeley.edu (E. Mark Ping) wrote in message news:<cm***********@agate.berkeley.edu>...
In article <Qc********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
E. Mark Ping wrote:
Especially that the union of the two intervals:

[a,b) U [b,c)

is also a half-open interval: [a,c)

See: http://mathworld.wolfram.com/Half-ClosedInterval.html
We are specifically interested in the case of [a,a) i.e., [a,b) where
b = a.

My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

with a topology, ie specifying which sets are open. In the standard
topology, sets (a,b), a<=b, (a,a) "denoting" empty set (same as
0.9999.... denotes 1). These sets are well and constructively defined
based on the aximos reals and set theoretic operations: we take two
ordered points a,b, consdier set {x| a<=x<=b} and then define (a,b) =
{x| a<=x<=b}\{a, b}. Existence of such x follows from the
Dedekind-completeness (continuity) axiom.

Now, first, we see that (a,a) = {}, simply by construction.

Furthermore, we introduce "nomenclature"

[a,b) = {a} U (a,b) = [a] U (a,b),

and

[a,b] = [a,b) U {b}

which implies that [a,a) = {a}, as (a,a) = {}, and that {a} = [a, a].

Similarly, 0! is commenly defined as 1 becuase it's most useful with
that definition in combinatorics, but AFAIK it's not a universally
accepted definition.

Well, x! is a manning from naturals. You can simply extend it to
nonnegatives.

d
Jul 22 '05 #25
Andre Dajd wrote:
em****@soda.csua.berkeley.edu (E. Mark Ping) wrote in message
news:<cm***********@agate.berkeley.edu>...
In article <Qc********************@speakeasy.net>,
Steven T. Hatton <su******@setidava.kushan.aa> wrote:
>E. Mark Ping wrote:
>> Especially that the union of the two intervals:
>>
>> [a,b) U [b,c)
>>
>> is also a half-open interval: [a,c)
>>
>> See: http://mathworld.wolfram.com/Half-ClosedInterval.html

>We are specifically interested in the case of [a,a) i.e., [a,b) where
>b = a.

My apologies for being too terse. I've never seen standard
nomenclature for [a,a), but it makes sense in this case to define it
as the empty set, since that means the union property holds:

[a,a) U [a,b) = [a,b)

with a topology, ie specifying which sets are open. In the standard
topology, sets (a,b), a<=b, (a,a) "denoting" empty set (same as
0.9999.... denotes 1). These sets are well and constructively defined
based on the aximos reals and set theoretic operations: we take two
ordered points a,b, consdier set {x| a<=x<=b} and then define (a,b) =
{x| a<=x<=b}\{a, b}. Existence of such x follows from the
Dedekind-completeness (continuity) axiom.

Now, first, we see that (a,a) = {}, simply by construction.

Furthermore, we introduce "nomenclature"

[a,b) = {a} U (a,b) = [a] U (a,b),

and

[a,b] = [a,b) U {b}

which implies that [a,a) = {a}, as (a,a) = {}, and that {a} = [a, a].

My caution in accepting this is that it seems to neglect the concept of
position. There are two approaches to describing tensors which I believe
are relevant to this discussion. One approach is to talk about vectors as
simply the n-tuples of ordered sets which remain invariant under
transformations of coordinates. Another approach maintains that a tensor
is a function of position, and hence it is not meaningful to discuss them
without reference to the location in space where their components are
evaluated.

I can accept that mathematicians do use the definitions you are using to
construct dominant theories. That doesn't mean that other equally
successfull axioms cannot be posited as the foundations of a consistent and
useful theory.

Just as a simple example involving memory addressing, consider the
alternative approaches available for determining the equivalence of two
ranges. We could define the ranges using objects like this:

class range{
float* _lb;
float* _ub;
public:

range(float* lb_, float* ub_):_lb(lb_), _ub(ub_){}
//... populate with data

bool operator==(const range& r){
if(_ub - _lb != r._ub - r._lb) {
throw std::domain_error("comparing incongruent ranges");
}

float* p = _lb;
float* pr = r._lb;

while(p < _ub) {
if(*p++ != *pr++) {return false;}
}
return true;
}

};

Alternatively we could write the equivalence operator as follows:
bool operator==(const range& r){ return (_ub == _lb && r._ub == r._lb); }

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #26
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message news:<xv********************@speakeasy.net>...
Andre Dajd wrote: [snip] My caution in accepting this is that it seems to neglect the concept of
position. There are two approaches to describing tensors which I believe
are relevant to this discussion. One approach is to talk about vectors as
simply the n-tuples of ordered sets which remain invariant under
transformations of coordinates. Another approach maintains that a tensor
is a function of position, and hence it is not meaningful to discuss them
without reference to the location in space where their components are
evaluated.

I can accept that mathematicians do use the definitions you are using to
construct dominant theories. That doesn't mean that other equally
successfull axioms cannot be posited as the foundations of a consistent and
useful theory.

Sure they can. What are talking about here are vector spaces (in
which tensors are defined) and affine spaces. The latter differs from
the former, effectively, by removing "0", ie loosing the notion of
"beginning", hence making only the notion of "difference" = "relative
position" meaningful. This is simply a different object from "vector
space", having specific properties and useful in corresponding fields.

http://mathworld.wolfram.com/AffineSpace.html

So, one should only be clear what he is talking about and then there
will be no ambiguities

:)

d
Jul 22 '05 #27
Andre Dajd wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:<xv********************@speakeasy.net>...
Andre Dajd wrote:

[snip]
My caution in accepting this is that it seems to neglect the concept of
position. There are two approaches to describing tensors which I believe
are relevant to this discussion. One approach is to talk about vectors
as simply the n-tuples of ordered sets which remain invariant under
transformations of coordinates. Another approach maintains that a tensor
is a function of position, and hence it is not meaningful to discuss them
without reference to the location in space where their components are
evaluated.

I can accept that mathematicians do use the definitions you are using to
construct dominant theories. That doesn't mean that other equally
successfull axioms cannot be posited as the foundations of a consistent
and useful theory.

Sure they can. What are talking about here are vector spaces (in
which tensors are defined) and affine spaces. The latter differs from
the former, effectively, by removing "0", ie loosing the notion of
"beginning", hence making only the notion of "difference" = "relative
position" meaningful. This is simply a different object from "vector
space", having specific properties and useful in corresponding fields.

http://mathworld.wolfram.com/AffineSpace.html

So, one should only be clear what he is talking about and then there
will be no ambiguities

:)

d

No. I'm talking about a vector being defined as an n-valued function of the
coordinate system.
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #28

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