EmbeddedRelated.com
Forums
Memfault State of IoT Report

How to Auto-generate Unique Labels in C?

Started by aekalman November 23, 2004
----- Original Message ----- 
From: "Paul Curtis" <plc@plc@...>
To: <msp430@msp4...>
Sent: Tuesday, November 23, 2004 11:09 PM
Subject: RE: [msp430] Re: How to Auto-generate Unique Labels in C?


> 
> Andrew, 
> 
>> --- In msp430@msp4..., "Paul Curtis" <plc@r...> wrote: 
>> > #define DoLabel(X) X
>> > #define MyUniqueLabelMacro() A##DoLabel(__LINE__)
>> > 
>> > This generates identifiers of the type A<linenumber.  This is a
>> use-once
>> > macro, you can use it exactly once to define a label but
can't use
>> it to
>> > reference a label.  If the labels are only inside compounds, then
>> they
>> > are scoped by the compiler so there are no name clashes possible
>> anyway.
>> 
>> 1) Why is DoLabel(x) x required? Why doesn't A##__LINE__ 
>> work? Why the extra subsitution layer?
> 
> As a man of considerable merit in the C preprocessor world, I would have
> though you should know the answer to this one.  I'm sure it's a
FAQ.  If
> you use A##__LINE__ you'll get A__LINE__ all the time as __LINE__
won't
> be expanded.  Wrapping __LINE__ up in a macro that expands to the
> expansion of __LINE__ is how you get round this particular problem.
> 
>> 2) IINM, the scheme you've proposed works fine within a 
>> single file, in C. But I've seen assemblers that can 
>> reference EXTERN labels in all of the C files of a project. 
> 
> Boy.  What a nightmare.
> 
>> To do that, each label name must be unique (i.e. not allowed 
>> to have labels in two files with the same LINE number). Is 
>> there a way in C to get around that?
> 
> The only way is to have the user define a unique prefix based on file
> name or something else.  I can't see a way to do it in any variant of
C.
> 
>> m4 (dunno what that is) is not an option for me -- must stay 
>> within the ANSI C preprocessor.
> 
> m4 is an elderly macro processor distributed with Unix System III, IIRC.
> Once a program is put into the Unix pot, it never gets thrown out.

A DOS version is available, which I use occasionally.

Leon

Beginning Microcontrollers with the MSP430

--- In msp430@msp4..., onestone <onestone@b...> wrote:
> here again we find ourselves in agreement. The
only things that are
fun 
> to do are those that most others figure can't
be done. This doesn't
make 
> you smart. Just devious and twisted perhaps
:<>. The number of
people in 
> academia who've never had to earn a living
from what they teach
astounds 
> me, there is a vast difference between engineering
and teaching it
in my 
> opinion. But that's another OT story best
kept until the list goes
dead 
> once more.

Well said, Al.

--Andrew E. Kalman, Ph.D.
(E is not actually for Emil, nor for Esoteric)
aek at pumpkin inc dot com




aekalman wrote:
> 
> --- In msp430@msp4..., onestone <onestone@b...> wrote:
> 
>>here again we find ourselves in agreement. The only things that are
> 
> fun 
> 
>>to do are those that most others figure can't be done. This
doesn't
> 
> make 
> 
>>you smart. Just devious and twisted perhaps :<>. The number of
> 
> people in 
> 
>>academia who've never had to earn a living from what they teach
> 
> astounds 
> 
>>me, there is a vast difference between engineering and teaching it
> 
> in my 
> 
>>opinion. But that's another OT story best kept until the list goes
> 
> dead 
> 
>>once more.
> 
> 
> Well said, Al.

