help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong 'log' results when using .oct files


From: adler
Subject: Re: Wrong 'log' results when using .oct files
Date: Thu, 11 Jan 2001 21:09:26 -0500 (EST)

I'm unable to duplicate this problem. I
have a PII 233 under RedHat 6.2, octave 2.1.32


On Wed, 10 Jan 2001, Javier Perez wrote:
> I'm trying to compute the logarithm in base 2 of a number, in C++, since it's
> part of a .oct file. The code is really simple, and it works fine in a
> standalone program. The problem is that when used inside a .oct file, the file
> "octave/config.h" is included, and the results change. Am I doing some stupid
> mistake? Should I use a different way of computing the logarithm?? 
> 
> This simple code demonstrates my problem:
> 
> <-------- begin: "test_log.cc" ------------>
> #include <octave/config.h>
> 
> #include <iostream>
> #include <math.h>
> 
> int main() {
> 
>     int M = 8;
>     double j = log(M)/log(2);
>     std::cout << "(int) log2(" << M << "): " << j << " " << (int)j << 
> std::endl;
> 
>     return 1;
> }
> 
> <-------- end: "test_log.cc" ------------->
> 
> I'm compiling using:
> 
> gcc -O3 -mcpu=k6 -mieee-fp -fno-rtti -fno-exceptions -fPIC
> -fno-implicit-templates -o test_log test_log.cc -lg++
> -I/home/jape/local//include/octave-2.1.32
> -I/home/jape/local//include/octave-2.1.32/octave -I/home/jape/local//include
> -I/home/jape/cur/functions
> 
> Commenting out the line 
>       #include <octave/config.h>
> everything works fine, and I obtain the result "3". 
> 
>       address@hidden:~/cur/# ./test_log 
>       (int) log2(8): 3 3
> 
> The problem is when including that file, because the result is "2".
> 
>       address@hidden:~/cur/# ./test_log
>         (int) log2(8): 3 2
> 
> Any idea why is this way?
> 
> Thanks in advance
> 
> I include the results of the bug report tool:
> 
> Subject: [50 character or so descriptive subject here (for reference)]
> --------
> Bug report for Octave 2.1.32 configured for %OCTAVE_CANONICAL_HOST_TYPE%
> 
> 
> Configuration (please do not edit this section):
> -----------------------------------------------
> 
> uname output:     Linux shiraz 2.2.14 #5 SMP Tue Mar 14 22:11:28 CET 2000 i586
> unknown
> configure opts:   --prefix=/home/jape/local/ --enable-shared
> Fortran compiler: g77
> FFLAGS:           -O3 -mcpu=k6
> F2C:              
> F2CFLAGS:         
> FLIBS:            -lg2c -lm -L/usr/lib/gcc-lib/i386-linux/2.95.2 -lm
> CPPFLAGS:         
> INCFLAGS:         -I. -I. -I./liboctave -I./src -I./libcruft/misc  -I./glob
> -I./glob
> C compiler:       gcc, version 2.95.2 20000220 (Debian GNU/Linux)
> CFLAGS:           -O3 -mcpu=k6
> CPICFLAG:         -fPIC
> C++ compiler:     c++, version 2.95.2 20000220 (Debian GNU/Linux)
> CXXFLAGS:         -O3 -mcpu=k6
> CXXPICFLAG:       -fPIC
> LDFLAGS:          -g
> LIBFLAGS:         -L.
> RLD_FLAG:         -Xlinker -rpath -Xlinker /home/jape/local//lib/octave-2.1.32
> TERMLIBS:         -lncurses
> LIBS:             -ldl -lhdf5 -lm 
> LEXLIB:           
> LIBPLPLOT:        
> LIBDLFCN:         
> LIBGLOB:          ./glob/glob.o ./glob/fnmatch.o
> DEFS:
> 
>   -DOCTAVE_SOURCE=1 -DSEPCHAR=':' -DSEPCHAR_STR=":" -DUSE_READLINE=1
>   -D__NO_MATH_INLINES=1 -DCXX_NEW_FRIEND_TEMPLATE_DECL=1 -DHAVE_LIBM=1
>   -DHAVE_HDF5_H=1 -DHAVE_HDF5=1 -DF77_APPEND_UNDERSCORE=1 -DSIZEOF_SHORT=2
>   -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DHAVE_ALLOCA_H=1
>   -DHAVE_ALLOCA=1 -DNPOS=std::string::npos -DSTDC_HEADERS=1
>   -DHAVE_DIRENT_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_SYS_WAIT_H=1
>   -DHAVE_ASSERT_H=1 -DHAVE_CURSES_H=1 -DHAVE_DLFCN_H=1 -DHAVE_FCNTL_H=1
>   -DHAVE_FLOAT_H=1 -DHAVE_FNMATCH_H=1 -DHAVE_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READLINK=1 -DHAVE_RENAME=1
>   -DHAVE_RINDEX=1 -DHAVE_RMDIR=1 -DHAVE_SELECT=1 -DHAVE_SETGRENT=1
>   -DHAVE_SETPWENT=1 -DHAVE_SETVBUF=1 -DHAVE_SIGACTION=1 -DHAVE_SIGPENDING=1
>   -DHAVE_SIGPROCMASK=1 -DHAVE_SIGSUSPEND=1 -DHAVE_STAT=1 -DHAVE_STRCASECMP=1
>   -DHAVE_STRDUP=1 -DHAVE_STRERROR=1 -DHAVE_STRFTIME=1 -DHAVE_STRNCASECMP=1
>   -DHAVE_STRPTIME=1 -DHAVE_SYMLINK=1 -DHAVE_TEMPNAM=1 -DHAVE_UMASK=1
>   -DHAVE_UNLINK=1 -DHAVE_USLEEP=1 -DHAVE_VFPRINTF=1 -DHAVE_VSPRINTF=1
>   -DHAVE_VSNPRINTF=1 -DHAVE_WAITPID=1 -DHAVE_LIBDL=1 -DHAVE_DLOPEN=1
>   -DHAVE_DLSYM=1 -DHAVE_DLERROR=1 -DHAVE_DLCLOSE=1 -DWITH_DL=1
>   -DWITH_DYNAMIC_LINKING=1 -DHAVE_TIMEVAL=1 -DHAVE_FINITE=1 -DHAVE_ISNAN=1
>   -DHAVE_ISINF=1 -DHAVE_ACOSH=1 -DHAVE_ASINH=1 -DHAVE_ATANH=1 -DHAVE_ERF=1
>   -DHAVE_ERFC=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_ST_BLOCKS=1 -DHAVE_ST_RDEV=1
>   -DHAVE_TM_ZONE=1 -DHAVE_GR_PASSWD=1 -DEXCEPTION_IN_MATH=1
>   -DRETSIGTYPE=void -DSYS_SIGLIST_DECLARED=1 -DHAVE_SYS_SIGLIST=1
>   -DHAVE_POSIX_SIGNALS=1 -DHAVE_GETRUSAGE=1 -DHAVE_TIMES=1
>   -DGNUPLOT_HAS_MULTIPLOT=1 -DGNUPLOT_HAS_FRAMES=1




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]