gcc-4.9.2 installation failed on Linux

Question: The system information and installation command listed below [0, 1]. The message of contrib/download_prerequisites listed as [2]. Both configure.err [3] and configure.info [4] seemed ok. make_gcc.info can be downloaded from [5] and tailed 100 lines was listed [7]. make_gcc.err listed [6]. The installation command was checked by gcc mail list group and no error was found. But why it failed on my server? Any suggestions were very appreciated!
Best,
Pengcheng
[0] system information
[yangpc@node72 gcc-4.9.2]$ uname -a
Linux node72 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

[1] Installation command
rm -rf /panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2
cd /panfs/home/kang/yangpc/soft/lib/packages
tar -zxf gcc-4.9.2.tar.gz
cd gcc-4.9.2
./contrib/download_prerequisites 1> download_prerequisites.info 2> download_prerequisites.err
mkdir /panfs/home/kang/yangpc/soft/lib/packages/gcc-build
cd /panfs/home/kang/yangpc/soft/lib/packages/gcc-build
export LIBRARY_PATH=""
/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/configure --prefix=/panfs/home/kang/yangpc/soft/lib/gcc-4.9.2 --disable-multilib > configure.info 2> configure.err
make  1> make_gcc.info 2> make_gcc.err

[2] contrib/download_prerequisites message
./contrib/download_prerequisites
--2015-05-01 11:11:13--  ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
           => `mpfr-2.4.2.tar.bz2'
Resolving gcc.gnu.org... 18.104.22.168
Connecting to gcc.gnu.org|18.104.22.168|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/gcc/infrastructure ... done.
==> SIZE mpfr-2.4.2.tar.bz2 ... 1077886
==> PASV ... done.    ==> RETR mpfr-2.4.2.tar.bz2 ... done.
Length: 1077886 (1.0M)

100%[============================================================================================>] 1,077,886    510K/s   in 2.1s

2015-05-01 11:11:34 (510 KB/s) - `mpfr-2.4.2.tar.bz2' saved [1077886]

--2015-05-01 11:11:39--  ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
           => `gmp-4.3.2.tar.bz2'
Resolving gcc.gnu.org... 126.96.36.199
Connecting to gcc.gnu.org|18.104.22.168|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/gcc/infrastructure ... done.
==> SIZE gmp-4.3.2.tar.bz2 ... 1897483
==> PASV ... done.    ==> RETR gmp-4.3.2.tar.bz2 ... done.
Length: 1897483 (1.8M)

100%[============================================================================================>] 1,897,483    816K/s   in 2.3s

2015-05-01 11:11:59 (816 KB/s) - `gmp-4.3.2.tar.bz2' saved [1897483]

--2015-05-01 11:12:17--  ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
           => `mpc-0.8.1.tar.gz'
Resolving gcc.gnu.org... 22.214.171.124
Connecting to gcc.gnu.org|22.214.171.124|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/gcc/infrastructure ... done.
==> SIZE mpc-0.8.1.tar.gz ... 544950
==> PASV ... done.    ==> RETR mpc-0.8.1.tar.gz ... done.
Length: 544950 (532K)

100%[============================================================================================>] 544,950      361K/s   in 1.5s

2015-05-01 11:12:36 (361 KB/s) - `mpc-0.8.1.tar.gz' saved [544950]

--2015-05-01 11:12:38--  ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
           => `isl-0.12.2.tar.bz2'
Resolving gcc.gnu.org... 184.108.40.206
Connecting to gcc.gnu.org|188.8.131.52|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/gcc/infrastructure ... done.
==> SIZE isl-0.12.2.tar.bz2 ... 1319434
==> PASV ... done.    ==> RETR isl-0.12.2.tar.bz2 ... done.
Length: 1319434 (1.3M)

100%[============================================================================================>] 1,319,434    631K/s   in 2.0s

2015-05-01 11:12:58 (631 KB/s) - `isl-0.12.2.tar.bz2' saved [1319434]

--2015-05-01 11:13:09--  ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
           => `cloog-0.18.1.tar.gz'
Resolving gcc.gnu.org... 22.214.171.124
Connecting to gcc.gnu.org|188.8.131.52|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/gcc/infrastructure ... done.
==> SIZE cloog-0.18.1.tar.gz ... 3857324
==> PASV ... done.    ==> RETR cloog-0.18.1.tar.gz ... done.
Length: 3857324 (3.7M)

100%[============================================================================================>] 3,857,324   1.43M/s   in 2.6s

2015-05-01 11:13:29 (1.43 MB/s) - `cloog-0.18.1.tar.gz' saved [3857324]

[3] configure.err file
cat configure.err
configure: WARNING: using in-tree ISL, disabling version check
configure: WARNING: using in-tree CLooG, disabling version check
*** This configuration is not supported in the following subdirectories:
     gnattools target-libada target-libgo target-libbacktrace
    (Any other directories should still work fine.)

[4] configure.info file
[yangpc@node167 gcc-4.9.2]$ cat configure.info
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin//install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libcilkrts support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... gnatbind
checking for gnatmake... gnatmake
checking whether compiler driver understands Ada... yes
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
The following languages will be built: c,c++,fortran,java,lto,objc
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... expect
checking for runtest... runtest
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gcj... gcj
checking for gfortran... gfortran
checking for gccgo... no
checking for ar... no
checking for ar... ar
checking for as... no
checking for as... as
checking for dlltool... no
checking for dlltool... no
checking for ld... no
checking for ld... ld
checking for lipo... no
checking for lipo... no
checking for nm... no
checking for nm... nm
checking for objdump... no
checking for objdump... objdump
checking for ranlib... no
checking for ranlib... ranlib
checking for readelf... no
checking for readelf... readelf
checking for strip... no
checking for strip... strip
checking for windres... no
checking for windres... no
checking for windmc... no
checking for windmc... no
checking where to find the target ar... host tool
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gcj... just compiled
checking where to find the target gfortran... just compiled
checking where to find the target gccgo... host tool
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... host tool
checking where to find the target objdump... host tool
checking where to find the target ranlib... host tool
checking where to find the target readelf... host tool
checking where to find the target strip... host tool
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

