Changeset 3066


Ignore:
Timestamp:
Dec 29, 2013 12:27:20 PM (6 years ago)
Author:
bradbell
Message:

check_all.sh: run with boost vectors, point to check_all.err for warnings.
run_cmake.sh: select vector type with default boost vector,
eigen_scalar.sh: use name in more places.
eigen_shadow.sh: demonstate eigen does not support -Wshadow.
eigen_io.sh: problem fixed (long ago).
eigen_mul.sh: problem fixed using explicit from any type conversion.

Location:
trunk
Files:
2 deleted
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/bin/check_all.sh

    r2873 r3066  
    2626        fi
    2727        msg=`cat $top_srcdir/check_all.err`
    28         cat $top_srcdir/check_all.err
    29         rm $top_srcdir/check_all.err
    3028        if [ "$msg" != '' ]
    3129        then
     30                echo "$msg"
     31                echo 'Warning: see check_all.err'
    3232                exit 1
    3333        fi
     34        rm $top_srcdir/check_all.err
    3435}
    3536log_eval() {
     
    8586        fi
    8687done
    87 echo_log_eval bin/run_cmake.sh
     88echo_log_eval bin/run_cmake.sh --boost_vector
    8889echo_log_eval cd build
    8990# -----------------------------------------------------------------------------
  • trunk/bin/run_cmake.sh

    r3063 r3066  
    2222        eval $*
    2323}
    24 # ---------------------------------------------------------------------------
    25 # clean all variables in cmake cache
    26 cmake_args='-U .+'
    27 if [ "$1" != "" ]
    28 then
     24# -----------------------------------------------
     25verbose='no'
     26testvector='boost'
     27while [ "$1" != "" ]
     28do
    2929        if [ "$1" == '--verbose' ]
    3030        then
    31                 # echo each command that make executes
    32                 cmake_args="$cmake_args  -D CMAKE_VERBOSE_MAKEFILE=1"
     31                verbose='yes'
     32        elif [ "$1" == '--cppad_vector' ]
     33        then
     34                testvector='cppad'
     35        elif [ "$1" == '--boost_vector' ]
     36        then
     37                testvector='boost'
     38        elif [ "$1" == '--eigen_vector' ]
     39        then
     40                testvector='eigen'
    3341        else
    34                 echo 'usage: bin/run_cmake.sh: [--verbose]'
     42                options='[--verbose] [--<package>_vector]'
     43                echo "usage: bin/run_cmake.sh: $options"
     44                echo 'where <package> is cppad, boost, or eigen'
    3545                exit 1
    3646        fi
    37 fi
     47        shift
     48done
    3849if [ ! -e build ]
    3950then
     
    4152fi
    4253echo_eval cd build
     54# ---------------------------------------------------------------------------
     55# clean all variables in cmake cache
     56cmake_args='-U .+'
     57#
     58if [ "$verbose" == 'yes' ]
     59then
     60        # echo each command that make executes
     61        cmake_args="$cmake_args  -D CMAKE_VERBOSE_MAKEFILE=1"
     62fi
    4363# -----------------------------------------------------------------------------
    4464# cmake_install_prefix
     
    7797#
    7898# cppad_cxx_flags
    79 cmake_args="$cmake_args -D cppad_cxx_flags=\
    80 '-Wall -pedantic-errors -std=c++11 -Wshadow'"
     99cmake_args="$cmake_args -D cppad_cxx_flags='-Wall -pedantic-errors -std=c++11'"
     100if [ "$testvector" != 'eigen' ]
     101then
     102        cmake_args="$cmake_args -Wshadow"
     103fi
    81104#
    82105# simple options
     
    84107cmake_args="$cmake_args -D cppad_documentation=YES"
    85108cmake_args="$cmake_args -D cppad_sparse_list=YES"
    86 cmake_args="$cmake_args -D cppad_testvector=cppad"
     109cmake_args="$cmake_args -D cppad_testvector=$testvector"
    87110cmake_args="$cmake_args -D cppad_tape_id_type='int'"
    88111cmake_args="$cmake_args -D cppad_tape_addr_type=int"
  • trunk/bug/eigen_scalar.sh

    r3060 r3066  
    9898
    9999        if( D(0,0) != myscalar(6.0) )
    100         {       std::cout << "eigen_mul: Error" << std::endl;
     100        {       std::cout << "$name: Error" << std::endl;
    101101                return 1;
    102102        }
    103         std::cout << "eigen_mul: OK" << std::endl;
     103        std::cout << "$name: OK" << std::endl;
    104104        return 0;
    105105}
  • trunk/bug/eigen_shadow.sh

    r3065 r3066  
    1111# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1212# -----------------------------------------------------------------------------
    13 # eigen_scalar.cpp:57:21:
    14 # warning: ISO C++ says that these are ambiguous,
    15 # even though the worst conversion for the first is better
    16 # than the worst conversion for the second: [enabled by default]
    17 D      = A * (B * C);
    18 #                     ^
     13# Eigen generates lots of warnings if -Wshadow is set of compile; e.g.,
     14# the first warning generated by this script is:
     15#
     16# warning: declaration of ‘value’ shadows a member of 'this' [-Wshadow]
     17   explicit variable_if_dynamic(T value) : m_value(value) {}
     18#                                           ^
    1919# ------------------------------------------------------------------------------
    2020# bash function that echos and executes a command
     
    3636# include <Eigen/Core>
    3737
    38 // following is 0 or 1. If 0, there is no warning
    39 # define DEFINE_TEMPLATED_CONSTRUCTOR 1
    40 
    41 // ------------------------------------------------------------------------
    42 class myscalar {
    43 public:
    44         // data
    45         double value_;
    46         // constructors
    47         myscalar(void)
    48         {       value_ = 0.0; }
    49         myscalar(const double& value)
    50         {       value_ = value; }
    51 
    52 # if DEFINE_TEMPLATED_CONSTRUCTOR
    53         template <class T> explicit myscalar(const T& value)
    54         {       value_ = double(value); }       
    55 # endif
    56 
    57         // binary operators
    58         myscalar operator+(const myscalar& right) const
    59         {       myscalar result = value_ + right.value_;
    60                 return result;
    61         }
    62         myscalar operator*(const myscalar& right) const
    63         {       myscalar result = value_ * right.value_;
    64                 return result;
    65         }
    66         bool operator!=(const myscalar& right) const
    67         {       bool result = value_ != right.value_;
    68                 return result;
    69         }
    70 
    71         // assignments
    72         myscalar& operator=(const double& value)
    73         {       value_ = value;
    74                 return *this;
    75         }
    76 
    77         // computed assignment operators
    78         myscalar& operator +=(const myscalar& right)
    79         {       value_ += right.value_;
    80                 return *this;
    81         }
    82 
    83 };
    84 // ------------------------------------------------------------------------
    8538int main() {
    8639        using Eigen::Matrix;
    8740        using Eigen::Dynamic;
     41        Matrix<double, Dynamic, Dynamic> A(1,1);
     42        A(0,0) = 6.0;
    8843
    89         Matrix<myscalar, Dynamic, Dynamic> A(1,1);
    90         Matrix<myscalar, Dynamic, Dynamic> B(1,1);
    91         Matrix<myscalar, Dynamic, Dynamic> C(1,1);
    92         Matrix<myscalar, Dynamic, Dynamic> D(1,1);
    93 
    94         A(0,0) = 1.0;
    95         B(0,0) = 2.0;
    96         C(0,0) = 3.0;
    97         D      = A * (B * C);
    98 
    99         if( D(0,0) != myscalar(6.0) )
    100         {       std::cout << "eigen_mul: Error" << std::endl;
     44        if( A(0,0) != 6.0 )
     45        {       std::cout << "$name: Error" << std::endl;
    10146                return 1;
    10247        }
    103         std::cout << "eigen_mul: OK" << std::endl;
     48        std::cout << "$name: OK" << std::endl;
    10449        return 0;
    10550}
     
    11560        -O0 \
    11661        -std=c++11 \
     62        -Wshadow \
    11763        -o $name
    11864echo_eval ./$name
Note: See TracChangeset for help on using the changeset viewer.