Just bitter memories to some extent :<{
not that you can remain bitter and twisted for too long when there's so 
much fun to be had.

> 
> --Andrew E. Kalman, Ph.D.

For all the posts here, and all the times we've posted I never tied you 
to THAT Kalman, perhaps because I always think of you as AEKALMAN the 
PUMPKIN GUY. (Psycho processed as ACHE-AL MAN). Much Kudos indeed. A 
truly brilliant thing I have often had cause to wrestle with, and still 
somehtign I think I'm a beginner at.

> (E is not actually for Emil, nor for Esoteric)

Evo-lutionary? Enigmatic? Extracurricular? Extraterrestrial? just plain 
Extra? Eric? Edward? Edipus, without the O?

Cheers

Al, MMC, NB*

> aek at pumpkin inc dot com
> 
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 


On Tue, 23 Nov 2004 17:55:44 -0800, Richard wrote:

>Google for "Kalman Filter" for people who
are wondering what the heck 
>Andrew is talking about,

R. E. Kalman?  I was curious a couple of years ago but felt it was impolite to
ask, as each of us should be judged for who they are not who their parents were
(and it really wasn't any of my business.)  But now I know.  ;)

Jon

I will take a bet that Andrew is referring to the March 1960 paper of 
R. E. Kalmam entitled 'A New Approach to Linear Filtering and 
Prediction Problems' published in the Transactions of the American 
Society of Mechanical Engineers-Journal of Basic Engineering.

The first page of the paper states upfront "This research was 
supported in part by the U. S. Air Force Office of Scientific 
Research under Contract AF 49 (638)-382."

Given what we now know about the enormous military and aeronautical 
significance (including for NASA) of what came to be called 
the 'Kalmam Filter' for navigation and guidance, maybe we can 
speculate, using information provided by Andrew below, as to how this 
research slipped into the public domain without becoming classified.

Act 2, Scene 3
Military officer rings up Kalman's research supervisor. 

Military: "How is Kalman's research going?".

Supervisor: "I can't get through to him. He is obsessed about 
demonstrating mechanical regulators and random processes are 
equivalent. He is driving me nuts."

Military: "Should the research be classified?"

Supervisor: "Nope, we will be sending him home to Hungary without his 
Ph.D. Shame. He had such promise."

Military: "Thanks. I guess we won't offer him a job or a post 
doctoral research fellowship then."

This is my current version of a simple expression of what the Kalman 
filter is. By far the best source of information is the original 
paper itself. An OCR scanned copy is available online.

1. Assume the use of statistical estimates instead of exact values.
2. Assume random interference (noise) matches certain statistical 
distributions.
3. Assume use of a the state-transition method (which is highly 
suitable to digital processing environments).
4. Assume a process that can be modelled as a linear dynamic system 
as expressed by the classical Wiener filtering and prediction problem 
with unknown coefficients.

Then the Kalman filter provides, in a  single derivation solution,  a 
set of optimal estimation filtering coefficients to a large variety 
of problems (not all problems) that can be expressed by the classical 
Wiener filtering and prediction problem.

The regulator part of the paper is now largely forgotten except among 
esoteric system and control circles. Kalman proposed a duality 
between optimal estimation and the noise-free regulator problem. 

To quote from the 1960 paper "The physical significance of the 
duality is intriguing. Why are observations and control dual 
quantities?"

I wonder of R. E. Kalman got his answer and if not if he still cares?

John Heenan


--- In msp430@msp4..., "aekalman" <aek@p...> wrote:
> 
> --- In msp430@msp4..., onestone <onestone@b...> wrote:
> > It isn't something I could ever imagine wanting, let alone see as
> desirable.
> 
> This reminds me of something my Dad told me about his doctoral exam 
at
> Columbia ... One of the reviewers said something
to the effect that
> "this cannot be right, yada yada yada" and basically refused to
sign
> off on it.
> 
> So, Dad went and published his work in a mechanical engineering
> journal instead.
> 
> The rest, as they say, is history.
> 
> I think it's interesting that I gravitate towards stuff that other
> people say can't work, can't be done, etc. I'm by no means
the
> smartest guy around (or on this list), but I do enjoy a challenge. 
> 
> --Andrew E. Kalman, Ph.D.
> aek at pumpkin inc dot com




Paul Curtis wrote:
> Sure, you can't compile Linux without GCC... 
;-)

You can compile it with TCC with some patches and I think with ICC 
(Intel not Imagecraft). This TCC demo is pointless but very impressive 
nevertheless:
http://fabrice.bellard.free.fr/tcc/tccboot.html

-- 
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer

John ,
You are sooooooooooo.... true.!
Another one could be  a 1964 Conference in Stability theory , where 
V.M.Popov presented his hyperstability  theory, nobody understood what that 
was, until he got an invitation to come to the States , and as they say  the 
rest is  history.

Karl.

>From: "John Heenan" <l10@l10@...>
>Reply-To: msp430@msp4...
>To: msp430@msp4...
>Subject: [msp430] Kalman Filter was Re: How to Auto-generate Unique Labels 
>in C?
>Date: Wed, 24 Nov 2004 10:44:50 -0000
>
>
>
>I will take a bet that Andrew is referring to the March 1960 paper of
>R. E. Kalmam entitled 'A New Approach to Linear Filtering and
>Prediction Problems' published in the Transactions of the American
>Society of Mechanical Engineers-Journal of Basic Engineering.
>
>The first page of the paper states upfront "This research was
>supported in part by the U. S. Air Force Office of Scientific
>Research under Contract AF 49 (638)-382."
>
>Given what we now know about the enormous military and aeronautical
>significance (including for NASA) of what came to be called
>the 'Kalmam Filter' for navigation and guidance, maybe we can
>speculate, using information provided by Andrew below, as to how this
>research slipped into the public domain without becoming classified.
>
>Act 2, Scene 3
>Military officer rings up Kalman's research supervisor.
>
>Military: "How is Kalman's research going?".
>
>Supervisor: "I can't get through to him. He is obsessed about
>demonstrating mechanical regulators and random processes are
>equivalent. He is driving me nuts."
>
>Military: "Should the research be classified?"
>
>Supervisor: "Nope, we will be sending him home to Hungary without his
>Ph.D. Shame. He had such promise."
>
>Military: "Thanks. I guess we won't offer him a job or a post
>doctoral research fellowship then."
>
>This is my current version of a simple expression of what the Kalman
>filter is. By far the best source of information is the original
>paper itself. An OCR scanned copy is available online.
>
>1. Assume the use of statistical estimates instead of exact values.
>2. Assume random interference (noise) matches certain statistical
>distributions.
>3. Assume use of a the state-transition method (which is highly
>suitable to digital processing environments).
>4. Assume a process that can be modelled as a linear dynamic system
>as expressed by the classical Wiener filtering and prediction problem
>with unknown coefficients.
>
>Then the Kalman filter provides, in a  single derivation solution,  a
>set of optimal estimation filtering coefficients to a large variety
>of problems (not all problems) that can be expressed by the classical
>Wiener filtering and prediction problem.
>
>The regulator part of the paper is now largely forgotten except among
>esoteric system and control circles. Kalman proposed a duality
>between optimal estimation and the noise-free regulator problem.
>
>To quote from the 1960 paper "The physical significance of the
>duality is intriguing. Why are observations and control dual
>quantities?"
>
>I wonder of R. E. Kalman got his answer and if not if he still cares?
>
>John Heenan
>
>
>--- In msp430@msp4..., "aekalman" <aek@p...> wrote:
> >
> > --- In msp430@msp4..., onestone <onestone@b...> wrote:
> > > It isn't something I could ever imagine wanting, let alone
see as
> > desirable.
> >
> > This reminds me of something my Dad told me about his doctoral exam
>at
> > Columbia ... One of the reviewers said something to the effect that
> > "this cannot be right, yada yada yada" and basically refused
to sign
> > off on it.
> >
> > So, Dad went and published his work in a mechanical engineering
> > journal instead.
> >
> > The rest, as they say, is history.
> >
> > I think it's interesting that I gravitate towards stuff that
other
> > people say can't work, can't be done, etc. I'm by no
means the
> > smartest guy around (or on this list), but I do enjoy a challenge.
> >
> > --Andrew E. Kalman, Ph.D.
> > aek at pumpkin inc dot com
>
>
>
>
>
>
>.
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


--- In msp430@msp4..., "Karl Adler" <specific2@m...> wrote:
> John ,
> You are sooooooooooo.... true.!
> Another one could be  a 1964 Conference in Stability theory , where 
> V.M.Popov presented his hyperstability  theory, nobody understood
what that 
> was, until he got an invitation to come to the
States , and as they
say  the 
> rest is  history.

I presume that's the Popov who my parents sometimes had over for
dinner. Those mathematicians like to stick together ... :-)

 
> >From: "John Heenan" <l10@a...>
> >Reply-To: msp430@msp4...
> >To: msp430@msp4...
> >Subject: [msp430] Kalman Filter was Re: How to Auto-generate Unique
Labels 
> >in C?
> >Date: Wed, 24 Nov 2004 10:44:50 -0000