[5] make_gcc.info
http://pan.baidu.com/s/1pJA4xej
[6] make_gcc.err file content
configure: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet.  If you think this
configuration is useful to you, please write to firstname.lastname@example.com.
configure: WARNING: cannot check for properly working vsnprintf when cross compiling, will assume it's ok
libtool: install: warning: remember to run `libtool --finish /panfs/home/kang/yangpc/soft/lib/gcc-4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2'
configure: WARNING: fixed-point is not supported for this target, ignored
Links are now set up to build a native compiler for x86_64-unknown-linux-gnu.
../.././libiberty/cp-demangle.c: In function 'd_print_comp':
../.././libiberty/cp-demangle.c:4281: warning: 'saved_templates' may be used uninitialized in this function
In file included from ../.././fixincludes/fixincl.c:88:
../.././fixincludes/fixincl.x:79: warning: string length '667' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:189: warning: string length '4756' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:309: warning: string length '552' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:354: warning: string length '532' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:398: warning: string length '808' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:527: warning: string length '560' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:607: warning: string length '2768' is greater than the length '509' ISO C89 compilers are required to support
../.././fixincludes/fixincl.x:3741: warning: string length '729' is greater than the length '509' ISO C89 compilers are required to support
../.././libcpp/symtab.c: In function 'void ht_dump_statistics(cpp_hash_table*)':
../.././libcpp/symtab.c:290: warning: converting to 'size_t' from 'double'
../.././gcc/genopinit.c: In function 'int main(int, char**)':
../.././gcc/genopinit.c:517: warning: comparison between signed and unsigned integer expressions
In file included from ./tm.h:19,
                 from ../.././gcc/c/c-lang.c:24:
./options.h:4257:2: error: #error too many masks for ix86_isa_flags
In file included from ../.././gcc/tree-core.h:26,
                 from ../.././gcc/tree.h:23,
                 from ../.././gcc/c/c-lang.c:25:
../.././gcc/statistics.h:25:2: error: #error GATHER_STATISTICS must be defined
In file included from ../.././gcc/tree-core.h:29,
                 from ../.././gcc/tree.h:23,
                 from ../.././gcc/c/c-lang.c:25:
../.././gcc/real.h:85:5: error: division by zero in #if
../.././gcc/real.h:85:5: error: division by zero in #if
../.././gcc/real.h:88:6: error: division by zero in #if
../.././gcc/real.h:88:6: error: division by zero in #if
../.././gcc/real.h:91:7: error: division by zero in #if
../.././gcc/real.h:91:7: error: division by zero in #if
../.././gcc/real.h:94:8: error: division by zero in #if
../.././gcc/real.h:94:8: error: division by zero in #if
../.././gcc/real.h:97:9: error: division by zero in #if
../.././gcc/real.h:97:9: error: division by zero in #if
../.././gcc/real.h:100:10: error: division by zero in #if
../.././gcc/real.h:100:10: error: division by zero in #if
../.././gcc/real.h:103:9: error: #error "REAL_WIDTH > 6 not supported"
In file included from ../.././gcc/c-family/c-common.h:24,
                 from ../.././gcc/c/c-tree.h:23,
                 from ../.././gcc/c/c-lang.c:27:
../.././gcc/../libcpp/include/cpplib.h:266:3: error: #error "Cannot find a least-32-bit signed integer type"
../.././gcc/system.h:506: error: declaration of C function 'const char* strsignal(int)' conflicts with
/usr/include/string.h:359: error: previous declaration 'char* strsignal(int)' here
../.././gcc/hwint.h: In function 'int clz_hwi(long unsigned int)':
../.././gcc/hwint.h:244: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/hwint.h: In function 'int ctz_hwi(long unsigned int)':
../.././gcc/hwint.h:258: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/hwint.h: In function 'int floor_log2(long unsigned int)':
../.././gcc/hwint.h:295: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/hwint.h: In function 'long int sext_hwi(long int, unsigned int)':
../.././gcc/hwint.h:328: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/hwint.h: In function 'long unsigned int zext_hwi(long unsigned int, unsigned int)':
../.././gcc/hwint.h:342: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/vec.h: In static member function 'static void va_heap::reserve(vec<T, va_heap, vl_embed>*&, unsigned int, bool)':
../.././gcc/vec.h:304: error: 'GATHER_STATISTICS' was not declared in this scope
../.././gcc/vec.h:312: error: 'GATHER_STATISTICS' was not declared in this scope
../.././gcc/vec.h: In static member function 'static void va_heap::release(vec<T, va_heap, vl_embed>*&)':
../.././gcc/vec.h:326: error: 'GATHER_STATISTICS' was not declared in this scope
../.././gcc/real.h: At global scope:
../.././gcc/real.h:51: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/real.h:51: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/real.h:76: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/real.h:76: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/real.h:76: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/real.h:76: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/../libcpp/include/cpplib.h:268: error: 'CPPCHAR_SIGNED_T' does not name a type
../.././gcc/../libcpp/include/cpplib.h:269: error: 'CPPCHAR_SIGNED_T' does not name a type
../.././gcc/../libcpp/include/cpplib.h:791: error: 'cppchar_t' does not name a type
../.././gcc/../libcpp/include/cpplib.h:802: error: 'cppchar_t' does not name a type
../.././gcc/../libcpp/include/cpplib.h:981: error: 'cppchar_t' does not name a type
../.././gcc/c-family/c-common.h: In member function 'omp_clause_mask omp_clause_mask::operator<<(int)':
../.././gcc/c-family/c-common.h:1131: error: 'SIZEOF_LONG' was not declared in this scope
../.././gcc/c-family/c-common.h: In member function 'omp_clause_mask omp_clause_mask::operator>>(int)':
../.././gcc/c-family/c-common.h:1151: error: 'SIZEOF_LONG' was not declared in this scope
make[3]: *** [c/c-lang.o] Error 1
make[2]: *** [all-stage1-gcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

[7] tail 100 lines of make_gcc.info file
tail -n 100 make_gcc.info
            "" '' no \
            > tmp-mlib.h; \
        fi
/bin/sh ../.././gcc/../move-if-change tmp-mlib.h multilib.h
echo timestamp > s-mlib
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/genattr.o ../.././gcc/genattr.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genattr \
            build/genattr.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genattr ../.././gcc/config/i386/i386.md \
          insn-conditions.md > tmp-attr.h
/bin/sh ../.././gcc/../move-if-change tmp-attr.h insn-attr.h
echo timestamp > s-attr
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/genattr-common.o ../.././gcc/genattr-common.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genattr-common \
            build/genattr-common.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genattr-common ../.././gcc/config/i386/i386.md \
          insn-conditions.md > tmp-attr-common.h
/bin/sh ../.././gcc/../move-if-change tmp-attr-common.h insn-attr-common.h
echo timestamp > s-attr-common
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/gencodes.o ../.././gcc/gencodes.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/gencodes \
            build/gencodes.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/gencodes ../.././gcc/config/i386/i386.md \
          insn-conditions.md > tmp-codes.h
/bin/sh ../.././gcc/../move-if-change tmp-codes.h insn-codes.h
echo timestamp > s-codes
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/genconfig.o ../.././gcc/genconfig.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genconfig \
            build/genconfig.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genconfig ../.././gcc/config/i386/i386.md \
          insn-conditions.md > tmp-config.h
/bin/sh ../.././gcc/../move-if-change tmp-config.h insn-config.h
echo timestamp > s-config
lsf="../.././gcc/cp/lang-specs.h ../.././gcc/lto/lang-specs.h"; for f in $lsf; do \
            echo "#include \"$f\""; \
        done | sed 's|../.././gcc/||' > tmp-specs.h
/bin/sh ../.././gcc/../move-if-change tmp-specs.h specs.h
echo timestamp > s-specs
rm -f tmp-all-tree.def
echo '#include "tree.def"' > tmp-all-tree.def
echo 'END_OF_BASE_TREE_CODES' >> tmp-all-tree.def
echo '#include "c-family/c-common.def"' >> tmp-all-tree.def
ltf="../.././gcc/ada/gcc-interface/ada-tree.def ../.././gcc/cp/cp-tree.def ../.././gcc/java/java-tree.def ../.././gcc/objc/objc-tree.def"; for f in $ltf; do \
          echo "#include \"$f\""; \
        done | sed 's|../.././gcc/||' >> tmp-all-tree.def
/bin/sh ../.././gcc/../move-if-change tmp-all-tree.def all-tree.def
echo timestamp > s-alltree
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/gencheck.o ../.././gcc/gencheck.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/gencheck \
            build/gencheck.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/gencheck > tmp-check.h
/bin/sh ../.././gcc/../move-if-change tmp-check.h tree-check.h
echo timestamp > s-check
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/gcov-iov.o ../.././gcc/gcov-iov.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  \
                build/gcov-iov.o -o build/gcov-iov
build/gcov-iov '4.9.2' '' \
            > tmp-gcov-iov.h
/bin/sh ../.././gcc/../move-if-change tmp-gcov-iov.h gcov-iov.h
echo timestamp > s-iov
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/genhooks.o ../.././gcc/genhooks.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genhooks \
            build/genhooks.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genhooks "Target Hook" \
                                             > tmp-target-hooks-def.h
/bin/sh ../.././gcc/../move-if-change tmp-target-hooks-def.h \
                                             target-hooks-def.h
echo timestamp > s-target-hooks-def-h
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include  -I../.././gcc/../libcpp/include  \
                -o build/genopinit.o ../.././gcc/genopinit.c
g++   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genopinit \
            build/genopinit.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genopinit ../.././gcc/config/i386/i386.md \
          insn-conditions.md -htmp-opinit.h -ctmp-opinit.c
/bin/sh ../.././gcc/../move-if-change tmp-opinit.h insn-opinit.h
/bin/sh ../.././gcc/../move-if-change tmp-opinit.c insn-opinit.c
echo timestamp > s-opinit
build/genhooks "Common Target Hook" \
                                             > tmp-common-target-hooks-def.h
/bin/sh ../.././gcc/../move-if-change tmp-common-target-hooks-def.h \
                                             common/common-target-hooks-def.h
echo timestamp > s-common-target-hooks-def-h
gawk -f ../.././gcc/gen-pass-instances.awk \
          ../.././gcc/passes.def > pass-instances.def
build/genhooks "C Target Hook" \
                                             > tmp-c-target-hooks-def.h
/bin/sh ../.././gcc/../move-if-change tmp-c-target-hooks-def.h \
                                             c-family/c-target-hooks-def.h
echo timestamp > s-c-target-hooks-def-h
g++ -c  -DIN_GCC_FRONTEND -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -fno-common  -DHAVE_CONFIG_H -I. -Ic -I../.././gcc -I../.././gcc/c -I../.././gcc/../include -I../.././gcc/../libcpp/include -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/host-x86_64-unknown-linux-gnu/gmp -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/gmp -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/host-x86_64-unknown-linux-gnu/mpfr -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/mpfr -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/mpc/src  -I../.././gcc/../libdecnumber -I../.././gcc/../libdecnumber/bid -I../libdecnumber -I../.././gcc/../libbacktrace -DCLOOG_INT_GMP -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/host-x86_64-unknown-linux-gnu/cloog/include -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/cloog/include -I./cloog/include  -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/host-x86_64-unknown-linux-gnu/isl/include -I/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/isl/include  -o c/c-lang.o -MT c/c-lang.o -MMD -MP -MF c/.deps/c-lang.TPo ../.././gcc/c/c-lang.c
make[3]: Leaving directory `/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2/host-x86_64-unknown-linux-gnu/gcc'
make[2]: Leaving directory `/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2'
make[1]: Leaving directory `/panfs/home/kang/yangpc/soft/lib/packages/gcc-4.9.2'

Comment: It seems to be similar to this question: http://stackoverflow.com/questions/12255058/g-4-7-1-compilation-error-conflicting-types-for-strsignal May be you should try the techniques in its answer.
Comment: Thank you @HaochenWu, following your given links, I have successfully compiled gcc-4.9.2. Thank you very much.
Answer: This problem has been resolved by unset the variables:
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE

gcc-4.9.2 installation failed on Linux


Floating multiplication performing slower depending of operands in C

Question: I am performing a stencil computation on a matrix I previously read from a file. I use two different kinds of matrices (NonZero type and Zero type). Both types share the value of the boundaries (1000 usually), whilst the rest of the elements are 0 for Zero type and 1 for NonZero type.
The code stores the matrix of the file in two allocated matrices of the same size. Then it performs an operation in every element of one matrix using its own value and values of neighbours (add x 4 and mul x 1), and stores the result in the second matrix. Once the computation is finished, the pointers for matrices are swapped and the same operation is perform for a finite amount of times. Here you have the core code:
#define GET(I,J) rMat[(I)*cols + (J)]
#define PUT(I,J) wMat[(I)*cols + (J)]

