~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/Eigen2/Eigen/src/Array/Random.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This file is part of Eigen, a lightweight C++ template library
2
 
// for linear algebra. Eigen itself is part of the KDE project.
3
 
//
4
 
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
5
 
//
6
 
// Eigen is free software; you can redistribute it and/or
7
 
// modify it under the terms of the GNU Lesser General Public
8
 
// License as published by the Free Software Foundation; either
9
 
// version 3 of the License, or (at your option) any later version.
10
 
//
11
 
// Alternatively, you can redistribute it and/or
12
 
// modify it under the terms of the GNU General Public License as
13
 
// published by the Free Software Foundation; either version 2 of
14
 
// the License, or (at your option) any later version.
15
 
//
16
 
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17
 
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19
 
// GNU General Public License for more details.
20
 
//
21
 
// You should have received a copy of the GNU Lesser General Public
22
 
// License and a copy of the GNU General Public License along with
23
 
// Eigen. If not, see <http://www.gnu.org/licenses/>.
24
 
 
25
 
#ifndef EIGEN_RANDOM_H
26
 
#define EIGEN_RANDOM_H
27
 
 
28
 
template<typename Scalar> struct ei_scalar_random_op EIGEN_EMPTY_STRUCT {
29
 
  inline ei_scalar_random_op(void) {}
30
 
  inline const Scalar operator() (int, int) const { return ei_random<Scalar>(); }
31
 
};
32
 
template<typename Scalar>
33
 
struct ei_functor_traits<ei_scalar_random_op<Scalar> >
34
 
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
35
 
 
36
 
/** \array_module
37
 
  * 
38
 
  * \returns a random matrix (not an expression, the matrix is immediately evaluated).
39
 
  *
40
 
  * The parameters \a rows and \a cols are the number of rows and of columns of
41
 
  * the returned matrix. Must be compatible with this MatrixBase type.
42
 
  *
43
 
  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
44
 
  * it is redundant to pass \a rows and \a cols as arguments, so ei_random() should be used
45
 
  * instead.
46
 
  *
47
 
  * \addexample RandomExample \label How to create a matrix with random coefficients
48
 
  *
49
 
  * Example: \include MatrixBase_random_int_int.cpp
50
 
  * Output: \verbinclude MatrixBase_random_int_int.out
51
 
  *
52
 
  * \sa MatrixBase::setRandom(), MatrixBase::Random(int), MatrixBase::Random()
53
 
  */
54
 
template<typename Derived>
55
 
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
56
 
MatrixBase<Derived>::Random(int rows, int cols)
57
 
{
58
 
  return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>());
59
 
}
60
 
 
61
 
/** \array_module
62
 
  * 
63
 
  * \returns a random vector (not an expression, the vector is immediately evaluated).
64
 
  *
65
 
  * The parameter \a size is the size of the returned vector.
66
 
  * Must be compatible with this MatrixBase type.
67
 
  *
68
 
  * \only_for_vectors
69
 
  *
70
 
  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
71
 
  * it is redundant to pass \a size as argument, so ei_random() should be used
72
 
  * instead.
73
 
  *
74
 
  * Example: \include MatrixBase_random_int.cpp
75
 
  * Output: \verbinclude MatrixBase_random_int.out
76
 
  *
77
 
  * \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random()
78
 
  */
79
 
template<typename Derived>
80
 
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
81
 
MatrixBase<Derived>::Random(int size)
82
 
{
83
 
  return NullaryExpr(size, ei_scalar_random_op<Scalar>());
84
 
}
85
 
 
86
 
/** \array_module
87
 
  * 
88
 
  * \returns a fixed-size random matrix or vector
89
 
  * (not an expression, the matrix is immediately evaluated).
90
 
  *
91
 
  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
92
 
  * need to use the variants taking size arguments.
93
 
  *
94
 
  * Example: \include MatrixBase_random.cpp
95
 
  * Output: \verbinclude MatrixBase_random.out
96
 
  *
97
 
  * \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random(int)
98
 
  */
99
 
template<typename Derived>
100
 
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
101
 
MatrixBase<Derived>::Random()
102
 
{
103
 
  return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>());
104
 
}
105
 
 
106
 
/** \array_module
107
 
  * 
108
 
  * Sets all coefficients in this expression to random values.
109
 
  *
110
 
  * Example: \include MatrixBase_setRandom.cpp
111
 
  * Output: \verbinclude MatrixBase_setRandom.out
112
 
  *
113
 
  * \sa class CwiseNullaryOp, setRandom(int), setRandom(int,int)
114
 
  */
115
 
template<typename Derived>
116
 
inline Derived& MatrixBase<Derived>::setRandom()
117
 
{
118
 
  return *this = Random(rows(), cols());
119
 
}
120
 
 
121
 
/** Resizes to the given \a size, and sets all coefficients in this expression to random values.
122
 
  *
123
 
  * \only_for_vectors
124
 
  *
125
 
  * Example: \include Matrix_setRandom_int.cpp
126
 
  * Output: \verbinclude Matrix_setRandom_int.out
127
 
  *
128
 
  * \sa MatrixBase::setRandom(), setRandom(int,int), class CwiseNullaryOp, MatrixBase::Random()
129
 
  */
130
 
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
131
 
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
132
 
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
133
 
{
134
 
  resize(size);
135
 
  return setRandom();
136
 
}
137
 
 
138
 
/** Resizes to the given size, and sets all coefficients in this expression to random values.
139
 
  *
140
 
  * \param rows the new number of rows
141
 
  * \param cols the new number of columns
142
 
  *
143
 
  * Example: \include Matrix_setRandom_int_int.cpp
144
 
  * Output: \verbinclude Matrix_setRandom_int_int.out
145
 
  *
146
 
  * \sa MatrixBase::setRandom(), setRandom(int), class CwiseNullaryOp, MatrixBase::Random()
147
 
  */
148
 
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
149
 
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
150
 
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
151
 
{
152
 
  resize(rows, cols);
153
 
  return setRandom();
154
 
}
155
 
 
156
 
#endif // EIGEN_RANDOM_H