> >I will take a bet that Andrew is referring to
the March 1960 paper
of
> >R. E. Kalmam entitled 'A New Approach to
Linear Filtering and
> >Prediction Problems' published in the Transactions of the American
> >Society of Mechanical Engineers-Journal of Basic Engineering.

Indeed.

> >To quote from the 1960 paper "The
physical significance of the
> >duality is intriguing. Why are observations and control dual
> >quantities?"
> >
> >I wonder of R. E. Kalman got his answer and if not if he still
cares?

Note that the Kalman filter was never patented (by my Dad, at least).
Jack Bertram of IBM Research often told my Dad he ought to pursue some
sort of IP protection -- IBM ended up using it in their disk drives
and other places. But once he had written the paper, his interests
turned elsewhere. Nowadays he works on a variety of problems that
interest him.

Enough (from me) about my Dad -- as Jon K. pointed out, it's impolite
for me to go on about it.

--Andrew E. Kalman, Ph.D.
aek at pumpkin inc dot com




On Wed, 24 Nov 2004 16:23:34 -0000, you wrote:

>Enough (from me) about my Dad -- as Jon K. pointed
out, it's impolite
>for me to go on about it.

Hehe.  No, I said (or hoped I said) that it was impolite for me to inquire about
it.  Each of us should be measured by who we are, ourselves, and how we progress
against our own measures.

But, of course, now that I know, I'll be sending you all my confusions over
continuous and non-continuous time Kalman/Bucy problems.  ;)

Jon

At 11:46 AM 11/24/2004, Jonathan Kirwan wrote:
>....
>
>But, of course, now that I know, I'll be sending you all my confusions
over
>continuous and non-continuous time Kalman/Bucy problems.  ;)

But who sez ANDREW knows anything about Kalman filter? :-)

Me? I got lost when the words goes from Kalman to "Filter." :-)


// richard (This email is for mailing lists. To reach me directly, please 
use richard at imagecraft.com) 



Memfault State of IoT Report