master: cppad_vector: include sizing constructor with int argument.
command_line_arg.cmake: only set default and cache for mssing variables.
Brad Bell
4 years ago
0 | 0 |
# -----------------------------------------------------------------------------
|
1 | |
# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
|
|
1 |
# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-20 Bradley M. Bell
|
2 | 2 |
#
|
3 | 3 |
# CppAD is distributed under the terms of the
|
4 | 4 |
# Eclipse Public License Version 2.0.
|
|
37 | 37 |
ENDIF( NOT ( ${type} STREQUAL "PATH" ) )
|
38 | 38 |
ENDIF( NOT ( ${type} STREQUAL "STRING" ) )
|
39 | 39 |
#
|
40 | |
SET(${variable} "${default}" CACHE ${type} "${description}")
|
|
40 |
IF( NOT ${variable} )
|
|
41 |
SET(${variable} "${default}" CACHE ${type} "${description}")
|
|
42 |
ENDIF( NOT ${variable} )
|
41 | 43 |
MESSAGE(STATUS "${variable} = ${${variable}}")
|
42 | 44 |
#
|
43 | 45 |
ENDMACRO( command_line_arg )
|
55 | 55 |
// check Simple Vector specifications
|
56 | 56 |
CppAD::CheckSimpleVector< Scalar, vector<Scalar> >();
|
57 | 57 |
|
|
58 |
// check constructor with size_t and with an int
|
|
59 |
size_t two_s = 2;
|
|
60 |
int two_i = 2;
|
|
61 |
vector<Scalar> vec(2), other(two_s), another(two_i);
|
|
62 |
|
58 | 63 |
// assignment returns reference for use in other assignments
|
59 | |
vector<Scalar> vec(2), other(2), another(2);
|
60 | 64 |
another[0] = Scalar(1);
|
61 | 65 |
another[1] = Scalar(2);
|
62 | 66 |
vec = other = another;
|
0 | 0 |
/* --------------------------------------------------------------------------
|
1 | |
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
|
|
1 |
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-20 Bradley M. Bell
|
2 | 2 |
|
3 | 3 |
CppAD is distributed under the terms of the
|
4 | 4 |
Eclipse Public License Version 2.0.
|
|
81 | 81 |
and not the rest of CppAD, you should include
|
82 | 82 |
$code cppad/utility/vector_bool.hpp$$.
|
83 | 83 |
|
|
84 |
$head Integer Size$$
|
|
85 |
The size $icode n$$ in the constructor syntax below can be an
|
|
86 |
$code int$$ (all simple vectors support $code size_t$$):
|
|
87 |
$codei%
|
|
88 |
CppAD::vector<%Scalar%> %vec%(%n%)
|
|
89 |
%$$
|
84 | 90 |
|
85 | 91 |
$head capacity$$
|
86 | 92 |
If $icode cap$$ is a $code size_t$$ object,
|
118 | 118 |
$head Sizing$$
|
119 | 119 |
$codei%vector<%Type%> %vec%(%n%)
|
120 | 120 |
%$$
|
121 | |
where $icode n$$ is a $code size_t$$,
|
|
121 |
where $icode n$$ is a $code size_t$$ or $code int$$,
|
122 | 122 |
creates the vector $icode vec$$ with $icode n$$ elements and capacity
|
123 | 123 |
greater than or equal $icode n$$.
|
124 | 124 |
|
|
146 | 146 |
{ }
|
147 | 147 |
vector(size_t n) : capacity_(0), length_(0), data_(CPPAD_NULL)
|
148 | 148 |
{ resize(n); }
|
|
149 |
vector(int n) : capacity_(0), length_(0), data_(CPPAD_NULL)
|
|
150 |
{ CPPAD_ASSERT_KNOWN(
|
|
151 |
n >= 0,
|
|
152 |
"CppAD::vector: attempt to create a vector with a negative size."
|
|
153 |
);
|
|
154 |
resize( size_t(n) );
|
|
155 |
}
|
149 | 156 |
vector(const vector& other) : capacity_(0), length_(0), data_(CPPAD_NULL)
|
150 | 157 |
{ resize(other.length_);
|
151 | 158 |
for(size_t i = 0; i < length_; i++)
|
20 | 20 |
$$
|
21 | 21 |
|
22 | 22 |
$section Changes and Additions to CppAD During 2020$$
|
|
23 |
|
|
24 |
$head 03-11$$
|
|
25 |
The $code CppAD::vector$$ constructor was extended to allow its
|
|
26 |
$cref/size/CppAD_vector/Integer Size/$$ to be a $code int$$
|
|
27 |
(this used to generate a warning when using the $code clang$$ compiler).
|
23 | 28 |
|
24 | 29 |
$head 02-02$$
|
25 | 30 |
The $code get_optional.sh$$ prefix was extended so that it could be a
|