for (cur_time=0; cur_time<timeSteps; cur_time++) {
    for (i=1; i<rows-1; i++) {
        for (j=1; j<cols-1; j++) {
            PUT(i,j) = 0.2f*(GET(i-1,j) + GET(i,j-1) + GET(i,j) + GET(i,j+1) + GET(i+1,j));
        }
    }
    // Change pointers for next iteration
    auxP = wMat;
    wMat = rMat;
    rMat = auxP;
}

The case I am exposing uses a fixed amount of 500 timeSteps (outer iterations) and a matrix size of 8192 rows and 8192 columns, but the problem persists while changing number of timeSteps or matrix size. Note that I only measure time of this concrete part of algorithm, so reading matrix from file nor anything else affects the time measure.
What it happens, is that I get different times depending on which type of matrix I use, obtaining a much worse performance when using Zero type (every other matrix performs same as NonZero type, as I have already tried to generate a matrix full of random values).
I am certain it is the multiplication operation, as if I remove it and leave only the adds, they perform the same. Note that with Zero matrix type, most of the type the result of the sum will be 0, so the operation will be "0.2*0".
This behaviour is certainly weird for me, as I thought that floating point operations were independent of values of operands, which does not look like the case here. I have also tried to capture and show SIGFPE exceptions in case that was the problem, but I obtained no results.
In case it helps, I am using an Intel Nehalem processor and gcc 4.4.3.
Comment: How is the zero matrix initialized?  In particular, are the zero true zeros or just very very small values appearing to be zero?  Computation with subnormals (non zero values whose absolute value is smaller than FLT_MIN) are well known to often be slower than with normalized values.
Comment: Does it improve if you use `double` instead of `float` (for constants -- the `0.2f` -- and matrix values)?
Comment: Are you testing this with hard coded data such that the compiler can _at compile time_ see the values in the matrix and make an inlined version of your code optimsied for that that fixed data? If it knows that an element is zero it can likely optimise out the multiply completely...
Comment: I think your main problem is cache pressure. Each of these matrices is 8192^2 * sizeof(float) large. That's well beyond L2, not to speak of L1 cache size. You should change your algorithm so that it operates on about chunks of 8k of data. Also I'd try to process those values using SIMD instructions. This looks like a prime example for using MAD instruction (Multiply Add).
Comment: @JohnB Data is not hard coded, I read it from files. I have also checked the assembler produced with objdump -S and the code of the inner loop looks pretty clear, 4 addss and 1 mulss with changes on the pointer to load next iterations, I could have not done it better in assembler. @pmg It surprisingly improves the result of the zero type matrix and makes the nonzero type perform worse than with floats, but still the nonzero type performs better than the zero type.
Comment: @AProgrammer What you say makes a lot of sense. Due to the algorithm nature, the values on the boundaries are spread to the centre. Initially, they are large enough values, but after a few iterations the new spread values are closer to 0. This doesn't happen when I fill matrix with NonZero values like 1, as the result of the operation would be 1 at least.

@datenwolf I know the problem of the algorithm is that it is memory bound, in fact I apply several optimisations to the code to improve performance. But that problem with floating point operations is independent of memory.
Comment: @AProgrammer It worked, I have just changed 0.2f for 1.2f (then the result of the operation would never give a value below FLT_MIN) and then both matrices gave exactly the same time. Now I will have to find a source to explain that behaviour, but in case I could not find it, I could always use as a proof the experimental result obtained changing the constant. Thank you all very much.
Comment: @AProgrammer, you should add your comment as an answer so it can be accepted.
Answer: The problem has already mostly been diagnosed, but I will write up exactly what happens here.
Essentially, the questioner is modeling diffusion; an initial quantity on the boundary diffuses into the entirety of a large grid.  At each time step t, the value at the leading edge of the diffusion will be 0.2^t (ignoring effects at the corners).
The smallest normalized single-precision value is 2^-126; when cur_time = 55, the value at the frontier of the diffusion is 0.2^55, which is a bit smaller than 2^-127.  From this time step forward, some of the cells in the grid will contain denormal values.  On the questioner's Nehalem, operations on denormal data are about 100 times slower than the same operation on normalized floating point data, explaining the slowdown.
When the grid is initially filled with constant data of 1.0, the data never gets too small, and so the denormal stall is avoided.
Note that changing the data type to double would delay, but not alleviate the issue.  If double precision is used for the computation, denormal values (now smaller than 2^-1022) will first arise in the 441st iteration.
At the cost of precision at the leading edge of the diffusion, you could fix the slowdown by enabling "Flush to Zero", which causes the processor to produce zero instead of denormal results in arithmetic operations.  This is done by toggling a bit in the FPSCR or MXSCR, preferably via the functions defined in the <fenv.h> header in the C library.
Another (hackier, less good) "fix" would be to fill the matrix initially with very small non-zero values (0x1.0p-126f, the smallest normal number).  This would also prevent denormals from arising in the computation.
Comment: Should work too: `double FlushToZero(double x){return (x < 2e-126)?0:x;}` and call it: `y = FlushToZero(0.2 * ...);`. Should contain no overhead with proper inlining of the compiler.
Comment: @Xeo: I suspect most compilers will (rightly or wrongly) compile that into a compare and branch, which will introduce overhead, but it's still a reasonable suggestion.  Actually enabling the FTZ bit is the only way to do it with zero overhead.  Also, the constant should be `0x1.0p-126f`, not `2e-126` (a rather different value).
Comment: Woops, you're right with the constant, but my 5min for edits have passed. :| Fun fact: `0x1.0p` is `3,1415926535897932384626433832795`. Found that while pasting `0x1.0p-126` into Windows Calc.
Comment: But what is the scope of this setting (in ) ? Can it be turned off and on around specific calculations whose near-zero accuracy isn't important? and what is the processor behavior in other threads in my process, when they perform such calculations?
Comment: @MottiShneor: The setting is per-thread.  If the near-zero accuracy is unimportant, there's no reason to bother turning it off, because that's all that it effects.
Answer: Maybe your ZeroMatrix uses the typical storage scheme for Sparse Matrices: store every non-zero value in a linked list. If that is the case, it is quite understandable why it performs worse than a typical array-based storage-scheme: because it needs to run thru the linked list once for every operation you perform. In that case you can maybe speed the process up by using a matrix-multiply-algorithm that accounts for having a sparse-matrix. If this is not the case please post minimal but complete code so we can play with it.
here is one of the possibilities for multiplying sparse matrices efficiently:

http://www.cs.cmu.edu/~scandal/cacm/node9.html


How to find parametric equations from a polynomial equation/curve?

Question:
Find a set of parametric equations $x(m)$, $y(m)$ that represent the graph of $y= 2x^2-3x+1$ such that the parameter $m$ is the slope $m = \frac{dy}{dx}$ at the point $(x,y)$.

I am guessing I need first convert the polynomial into parametric first? Honestly, I have no clue how to even start this. I've looked for hours on the internet but can't find an explanation that I understand.
Comment: (1) Find $dy/dx$ in terms of $x$. Call the result $m$.
(2) Solve for $x$ in terms of $m$.
(3) Replace $x$ by the result of step (2) in the original equation to get $y$ in terms of $m$.
Done.
Answer: Since $m=y'=4x-3$ then
$$x=\frac{m+3}{4}$$
Then the graph is
$$(x,y)=(x,2x^2-3x+1)=\left(\frac{m+3}4,\frac{m^2-6m+9}8-\frac{3m+9}4+1\right)$$
or
$$(x(m),y(m))=\left(\frac{m+3}4,\frac{m^2-12m-1}8\right)$$
Note that it is crucial that you can solve for $x$ in the equation of the derivative, so the polynomial should have a degree at most $2$. Or, at least, the derivative of the polynomial should be an injective function.


Extreme Value Theorem over the Real Numbers

Question: I'm stuck on where to start with this.  I can tell it is to do with the extreme value theorem, but past that point I'm stuck.  Any help would be appreciated.
If $f(x)$ is continuous on $\mathbb{R}$, with $f(x) \geq 0$ $\forall x \in \mathbb{R}$ and $\lim_{x \to - \infty} f(x) = 0 = \lim_{x \to \infty} f(x)$, then $\exists x_0 \in \mathbb{R}$ where $f(x) \leq f(x_0)$  $ \forall x \in \mathbb{R}$.
Answer: If $f$ is identically zero we are done - every point is maximal. Therefore assume $f(x_1)>0$ for some $x_1$. By the limit condition, there exists $a,b$ with $f(x)<f(x_1)$ for all $x<a$ and also for all $x>b$. On the compact interval $[a,b]$, $f$ assumes its maximum at some point $x_0$. Then $f(x_0)\ge f(x)$ for all $x\in \mathbb R$.
Comment: The key insight here is that you can cut off the infinite tails where the function is small and work with a closed interval which is compact and where you have a theorem you can use. You need to deal with the zero case as an exception. It is often the case that you have to divide a problem up into bits - for example, big bits where a function is under control, and small bits where it doesn't matter what the function does because they are so small (or as here, where you know enough to prove a bound).
Comment: Thanks Hagen and Mark.  Your explanations were wonderfully helpful.  Much appreciated!
Answer: Hints:
$$\exists\,R\in\Bbb R^+\;\;s.t.\;\;\forall\,x\in\Bbb R\;\;with\;\;|x|>R\;,\;\;f(x)<0.1$$
Apply now Wierstrass Theorem for $\;f\;$ on $\;[-R\,,\,R]\;$
Comment: What if, coincidentally, $f < 0.05$ on $[-R,R]$, and $f(R + 1) = 0.09$?


