I have a small question. In matlab we have eps to look what the floating
point relative accurancy is. Is there also a function in C/C++ for doing
this.
Thanks
Joeri
In C++ there is std::numeric_limits<double>::epsilon() function
and std::numeric_limits<float>::epsilon() function. In C (and
acceptable in C++) there are FLT_EPSILON, DBL_EPSILON and
LDBL_EPSILON defined in <limits.h>. AFAIK, there is no function
in both C and C++ (C/C++ as you put it), but macros from <limits.h>
should be sufficient.
Victor
--
Please remove capital A's from my address when replying by mail
Alternately, if you want to calculate it, Cleve described a quick
approximation technique in one of his Cleve's Corners:
http://www.mathworks.com/company/newsletter/pdf/Fall96Cleve.pdf
Execute the C/C++ equivalent of the code in the box on the first page; the
first full paragraph in the second column of the second page describes it.
--
Steve Lord
sl...@mathworks.com
Joeri Verbiest wrote:
I found
http://www.softintegration.com/products/features/ch_vs_matlab.html
might be useful for porting Matlab code to C/C++ or C like.
Porting eps in Matlab to DBL_EPSILON is lited as well.
The characteristic features of floating point numbers are
defined in header file float.h in C/C++.
esp in Matlab can be replaced by
DBL_EPSILON for double in C/C++.
In fact, C/C++ has FLT_EPSILON for float which is not available in Matlab.
However, I think Matlab might be able to convert Matlab code
to C/C++.
>
>
> Thanks
>
> Joeri
In Matlab, I have the following variables:
>> a = rand(3,2);
>> b = 0*a;
Normally one would expect 'b' to be 0 (singleton zero). But matlab produces
a zero matrix of size 3x2 for 'b'. Is there anyway to get rid of this problem?
Thanks and regards,
Lenin.
--
______________________________________________
Dr. R.B. Lenin
Department of Mathematics and Computer Science
University of Antwerp, Universiteitsplein 1
B-2610 Antwerp, Belgium
Tel: +32-3-8202416 Fax: +32-3-8202421
Email: le...@uia.ua.ac.be
Url: http://win-www.uia.ac.be/u/lenin/
______________________________________________
Hello. Please do come back to comp.lang.c and comp.lang.c++ ... WHEN you have
questions about C or C++.
>>> a = rand(3,2);
>>> b = 0*a;
>
> Normally one would expect 'b' to be 0 (singleton zero).
One who understood elementary matrix operations would expect no such thing.
> Is there anyway to get rid of this problem?
The problem is your ignorance. To get rid of it, read a book about matrices,
and some FAQs about netiquette.
--
Donovan
>Hello there,
>
>In Matlab, I have the following variables:
>
>>> a = rand(3,2);
>>> b = 0*a;
>
>Normally one would expect 'b' to be 0 (singleton zero). But matlab produces
>a zero matrix of size 3x2 for 'b'. Is there anyway to get rid of this problem?
As someone who never worked with matlab, I suppose I have no business
posting something here ... but it looks like you need a "." instead of
a "," between the 3 and the 2.
(BTW, what does this have to do with Standard C++ ?????)
Bob Hairgrove
rhairgro...@Pleasebigfoot.com
Ken
"Bob Hairgrove" <rhairgro...@Pleasebigfoot.com> wrote in message
news:3cbb1b43...@news.ch.kpnqwest.net...
My guess is he made a goof with his news reader. Something tells me he is
smarter than the matrix question he is asking about. We'll give him a break.
Sean
"Donovan Rebbechi" <elf...@panix.com> wrote in message
news:slrnabm2og....@panix2.panix.com...
Was yours? You top-posted an unsnipped reply without adding any new
information.
BTW, can YOU spot Lenin's question about C and C++? I for one
certainly can't.
Also, how can anyone who has opened a basic textbook on linear algebra
think that 0*a, where a is a 3*2 matrix, will equal singleton zero?
> "Donovan Rebbechi" <elf...@panix.com> wrote in message
> news:slrnabm2og....@panix2.panix.com...
>> In article <3cbb069d$1...@news.uia.ac.be>, Lenin.Bhavanandan wrote:
>> > Hello there,
>> >
>> > In Matlab, I have the following variables:
>>
>> Hello. Please do come back to comp.lang.c and comp.lang.c++ ... WHEN you
> have
>> questions about C or C++.
>>
>> >>> a = rand(3,2);
>> >>> b = 0*a;
>> >
>> > Normally one would expect 'b' to be 0 (singleton zero).
>>
>> One who understood elementary matrix operations would expect no such
> thing.
>>
>> > Is there anyway to get rid of this problem?
>>
>> The problem is your ignorance. To get rid of it, read a book about
> matrices,
>> and some FAQs about netiquette.
--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"I will never display my bum in public again."
- Homer Simpson
"Joona I Palaste" <pal...@cc.helsinki.fi> wrote in message
news:a9gsmt$gi4$1...@oravannahka.helsinki.fi...
You're still top-posting, but otherwise I think you're OK.
> "Joona I Palaste" <pal...@cc.helsinki.fi> wrote in message
> news:a9gsmt$gi4$1...@oravannahka.helsinki.fi...
>> "AJ \"no z\" Johnson" <aj.jo...@lmco.com> scribbled the following
>> on comp.lang.c:
>> > Well, that wasn't exactly a stellar example of netiquette, was it?
>> > -Aj
>>
>> Was yours? You top-posted an unsnipped reply without adding any new
>> information.
>> BTW, can YOU spot Lenin's question about C and C++? I for one
>> certainly can't.
>>
>> Also, how can anyone who has opened a basic textbook on linear algebra
>> think that 0*a, where a is a 3*2 matrix, will equal singleton zero?
--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Insanity is to be shared."
- Tailgunner
> You're still top-posting, but otherwise I think you're OK.
Ah, what can you expect from a Lock-Mart guy?
;)
Brian Rodenborn
>> You're still top-posting, but otherwise I think you're OK.
> Ah, what can you expect from a Lock-Mart guy?
> ;)
Huh? I don't understand this. Is it some kind of cultural thing?
--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
- Mika P. Nieminen
> Default User <first...@company.com> scribbled the following
> on comp.lang.c:
>> Joona I Palaste wrote:
>
>>> You're still top-posting, but otherwise I think you're OK.
>
>> Ah, what can you expect from a Lock-Mart guy?
>
>> ;)
>
> Huh? I don't understand this. Is it some kind of cultural thing?
It was a reference to Lockheed Martin, a very large defense contractor in
the USA. Note Mr. Johnson's mail address.
http://www.lockheedmartin.com/
I won't comment on why you would expect top-posting from a Lockheed Martin
employee; I'm not sure about that myself.
-Daniel
> > Ah, what can you expect from a Lock-Mart guy?
>
> > ;)
>
> Huh? I don't understand this. Is it some kind of cultural thing?
It's a US aerospace industry thing.
Brian Rodenborn
>Joona I Palaste <pal...@cc.helsinki.fi> wrote in
>news:a9hn14$b74$1...@oravannahka.helsinki.fi:
>
>>
>> Huh? I don't understand this. Is it some kind of cultural thing?
>
>It was a reference to Lockheed Martin, a very large defense contractor in
>the USA. Note Mr. Johnson's mail address.
>
>http://www.lockheedmartin.com/
>
>I won't comment on why you would expect top-posting from a Lockheed Martin
>employee; I'm not sure about that myself.
Brian probably works for a competitor. If I saw a posting from someone
daft enough to admit to working at SocGen I'd probably be equally
disparaging in a friendly sort of way. After all, its not /their/
fault, they just needed the money.... :->
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
Zactly.
Brian Rodenborn
OK, I'll be a team-player. (What do you want - I'm using Microsoft
newsreader!)
-Aj
"A man who thinks he is wise is not."