On Tuning: What's in a Temperament? (Well-Temperament vs. Equal Temperament)

Question: I just had my whole world shattered this morning when I was unwise enough to do a "quick" Google search on what exactly "equal temperament" means before I had started my work. Of course, the loudest voices in such a search all scream "IT'S FREAKING WRONG, YOU HEATHENS."
Is it acceptable to tune an instrument to well-temperament in this day and age? If so, what are the exact frequencies to tune to? Will it require, on an intonation-based instrument, such as the violin, a re-learning of what each pitch should be (Will I be constantly trying to flip back into equal temperament?)Basically, is there a temperament system which isn't totally equal like what we use today that can be used in practically any key without "wolf" chords?
(On the side, when a person says "concert pitch," I suppose that means he's referring to equal temperament, right? Wrong? Ahdunno, that's the job of the enlightened geniuses about to answer who will undoubtedly storm this question and tell me every place where I got my facts wrong here. But, whatever, that's what I want...)
Answer: You can approach the subject of temperament either as a mathematical exercise, or as a practical one (i.e. what it sounds like).
Mathematically, you are trying to find the "best" solution to a problem that is insoluble. Empirically, the intervals of a perfect fifth and an octave sounds "exactly in tune" if the frequency ratio of the notes is 3:2 and 2:1. The problem is that you can't make an exact octave by stacking up exact fifths. If you build a cycle of fiths like C, G, D, A, B, ... you eventually get to an interval C - B sharp with a frequency ratio of 531441:262144, which isn't quite the same as the octave C - C with a ratio of 524288:262144 or 2:1.
There have been almost as many different ways to "make B sharp the same note as C" as the number of people who have written anything about the problem.
The current "standard" for western music is equal temperament, where you split the octave into 12 equal parts. That makes a "not quite perfect fifth" with a ratio of 2.9966142 : 2, instead of 3:2. That doesn't look much different on paper, but it is just about audible.
There were several different solutions to the problem in use in the 18th and 19th centuries, all of which allowed playing in every major and minor key. These "well-temperaments" result in semitones of slightly different sizes, and therefore each of the 24 keys has a slightly different sound - and 18th and 19th century composers knew about that, and used it intentionally.
This is a good demonstration - Bach's organ prelude and fugue in D (BWV 532). The start is basically D major scales and chords, ending with an A major chord. At around 30 seconds this is suddenly followed by passage built around an F# major chord, and the tuning of the F# chord is noticeably different from the D and the A - probably a "WTF???" moment for Bach's original listeners, who were not used to this sort of thing.

There are several unequal well-temperaments that are currently used for "historically informed" music performances. https://en.wikipedia.org/wiki/Well_temperament lists the common ones, and has links to the details of most of them.
Unlike a keyboard instrument, the violin is not restricted to playing in any "fixed" temperament, except for the tuning of the open strings. In practice, individual notes are "tempered" according to the musical context, often by much more than the difference between a well-temperament and equal temperament. I've seen claims that professional players sometimes pitch-shift individual notes by almost a quarter-tone.
In contemporary music (since about 1950) most of the interest has been in equal-tempered tunings but with more than 12 divisions per octave. By dividing an octave into more than 12 equal parts, you can get intervals which are "closer to perfectly in tune" than Equal temperament, but still "play in any key". 19, 41 and 53 divisions are cases that work out well and have been explored musically.
Comment: Given that every scale has two (or more?) kind of step, why would anyone expect to be able to build a scale from only one?  The problem as I see it is that you can't meet three desiderata (octave, fifth, third) with only two kinds of step.
Comment: @AntonSherwood "why would anyone expect to be able to build a scale from only one?": to be able to modulate.  Unequal temperaments are lovely in certain keys, but of course awful in others.  Much 19th century music would sound bad in unequal temperaments (even a lot of Baroque music is unlistenable in mean tone temperament, which was for the most part superseded by Werckmeister and others before the end of the Baroque).
Comment: @phoog You've answered a different question: why one would want to attempt it.
Comment: @AntonSherwood fair enough.  But experience shows that people not only attempt it but succeed.  That the major third of 12-tone equal temperament is so far off from the acoustical pitch does not prevent scales built from 12-tone equal temperament from being scales.
Answer: Violins are tuned by tuning the A and then tuning all other strings in perfect fifths in relation to A.  The idea of Werckmeister III tuning, the most commonly employed well-tempered tuning, is actually pretty compatible with that scheme, namely using 8 perfect tuned fifths and then offset the accumulated +16cents of tuning error (a perfect fifth is 2 cents above an equal-tempered one) then over four non-perfect fifths.  Unfortunately, those fifths are C-G, G-D, D-A and B-F♯, so a Werckmeister III G is 8 cents above a normally tuned violin G (and you'd be even off 12 cents for a viola C).
By the way, Bach wrote for "Well-tempered Clavier" (likely as opposed to mean-tone temperament common for keyboard instruments at the time, mean-tone being based on pure and unpure thirds rather than pure and unpure fifths and thus making unusual keys much less playable).  He did not invent it, and it is not clear just what well-tempered temperament (of which there are several different ones) he had in mind for that work cycle.
Comment: Some say the intended temperament for the Well-Tempered Clavier is indicated on its title page: https://www.rolf-musicblog.net/what-tunings-did-bach-use/
Comment: Violinists (and other string players) playing with historically tempered keyboards actually tend to tune each string to the keyboard, since as you note failing to do so can leave the open strings fairly far from the corresponding notes on the keyboard.  Two of the four small fifths you note are open strings in violins, violas, and cellos (G-D and D-A), and one in violas and cellos only (C-G).
Answer: The term "well tempered" is generally used for what you refer to in the end: a temperament that is not-equal, but is (reasonably) playable in any key.  The Werkmeister tunings are the most well known of this sort.  It's my impression that many pipe organs are still tuned in this manner (so that is the context you'll often hear it in), due to way that the sustained nature of the notes works with the common repertoire.
(Disclaimer I'm not a violinist)
In terms of violin performance I've heard the following: if you tune your violin using harmonics just by ear so that they form perfect (consonant) fifths, so that G->D is a perfect 5th, D->A is a perfect fifth and so on.  The interval between the G and E string is a Pythagorean sixth, which is noticeably off (to some people) from a (5-limit) just intonated 6th and/or an equal tempered major 6th.  So some violinists "temper their fifths" when tuning by ear, though by no means is this universally accepted as ideal, especially not in all situations, e.g. playing with a fixed pitch instrument.
For the most part, temperament is a problem for fixed pitch instruments.  On a violin, for any fingered note, you can and probably do adjust the exact position of your finger to effect an intonation.
Answer: Just a quick note (hehe) to your on-the-side question about "concert pitch".  This does not refer to temperament but rather to the overall pitch level, usually based on how high or low the A is.  Current concert pitch is somewhat standardized at A=440 Hz, but here in Vienna, for instance, it's more like 444.
Comment: Thanks for that. I was gonna edit it out because it's unrelated to the main point, but then your wonderful descriptive answer won't be right. So I'll just leave it there, to magnify my musical illiteracy. Which is getting smaller. ¯\\_(ツ)_/¯
Comment: Hey, no problem.  Being illiterate in countless fields, I share your shame, lol.  Cheers, Scott


Determining the grids cut by a plane,formed from 3 vertices

Question: I found out an equation of a plane,from three vertices.
Now,if I have a bounding box(i.e. a large cube),How can I determine the grid positions(small cubes),where the plane cuts the large cube.
I am currently following this approach:
For each small cube center, say(Xp, Yp, Zp), calculate perpendicular distance to the plane i.e., (aXp + bYp + c*Zp + d)/ (SquareRoot Of (a^2 + b^2 + c^2)). This should be less than or equal to (length of smallCube * SquareRoot(3))/2.
If this criteria,gets satisfied,then I assume my plane to cut the large cube at this small cube position.
a,b,c,d are coefficients of the plane,of the form ax+by+cz+d = 0.
I would be really glad,if someone can let me know,if I am doing something wrong (or) also,any other simple approach.
Answer: Seems you want to get a list of small cubes (grid voxels) intersected by given plane.
The simplest approach:
Find intersection of the plane with any cube edge. For example, intersection with vertical edge of AAB (X0,Z0 are constant) might be calculated by solving this equation for unknown Y:
aX0 + bY + c*Z0 + d = 0

and checking that Y is in cube range. Get small cube coordinates (0, ky=Floor(Y/VoxelSize), 0)  and then check neighbor voxels in order (account for plane coefficients to check only real candidates).
candidates:
0,ky,0
1,ky,0
0,ky-1,0
0,ky+1,0
0,ky,1

There are more advanced methods to generate voxel sequence for ray case (both 2d and 3d) like Amanatides/Woo algorithm. Perhaps something similar exists also for plane voxelization
Here is AABB-plane intersection test code from this page (contains some explanations)
// Test if AABB b intersects plane p
int TestAABBPlane(AABB b, Plane p) {
    // Convert AABB to center-extents representation
    Point c = (b.max + b.min) * 0.5f; // Compute AABB center
    Point e = b.max - c; // Compute positive extents

    // Compute the projection interval radius of b onto L(t) = b.c + t * p.n
    float r = e[0]*Abs(p.n[0]) + e[1]*Abs(p.n[1]) + e[2]*Abs(p.n[2]);

    // Compute distance of box center from plane
    float s = Dot(p.n, c) - p.d;

    // Intersection occurs when distance s falls within [-r,+r] interval
    return Abs(s) <= r;
}

Note that e and r remain the same for all cubes, so calculate them once and use later.
Comment: could zou please go through my algorithm once and explain me the changes ,I can do to make it working.Thanks
Comment: Emm... What is your algorithm? Your checking is not right  - it can produce false positive results. And I gave you a clue - how to get rid of brute force checking all small cubes.
Comment: I would be really glad,if you can slightly modify my check.Because,being a beginner in programmer,I am finding it a bit difficult to code the algorithm,you described.
Comment: But you have the same Google, haven't you? ;) Intersection test code added
Comment: Hi, in your algorithm, if my plane is in the form ax+by+cz+d = 0, are the values  p.n[0] `= a , p.n[1] `= b , p.n[2] `= b ,respectively?? could you please explain a bit on this
Comment: Also,in your described algorithm, point e evaluates to same every time.Because, b.max = c+(voxelsize/2) and b.max - c =  (voxelsize/2).So,irrespective of the grid,point e evaluates to the same value everytime.
Comment: Yes, p.n[0]=a and so on. And yes, you find both **e** and **r** once and use them instantly for all cubes


Python Lowest Common CIDR

Question: Say I have two IPs: startip = '18.104.22.168' and endip   = '220.127.116.11'
I understand that in python netaddr.iprange_to_cidrs(startip, endip) will give you a list of CIDR subnets that fit exactly between the boundaries.  However, I was hoping to go for one CIDR subnet that covers it all even if it gives a few more IPs.
I prefer a function that does it, but I would also welcome any math/logic to calculate it and eventually turn it into code.
Answer: Have you tried the ipaddress module? It comes with Python 3, but is installable for Python 2.
import ipaddress
startip = ipaddress.IPv4Address('126.96.36.199')
endip = ipaddress.IPv4Address('220.127.116.11')
# summarize_address_range produces a generator, so force the results
networks = [n for n in ipaddress.summarize_address_range(startip, endip)]
print(networks)
# [IPv4Network('22.214.171.124/18')]

Comment: Issue is I have python 2.6.6 and no way of installing new modules.  but I'll give it a shot.  thanks.
Answer: It looks like netaddr.spanning_cidr does the trick:
In [5]: netaddr.spanning_cidr(['184.108.40.206', '184.108.40.206'])
Out[5]: IPNetwork('22.214.171.124/18')

Python Lowest Common CIDR


Prolog findall solutions within time limit

Question: I would like to find all solutions to a goal within some time limit. I mean that I would like to search for solutions for at most the time limit, and return all solutions found, whether the time limit has been reached or not, which is regardless of whether the list of solutions is complete or not.
I have tried the following:
catch(call_with_time_limit(60, findall(S,my_goal(S),Sol)), time_limit_exceeded,false)

However, it does not return the partial list of solutions found if the time limit has been reached, and "false" can not be an expression relying on Sol.
This question is related to Prolog: "findall" for limited number of solutions, but instead of having a maximum number of solution I am interested in maximum search time.
Would you please have any insight for this?
Comment: Of interest: [Is it possible to create something similar to call_with_time_limit/2 which doesn't kill the goal after timeout?](https://swi-prolog.discourse.group/t/is-it-possible-to-create-something-similar-to-call-with-time-limit-2-which-doesnt-kill-the-goal-after-timeout/1313)
Answer: Something like this may work to you:
findall_time(Duration, Template, Goal, Bag):-
  get_time(TimeStamp),
  Time is TimeStamp + Duration,
  findall(Template, findall_time1(Time, Goal), Bag).

findall_time1(Time, Goal) :-
    catch(setup_call_cleanup(alarm_at(Time,
                                      throw(time_limit_exceeded),
                                      Id),
                             (get_time(TimeStamp), Time>TimeStamp, Goal),
                             remove_alarm(Id)),
          time_limit_exceeded,
          fail).

with this sample code and test:
my_goal(X):-
 between(0, 5, X),
 sleep(1).

?- findall_time(2.5, X, my_goal(X), Bag).
Bag = [0, 1].


Which version of OpenGL should I learn?

Question:
Possible Duplicate:
Which version of OpenGL to use?

I have been wanting to learn a 3d graphics language for some time now and I have finally decided to learn OpenGL.
However, I work on a Mac and officially this highest version of OpenGL for mac is 2.1 but it can support 3.3 unofficially through tests that I have done.
I would like to develop applications that would work on multiple platforms but what version would be the best to learn?
Answer: A good compromise between portability and still learning the "modern OpenGL way", is roughly "the OpenGL ES 2.0 subset of OpenGL 2.1". That gives you portability to

OSX, as you mention
Windows, obviously
Linux with open source drivers (for higher OpenGL versions and better performance you need the proprietary drives which you might prefer anyway, but some people like to avoid those)
Smartphone platforms like iOS and Android.

OpenGL 1.x is even more portable (e.g. older iOS and Android releases support only OpenGL ES 1.x) but the classical fixed-function programming model is somewhat different than the modern one based on buffer objects and shaders, and use of immediate mode easily leads to performance issues when rendering lots of vertices. So probably not worth it, IMHO.
Comment: Yet the best answer among the a bit narrow-minded "OpenGL 2.1 is deprecated!"-answer and the ridiculous idea of learning WebGL or GLES on desktop.
Answer: My recommendation would be to learn no less than version 3.2. If 3.3 is supported (even unofficially), go for that.
OpenGL 3.3 is already rather "last generation" than "bleeding edge". You have to search hard to find a card that does not support OpenGL 3.3, and you get 4.x capable cards in the $30 range.
Under version 2.x, you must go through a lot of pain to ensure that even the most basic functionality that you use every day is available, and you end up writing two or three code paths depending on what extension you must use and on what some limit is.
Under version 3.3, most features that you want to use every day are core (guaranteed standard), and most limits have a guaranteed minimum value that is enough for most things anyway. The features that are not core in 3.3 are few (and you won't die if you don't have them), and you can pretty much just plug them in optionally if they're there, and forget about them if they aren't.
There is a huge change in paradigms between 2.1 and 3.3 (which you will have to re-learn later if you start with 2.x first!), and there are notable changes in GLSL between 3.1 and 3.2 which make writing shader code that works for both an ordeal, or impossible.
Upwards of version 3.2, everything is smooth. New features are available or they aren't... use them or don't... but you can in principle write one piece of code to run on all versions.
Answer: If your goal is maximum interoperability, I would rather take a look at WebGL, or it's close relative, OpenGL ES. The concepts of OpenGL ES (at least in the 2.0 version) are quite close to those of OpenGL 4 (buffer-based data transfer, universal shaders etc.).
I think that by learning 2.1 you would learn some outdated concepts you will soon have to re-learn, like the direct mode, or rather the whole fixed-function pipeline which was pruned in later versions.
You can safely start learning the 3.x too, as you will learn the current concepts and features. Do not worry about the "officially supported" version.
Comment: I believe it is wrong to guide someone towards WebGL. WebGL is to access native GPU capabilities on the web, and openGL is for accessing native GPU capabilities as a native application. Also, WebGL has its own portability problems with only Chrome (and Opera) supporting it fully (as of now) as per http://caniuse.com/webgl.

Which version of OpenGL should I learn?


Is $C^{\infty}\left(M,N\right)$ a Frechet space?

Question: Let $M$ and $N$ be compact, smooth manifolds. Can we equip a topology
on
$$C^{\infty}\left(M,N\right):=\left\{ f:M\rightarrow N\;\textrm{smooth}\right\}
$$
such that $C^{\infty}\left(M,N\right)$ is a Frechet space?
Recall that: A Frechet space is a topological vector space that is locally convex, metrizable, and complete.
Answer: If the target $N$ is not $\mathbb{R}^n$, you already fail to give $C^\infty(M,N)$ a vector space structure that is of geometrical significance.
On the other hand $C^\infty(M,\mathbb{R}^n)$ caries a natural Fréchet space structure. Its topology is for example generated by seminorms of the form $p_k(f) = \sup_{p\in M}\vert \nabla^k f(p)\vert_g$ (for $\nabla$ the Levi-Civita-connection w.r.t. to an arbitrary metric $g$ on $M$). (Provided $M$ is compact, otherwise you can only give it the structure of an LF-space, just as it is the case with Distributions on $\mathbb{R}^m$.)
If $N$ is an arbitrary closed manifold, then it admits a proper embedding into some $\mathbb{R}^n$ and you can identify $C^\infty(M,N)$ with the subset of all functions $f\in C^\infty(M,\mathbb{R}^n)$ whose images lie in the embedding of $N$. Then  $C^\infty(M,N) \subset C^\infty(M,\mathbb{R}^n)$ is closed Fréchet submanifold.
For the construction of charts on $C^\infty(M,N)$ consider https://ncatlab.org/nlab/show/manifold+structure+of+mapping+spaces.
Comment: Thanks so much.
Comment: @Jan Bohr Could  you write a  proof $C^\infty(M,\mathbb{R}^n)$ is a frechet space with the seminorm $p_k$ namely  I more interested in the proof that this space is complete in relation to this seminorm
Comment: I am sure you will find a proof of this somewhere; otherwise try yourself and ask for help in a separate question.


Existence of a Perfect matching in a Graph

Question: how to find whether a given graph has a perfect matching or not?? I read that the degree should be atleast n/2 for all the vertices to be a perfect matching..But can anyone give the necessary and sufficient condition... Thank you in advance
Answer: Tutte's Theorem characterizes the graphs with a perfect matching.
http://en.wikipedia.org/wiki/Tutte_theorem
It states that some graph $G = (V, E)$ has a perfect matching if and only if for any subset $U \subseteq V$, the graph induced by $V - U$ (that is, by removing the vertices of $U$ from $G$) has at most $|U|$ connected components with an odd number of vertices.


Como fazer Scraping de uma tabela e inserir os dados no banco de dados?

Question: Bom, basicamente o que eu preciso é fazer um microservice que extraia os preços da cotação da soja dessa tabela: https://www.canalrural.com.br/cotacao/soja/. E depois inserir os dados em um banco de dados.
Apesar de conseguir fazer o Scraping utilizando o código abaixo, não tenho ideia de como "filtrar" os dados do array para incluir na estrutura do banco de dados.
$content = file_get_contents('https://www.canalrural.com.br/cotacao/soja/');

preg_match_all('/
(.*?)(.*?)<\/div>/s',$content,$matches);

foreach ($matches[0] as $key => $value){
    echo $value;
    echo '
';
}

As colunas do banco de dados são apenas o local e preço.
Answer: Opa, aconselho você a usar a biblioteca Simple HTML DOM Parser, daí você consegue interagir com o html de forma muito mais fácil, usando seletores css, que nem javascript.
No seu caso, poderia usar desse jeito:
$html = file_get_html('https://www.canalrural.com.br/cotacao/soja/');
$tableRows = $html->find('.table-cotacao tr'); // pega todas as
 dentro da .table-cotacao

foreach($tableRows as $tr) {
  $name  = $tr->find('td')[0]->plaintext;
  $price = $tr->find('td')[1]->plaintext;
}

Espero ter ajudado =D


C# Parsing JSON String

Question: I have tried countless methods to Parse my JSON string (Steam Public Data), yet nothing seems to work. I just want to be able to extract values from the string. For Example, obtaining the value of personaname which would return SlothGod. I have JSON.NET installed in my project.
Here is my JSON:
{
    "response": {
        "players": [
            {
                "steamid": "76561198301407459",
                "communityvisibilitystate": 3,
                "profilestate": 1,
                "personaname": "SlothGod",
                "lastlogoff": 1508389707,
                "commentpermission": 1,
                "profileurl": "http://steamcommunity.com/id/sleuthgud/",
                "avatar": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/09/09cea52b91136fb3306c57771a746db2823b91ba.jpg",
                "avatarmedium": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/09/09cea52b91136fb3306c57771a746db2823b91ba_medium.jpg",
                "avatarfull": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/09/09cea52b91136fb3306c57771a746db2823b91ba_full.jpg",
                "personastate": 0,
                "realname": "Josh",
                "primaryclanid": "103582791460168790",
                "timecreated": 1462086929,
                "personastateflags": 0,
                "loccountrycode": "AU",
                "locstatecode": "QLD"
            }
        ]

    }
}

Main method suggested to me:
public class Details
{
    public string personaname { get; set; }
}
private void GetSteamDetails()
{
    var data = Newtonsoft.Json.JsonConvert.DeserializeObject(SteamDetailsJson);
    SteamName = data.personaname;
}

This is placed before Page_Load(). I then call GetSteamDetails(); when I want to fetch the name.
Comment: Possible duplicate of [How can I parse JSON with C#?](https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c)
Comment: You should show what you have tried.. and we can try and help fix it
Comment: @TAHASULTANTEMURI I have looked at that exact post myself, yet I was never able to get it working
Comment: not clear question. provide what you tried so far and where exactly you are facing problem.
Comment: OP should first study how to parse JSON in c#. The complexity level of JSON parsing is really low specially with the right tools and valid format.
Comment: @JohnEphraimTugado Trust me, I have been studying it, but I just can't seem to understand it, and the easiest way to learn something is by having an example show to you that you actually understand.
Answer: After my question being down voted, I decided to not give up on this problem. After extensive research, trial and error, and YouTube tutorials which are the most helpful IMO. I found that the data was containing a JSON array, and yes I will admit, I was confused with this, but the answer was to simply treat it like a C# array and add [1] to the end of players.
Details details = new Details();
public class Details
{
    public string avatar { get; set; }
    public string avatarmedium { get; set; }
    public string avatarfull { get; set; }
    public string realname { get; set; }
    public string personaname { get; set; }
    public string steamid { get; set; }
}

private void GetSteamDetails()
{
    var SteamDetails= JsonConvert.DeserializeObject<dynamic>(SteamDetailsJson);
    avatar = SteamDetails.response.players[1].avatar.ToString();
    personaname = SteamDetails.response.players[1].personaname.ToString();
}

Answer: Based on the JSON string you provided, you should have the following C# classes to support it, or to deserialize the JSON object values into:  I used this link to generate the classes.
public class Player
{
    public string steamid { get; set; }
    public int communityvisibilitystate { get; set; }
    public int profilestate { get; set; }
    public string personaname { get; set; }
    public int lastlogoff { get; set; }
    public int commentpermission { get; set; }
    public string profileurl { get; set; }
    public string avatar { get; set; }
    public string avatarmedium { get; set; }
    public string avatarfull { get; set; }
    public int personastate { get; set; }
    public string realname { get; set; }
    public string primaryclanid { get; set; }
    public int timecreated { get; set; }
    public int personastateflags { get; set; }
    public string loccountrycode { get; set; }
    public string locstatecode { get; set; }
}

public class Response
{
    public List<Player> players { get; set; }
}

public class RootObject
{
    public Response response { get; set; }
}

Then, using Newtonsoft.Json, you can deserialize the JSON object into your C# classes as follow:
JsonConvert.DeserializeObject<RootObject>("yourJsonString");

Answer: You mention that Newtonsoft.Json already referenced in the project.
Use class to represent json data structure, then you can easy deserialize it.
You can use only properties you need in the class.
public class Player
{
    public string personaname { get; set; }
}

var player = Newtonsoft.Json.JsonConvert.DeserializeObject<Player>(jsonString);

// use player.personaname

For updates question create classes which represent your data structure
public class Team
{
    public List<Player> players { get; set; }
}

public class Response
{
    public Team response { get; set; }
}

Comment: I have been very confused about the DeserializeObject method, would you be able to explain what I add in place of `Data`?
Comment: Create class `Data` or name it how you want.
Comment: I edited my question and added the changes that I made. SteamName is still returning null.
Comment: No very nice to edit questions this way, but simply you need to create classes which represents your data structure - you can use some online converters from json to c# classes - just search for "json to c# class"
Answer: You can use http://json2csharp.com/ to generate a class automatically from a JSON string.
Comment: I dont know why people down voted this answer ? This is a good one.
Comment: I am not downvoter, but I think because "link" answers not very welcome on SO
Comment: @Fabio I suspect that's why. That page goes down and this answer is useless. It's better as an aside to an existing answer.
Comment: I did downvote that answer because the OP is trying to convert in runtime. The question is not "How to write a C# class based on a JSON string". I bet he can write his classes by himself.

C# Parsing JSON String


Anti-derivative of an analytical expression

Question: I have a function $g : \mathbb{R}^d \rightarrow \mathbb{R}$ and I want to find the anti-derivative of the following expression:
$$ \partial_{x_1} g(x) + a $$
where the differentiation is taken with repect to $x_1$ in $\partial_{x_1} g(x)$ and $a \in \mathbb{R}$. For the second term, it should be $x_1$ but for the first one can I simply say $g(x)$? as obviously $g(x_1)$ is not well-defined?
Answer: An anti-derivative is given by
$$g(x)+ax_1+\varphi(x_2,...,x_n).$$
$\varphi$ is a (unknown) function, which does not depend on $x_1.$
Comment: just one more question, if I had $ \partial_{x_1} g(x) + a = 0 $, with the function $g$ being convex, can I safely say that $x$ minimizes the convex function $g(x) + a x_1$?


Given marginal tables back solve for contingency table

Question: How to programmatically solve problems similar to the below:
Most basic example: Given two marginal tables, solve for 2x2 distribution.

A
Sum

0
3

1
7

B
Sum

0
4

1
6

Solve for

A
B
Sum

0
0

0
1

1
0

1
1

The solution needs to be scalable. For example, given n * m and n * z solve for n * m * z.
Answer: Maybe I don't exactly follow your question. However, there is more information
in the bivariate distribution than can be retrieved from the two marginal
distributions. That holds for sample distributions as well.
Consider:
TABLE 1    A  not A   TOTAL

B         25   25       50
not B     25   25       50

TOTAL     50   50      100

and
TABLE 2    A  not A   TOTAL

B         50    0       50
not B      0   50       50

TOTAL     50   50      100

Moreover, there are many other $2\times 2$ tables
that have the same marginals.
If you believe that (or want to test whether) the A categories (columns) and the
B categories (rows) are independent, Table 1 is what you want.
That would would be the table of
expected counts for a chi-squared test.
Comment: If you found this answer helpful, then please consider
[upvoting](https://stats.stackexchange.com/help/why-vote)
and/or
[accepting](https://stats.stackexchange.com/help/accepted-answer)
it.


Cross-validation: error estimation and bias

Question: When obtaining the error estimation of a model over a dataset using k-fold cross-validation, lower values of the error estimation necessarily imply a lower bias? Are both concepts, error estimation and bias, equivalent?
Answer: Higher test errors can also indicate lower bias, e.g. if the training error is low. So, lower error is not equivalent to lower bias.
Comment: If the test error is what is used as performance estimation, isn't that equivalent to the model bias? Supposedly, if you reduce the test error, then the bias (how far you are from the real performance of the model) must necessarily be reduced, right?
Comment: What if you move from a highly overfitted model (high var, low bias) to a model that gives decent test performance?


Android like loadingview

Question: Im using the following code to get the effect similar to that of the android  like progress:

-(void) showSpinner
{

    NSLog(@"as");
    loadingView = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 170, 170)];
    loadingView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    loadingView.clipsToBounds = YES;
    loadingView.layer.cornerRadius = 10.0;

    activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    activityView.frame = CGRectMake(65, 40, activityView.bounds.size.width, activityView.bounds.size.height);
    [loadingView addSubview:activityView];

    loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
    loadingLabel.backgroundColor = [UIColor clearColor];
    loadingLabel.textColor = [UIColor whiteColor];
    loadingLabel.adjustsFontSizeToFitWidth = YES;
    loadingLabel.textAlignment = NSTextAlignmentCenter;
    loadingLabel.text = @"Loading...";
    [loadingView addSubview:loadingLabel];
    loadingView .center = CGPointMake(CGRectGetWidth(self.view.frame) / 2, CGRectGetHeight(self.view.frame) / 2);

    [self.statutoryTbl addSubview:loadingView];
    [activityView startAnimating];
}

The issue is that the UILabel appears below the spinner. I want it to be nearby spinner and the loadingview to be wide as android. What am I missing in my code?
Comment: Update the `xAxis` of `loadingLabel ` to 100 (or activityView.frame.size.width+ activityView.frame.origin.x+20)
Answer: Initialise your loadingLabel with this code:
loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake([activityView frame].origin.x+[activityView frame].size.width+20, 10, [loadingView frame].size.width-([activityView frame].origin.x+[activityView frame].size.width+20)-10, [loadingView frame].size.height-20)];

Android like loadingview


Fetch all products of a category in custom post type in wordpress

Question: I am new in wordpress and I am using RT-Theme 15 and I Want to show all
product of custom Post type. When I fetch products all products is not  coming
of a particular category. only 9 product is coming out of 15.
here is code whic is showing 9 products:-
<?php
#
# rt-theme product loop
#
global $args,$wp_query;

//column

$box_counter = 0;

if(is_tax()) $args = array_merge( $wp_query->query, $args);

query_posts($args);

$product = array();
$postCount = 0;

if ( have_posts() ) : while ( have_posts() ) : the_post();

?>

    <?php
    //box class

    $product[$postCount]['title']       =   get_the_title();
    $product[$postCount]['thumb']       =   find_image_org_path(get_post_meta($post->ID, THEMESLUG.'product_image_url', true));
    $product[$postCount]['image']       =   @vt_resize( '', $thumb, $w, $h, ''.$crop.'' );
    $product[$postCount]['short_desc']  =   get_post_meta($post->ID, THEMESLUG.'short_description', true);
    $product[$postCount]['permalink']   =   get_permalink();
    $product[$postCount]['watt']        =   get_post_meta($post->ID, 'wpcf-watt', true);

    $postCount = $postCount + 1;
    ?>

<?php endwhile?>
<?php

    echo "
";print_r($product);

?>

<?php endif; wp_reset_query();?>

But I want to all products into array. I don't know how to show all products and
where is setting I have to change to show to all products.
Answer: You can use argument posts_per_page in your query. Set it to -1 and it will fetch all the posts.
So something like this:
$args['posts_per_page'] = -1; query_posts($args);
Answer:
You can set count use this code in function.php file
function change_posts_per_page( $query )
{
  $query->set( 'posts_per_page', 5 );
 }
add_action( 'pre_get_posts', 'change_posts_per_page' );

or

You can set posts count from admin panel -
1] Go to Dashboard > Setting
2] Then Reading Settings.
3] In to that set post count 15.
4] Then Save Changes


Modeling frequency over time

Question: I have a two-dimensional data set that looks like $(t, x)$ where $t$ is a time in seconds when event $X$ happened. $X$ ranges from $[0, 200]$.
I want to visualize the frequency of each $x$ at time $t$ over some time period. I guess this would be a bar graph with $x$-axis being event #, $y$-axis being frequency, and $z$-axis being time, $t$.
Furthermore, I would like to group all events that happen within say a 5 second interval to count towards the same frequency bar on the $y$-axis.
If there is a way to do this with R that would be even better.
My goal is to get a sense how often some event occurs over the course of a day, and when certain events happen a lot or infrequently. If you know of a better way to understand this information, I am all ears.
Comment: It might help if you showed us some data (invented if necessary) which illustrates your question.
Comment: @Henry that is actually exactly what the data looks like: (1, 3), (1, 4), (2.4, 4), ... where x is time in seconds and the y coordinate is [0,200]
Answer: The key thing is you "want to visualize the frequency of each X at time t over some time period.".  Here is a starter with the straightforward methods.  Which method to use will very much depend on how your actual data looks.
# generate data
n <- 10000
mydata <- data.frame(
    Time=rexp(n, 5),
    X=runif(n))

First method - straightforward point plot, using transparency to avoid over-plotting problems
library(ggplot2)
ggplot(mydata, aes(x=Time, y=X)) +
    geom_point(alpha=0.1)

Second method - turn Time into a discrete variable and show box plots
mydata$Time.f <- cut(mydata$Time, breaks=20)
ggplot(mydata, aes(x=Time.f, y=X)) +
    geom_boxplot() +
    coord_flip()

Comment: I think he wants 5 sec. binning. I also assume his X are integral and hence each X could get its own count over every 5 sec interval.

Modeling frequency over time


Variable is not declared or inaccessible due to its protection level.

Question: Im new in visual basic and right now I'm studying how to import csv file to database. I have this codes that imports csv file to access database but I keep getting this error:
'txtFile' is not declared. It may be inaccessible due to its protection level

Here is the code.
Imports System.Data.OleDb
Imports System.Threading
Imports System.Windows
Imports System.Collections

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim cnAccess As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" & Application.StartupPath & "C:\Users\vissia18\Desktop\ReportDB2.accdb;")

        Dim op1 As New OpenFileDialog
        op1.ShowDialog()
        txtFile.Text = op1.FileName

        Dim QryInsert As String = "", QryCreate As String = ""
        Dim i As Integer
        Dim cmd As New OleDbCommand
        Dim Fnm As String = txtFile.Text
        Dim s1 As String
        Dim s2(5) As String
        Dim freader As New IO.StreamReader(Fnm, False)
        cmd.Connection = cnAccess
        cnAccess.Open()
        While (freader.EndOfStream = False)
            s1 = freader.ReadLine
            s2 = s1.Split(",")
            QryInsert = "Insert Into Report Values (" & s2(0) & ",'" & s2(1) & "'," & s2(2) & ")"
            cmd.CommandText = QryInsert
            cmd.ExecuteNonQuery()
        End While
        MsgBox("Data Imported Successfully")
        cnAccess.Close()

    End Sub

End Class

Please correct me if I'm wrong somewhere else. Any help will be very much appreciated.
Answer: txtFile is not declared in your above code. You need to declare variables before using them.
Try to replace
txtFile.Text = op1.FileName
[....]
Dim Fnm As String = txtFile.Text

with
Dim txtFile as String = op1.FileName
[....]
Dim Fnm As String = txtFile

Comment: but I have an exception which is on this code: Dim freader As New IO.StreamReader(Fnm, False). It said that the process is being used by another process. do you know what happened?
Comment: Answer edited due to a mistake. You need to declare Fnm as well .Sorry. Also make sure you don't have the file open in Notepad or any other editor.


Get Working path with highest privileges in C

Question: This is not a problem, more a good to know topic. I can life without an solution but it was nice to have an Solution.
When i run my .exe with normal privileges i got the correct path where the .exe is saved. When i run the .exe with highest privileges the returned path is "C:\Windows\System32". The correct location is i.e. "C:\Msys64\home\testproject\".

My code to get the path uses the Windows command "cd":
bool get_path(Arg* arg)
{
    //This function will only return the correct path when not run with highest privilegs over Taskscheduler
    FILE* fp = _popen("cd", "r");
    arg->workingdir_cnt = 0;
    while (!(feof(fp)))
    {
        arg->workingdir[arg->workingdir_cnt++] = fgetc(fp);
        if (arg->workingdir_cnt > sizeof(arg->workingdir)) { fclose(fp); return 0; }
    }
    _pclose(fp);

    //Add backslash for future use
    arg->workingdir[arg->workingdir_cnt-2] = '\\';
    arg->workingdir[arg->workingdir_cnt-1] = '\0';

    return 1;
}

Comment: It sounds like you are not interested in the current working directory, but rather in the directory where the executable is located (the two are generally unrelated). You can obtain the running EXE's file name with `GetModuleFileName(NULL)`
Comment: And if you do want current working directory, there are easier ways than shelling out to `cd` command. See `GetCurrentDirectory` (Windows-specific) or `_getcwd` (somewhat more portable).
Comment: "Current working directory" and "directory where EXE is located" are in general two different directories. If they happen to be the same, it's only by coincidence. Current working directory can be changed at any time (see e.g. `SetCurrentDirectory`). I showed you how to get both; you just need to figure out which one you actually want.
Comment: @AndrewTruckle Look at the edit history.
Comment: Thats correct. I wan´t to know where is the .exe saved. In example above i expect the return to path "C:\Msys64\home\testproject". I will try your Solution. In MicrosoftWeb it looks like good.
Comment: Use the standard library's `std::filesystem::current_path()`. You have tagged the question with [tag:c++], hence my answer is eligible. Seriously, use `GetModuleFileName()`
Comment: `while (!(feof(fp)))`???  You need to read [**Why is "while( !feof(file) )" always wrong?**](https://stackoverflow.com/questions/5431941/why-is-while-feoffile-always-wrong)
Comment: @273K he tagged it c.
Answer: GetModuleFileNameA() works for me. It output in every execute method the same Path (where the .exe is saved). Thanks @Igor Tandetnik


POST: 403 error in REST

Question: I created a custom entity, next I enabled (via RESTui) the GET and POST methods. I gave anonymous users permissions to "Access GET", "Access POST" and "Create new content" of that entity.
When I navigate in my browser to "http://mywebsite/my_entity/1?_format=json", I get a proper JSON response. When I navigate to "http://mywebsite/my_entity/add", I can add a new entity.
When I try to POST a new entity via "http://mywebsite/my_entity?_format=json", I get a 403 repsonse with following body:

{   "message": "" }

Does someone have an idea what I'm missing here?
EDIT: When i put a die('give me something') in the method post() of the class "EntityResource" (which is the base class for all entities), the message isn't displayed...
EDIT2: I added headers "Content-Type" and "X-CSRF-Token"
Comment: I hope you solved it by now. Hard to answer your question without seeing your body code.
Answer: Do you provide a (Basic) authorization header, as well as a X-CSRF-Token header in your POST?
See also:
https://www.drupal.org/documentation/modules/rest/start - "2.2 Unsafe methods & CSRF protection: X-CSRF-Token request header"
Edit:
So you should at least specify the following HTTP headers:

Content-type: application/json
X-CSRF-Token: [TOKEN RETURNED FROM A REQUEST TO /rest/session/token]
Comment: forgot to mention:I did add those headers :)

POST: 403 error in REST


Ruby/Rails with Rails Engine (Redmine plugins) - Adding to a base view without overriding it?

Question: I have a plugin that needs to add something the the base Redmine layout. The change consists of a couple divs and a call to a JavaScript function. Currently I am accomplishing this by simply overriding the base layout view.
I don't like doing this since if we upgrade Redmine any pages overridden would not update with the updated version. Is there a more elegant way to add this functionality?
Answer: You will want to use the Redmine Hooks to add content to the base layout.


How to calculate unique combinations that with fixed positions

Question: I am not that great at math, but am still interested in how one would go about calculating the following question:
Employees can type in their access code. There are two sets: A,B,C,D,E and 1,2,3,4,5.
An access code looks like this: E314. So always one letter at the beginning, then 3 numbers. There are 350 employees. Are there enough unique access codes for every person?
Now, I tried looking this up, but I couldn't find how this should be calculated when there are fixed positions, i.e. the letter at the start of any access code.
Thanks in advance!
Comment: As to the usefulness of these access codes, it seems like a rather poor system unless it had multifactor authentication of some sort since someone could just come up and press random buttons and have a very high chance of having correctly guess a code that is in use
Answer: This follows directly from the rule of product which loosely paraphrased says that if every outcome can be described uniquely by a sequence of steps where the number of options per step does not change based on previously made choices, then the total number of outcomes is the product of the number of options for each step.  Here, there are $5$ options for the starting letter, $5$ options for the first number, $5$ options for the second number, and $5$ options again for the third number for $5^4$ total outcomes.


Moving data between Java and R using renjin

Question: I'm trying to move data between Java and R and vice-versa (as a dataframe) using Renjin. Searching in Stackoverflow I've find something that at first I've thoutht it would work but It wouldn't because I've got the R data in Java  as an externalptr. Here is the code:
package teste;
(imports omitted)
public class TesteRenjin {
public static void main(String[] args) throws ClassNotFoundException {

List<Processos_Julgados> processosJulgados = new
ArrayList<Processos_Julgados>();

    String driver = "com.mysql.jdbc.Driver";
    String pwd = "";
    String user = "root";
    String url = "jdbc:mysql://localhost/cocaj_miner";
    Connection con = null;

    try {

    Class.forName(driver);
    con = DriverManager.getConnection(url, user, pwd);
    System.out.println("Conexão bem sucedida");
    String sql = "select ementa, numProcesso from processos_julgados where
ementa is not Null limit 15";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);

while (rs.next()) {

Processos_Julgados procJulg = new Processos_Julgados();
procJulg.setNumProcesso(rs.getString("numProcesso"));
procJulg.setEmenta(rs.getString("ementa"));
processosJulgados.add(procJulg);

        }

    } catch (SQLException e) {

        System.out.println(e.getMessage());
        //System.out.println("Conexão não foi possível");
    } finally {

        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(TesteRenjin.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    StringArrayVector.Builder numProcParaR = new StringArrayVector.Builder();

    for (Processos_Julgados processos : processosJulgados) {

        numProcParaR.add(processos.getNumProcesso());

    }

    ListVector.NamedBuilder dfProcessos = new ListVector.NamedBuilder();

    dfProcessos.setAttribute(Symbols.CLASS, StringVector.valueOf("data.frame"));
    dfProcessos.setAttribute(Symbols.ROW_NAMES, new RowNamesVector(processosJulgados.size()));
    dfProcessos.add("processos", numProcParaR.build());

    RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
    ScriptEngine engine = factory.getScriptEngine();

    engine.put("df", dfProcessos);

    try {
        engine.eval("str(df)");
    } catch (ScriptException ex) {
        Logger.getLogger(TesteRenjin.class.getName()).log(Level.SEVERE, null, ex);
    }

}

}
Could you help me please?
Answer: You are almost there.
The java object dfProcessos contains a ListVector.NamedBuilder, not a ListVector. A ListVector implements the SEXP interface, and so will be treated as a normal R object (or "S-Expression"), while all other Java objects, including the Builder object, need to be wrapped in an External Pointer R Object.
Change the line:
engine.put("df", dfProcessos);

To:
engine.put("df", dfProcessos.build());

And it should work.


Page template suggestion based on content types but not for node/edit or node/delete

Question: I have a template for a page content type that works perfect. But when I try to edit or delete the node of that content type it blocks the standard template.
So node/130/edit? or node/130/delete? are not working because I don't get the right page.
I tried strpos($_SERVER['REQUEST_URI']) versions but it doesn't work or like the one below only gives me the "original" Drupal template  when the path is node/130/edit? so the second variable gets through.
function mytheme_theme_suggestions_page_alter(array &$suggestions, array $variables) {
      // Add content type suggestions.
      if (($node = \Drupal::request()->attributes->get('node')) &&
      (strpos($_SERVER['REQUEST_URI'], "delete") || strpos($_SERVER['REQUEST_URI'], "edit") === false)
      ) {
        array_splice($suggestions, 1, 0, 'page__node__' . $node->getType());
      }
    }

The array_splice hint comes from
https://www.drupal.org/forum/support/theme-development/2015-07-02/how-to-add-in-drupal-8-a-custom-suggestion-page-template#comment-10684366
Any help?
Comment: This may help you figure out what template you need to override for node edit and delete: https://www.drupal.org/docs/8/theming/twig/debugging-twig-templates .
Answer: A slightly different approach: Add a custom theme suggestion for the canonical route of your node type(s).
This way, you neither have to meddle with path arguments whose position might change, e.g. when using subpath aliases in a later stage of your site's development cycle, nor have to extend your checks for additional routes added by third party modules, as e.g. node/{nid}/translate, node/{nid}/revisions, node/{nid}/devel, and so on.
I didn't test it though, but you could do something like this:
/**
 * Implements hook_theme_suggestions_HOOK_alter() for page.html.twig.
 */
function mytheme_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if (
    $route_name = \Drupal::routeMatch()->getRouteName()
    && $route_name == 'entity.node.canonical'
    && $node = \Drupal::request()->attributes->get('node')
  ) {
    $suggestions[] = 'page__node__' . $node->getType() . '__canonical';
  }
}

Then you could rename your page template to page--node--my-type--canonical.html.twig and it should be picked up only for your node type my_type at its canonical (view) route.
Comment: This feels like the right track, but I get this error:

Notice: Undefined variable: route_name in isutheme_theme_suggestions_page_alter() (line 55 of themes/isubit/isutheme/isutheme_theme.theme).
Comment: I think I figured it out: I had to add `$route_name = \Drupal::routeMatch()->getRouteName();` before and just outside the if
Answer: You can work with path_args instead of $_SERVER['REQUEST_URI'].
Something like:
function mythem_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  // Add content type suggestions.
  // Get current path.
  $current_path = \Drupal::service('path.current')->getPath();
  // explode args.
  $path_args = explode('/', $current_path);
  if (($node = \Drupal::request()->attributes->get('node')) && isset($path_args[3]) && ($path_args[3] == 'edit' || $path_args[3] == 'delete')) {
    array_splice($suggestions, 1, 0, 'page__node__' . $node->getType());
  }
}

For more infos about how to get url args take a look at https://www.drupal.org/node/2274705