diff --git a/flens/blas/level1/copy.tcc b/flens/blas/level1/copy.tcc index f1a324b0..5b561f16 100644 --- a/flens/blas/level1/copy.tcc +++ b/flens/blas/level1/copy.tcc @@ -255,7 +255,7 @@ copy(Transpose trans, const MA &A, MB &&B) // when the left hand side is an empty matrix (such that it is no actual // resizing but rather an initialization). // - if (trans==NoTrans) { + if (trans==NoTrans || trans==Conj) { if ((A.numRows()!=B.numRows()) || (A.numCols()!=B.numCols())) { # ifndef FLENS_DEBUG_CLOSURES ASSERT(B.numRows()==0 || B.numCols()==0); diff --git a/flens/blas/level1extensions/conj.h b/flens/blas/level1extensions/conj.h index 3c7c0891..db18f3d6 100644 --- a/flens/blas/level1extensions/conj.h +++ b/flens/blas/level1extensions/conj.h @@ -46,6 +46,12 @@ template void>::Type conj(VX &&x); +//-- conj +template + typename RestrictTo::value, + void>::Type + conj(MA &&A); + } } // namespace blas, flens #endif // FLENS_BLAS_LEVEL1EXTENSIONS_CONJ_H diff --git a/flens/blas/level1extensions/conj.tcc b/flens/blas/level1extensions/conj.tcc index e94ada38..6439471c 100644 --- a/flens/blas/level1extensions/conj.tcc +++ b/flens/blas/level1extensions/conj.tcc @@ -71,6 +71,27 @@ conj(VX &&x) FLENS_BLASLOG_UNSETTAG; } +//-- conj +template +typename RestrictTo::value, + void>::Type +conj(MA &&A) +{ + FLENS_BLASLOG_SETTAG("--> "); + FLENS_BLASLOG_BEGIN_MCOTR(Conj, A); + +# ifdef HAVE_CXXBLAS_GECOTR + cxxblas::gecotr(A.order(), Conj, + A.numRows(), A.numCols(), + A.data(), A.leadingDimension()); +# else + ASSERT(0); +# endif + + FLENS_BLASLOG_END; + FLENS_BLASLOG_UNSETTAG; +} + } } // namespace blas, flens #endif // FLENS_BLAS_LEVEL1EXTENSIONS_CONJ_TCC diff --git a/flens/examples/howto-conjugate.cc b/flens/examples/howto-conjugate.cc new file mode 100644 index 00000000..d4e3dd83 --- /dev/null +++ b/flens/examples/howto-conjugate.cc @@ -0,0 +1,39 @@ +#include +#include + +using namespace flens; +using namespace std; + +int +main() +{ + typedef complex ZComplex; + typedef GeMatrix > ZGeMatrix; + + ZComplex I(0,1); + + ZGeMatrix A(2,3); + + A = 2.*I, 3.+I, 1., + 4., 2.+2.*I, 4.; + + cout << "A = " << A << endl; + + // in-place conjugate (via overloaded operators) + A = conjugate(A); + cout << "A = " << A << endl; + + // in-place conjugate (via explicit copy call) + blas::copy(Conj, A, A); + cout << "A = " << A << endl; + + // in-place conjugate (via explicit call) (new) + blas::conj(A); + cout << "A = " << A << endl; + + // elementwise variant + ZGeMatrix::IndexVariable k, l; + + A(k,l) = Real(A(k,l)) - Imag(A(k,l)) * I; + cout << "A = " << A << endl; +} diff --git a/flens/lapack/ge/hrd.tcc b/flens/lapack/ge/hrd.tcc index 29ab87b7..69ebb0f5 100644 --- a/flens/lapack/ge/hrd.tcc +++ b/flens/lapack/ge/hrd.tcc @@ -202,7 +202,9 @@ hrd_impl(IndexType iLo, // left // GeView Work(n-i-ib+1, ib, work, ldWork); - larfb(Left, ConjTrans, Forward, ColumnWise, + larfb(Left, + IsComplex::value ? ConjTrans : Trans, + Forward, ColumnWise, A(_(i+1,iHi),_(i,i+ib-1)), Tr, A(_(i+1,iHi),_(i+ib,n)), diff --git a/flens/lapack/interface/src/gees.cc b/flens/lapack/interface/src/gees.cc index 318a8da7..b39e7384 100644 --- a/flens/lapack/interface/src/gees.cc +++ b/flens/lapack/interface/src/gees.cc @@ -64,8 +64,6 @@ LAPACK_DECL(dgees)(const char *JOBVS, LOGICAL *BWORK, INTEGER *INFO) { - std::cerr << "dgees: N = " << *N << std::endl; - using std::max; using std::min; // diff --git a/flens/lapack/interface/src/geesx.cc b/flens/lapack/interface/src/geesx.cc index 88d90e12..29f80315 100644 --- a/flens/lapack/interface/src/geesx.cc +++ b/flens/lapack/interface/src/geesx.cc @@ -69,8 +69,6 @@ LAPACK_DECL(dgeesx)(const char *JOBVS, LOGICAL *BWORK, INTEGER *INFO) { - std::cerr << "dgeesx: N = " << *N << std::endl; - using std::max; using std::min; // diff --git a/flens/lapack/interface/src/geevx.cc b/flens/lapack/interface/src/geevx.cc index f79f7c98..2baef565 100644 --- a/flens/lapack/interface/src/geevx.cc +++ b/flens/lapack/interface/src/geevx.cc @@ -31,8 +31,6 @@ LAPACK_DECL(dgeevx)(const char *BALANC, INTEGER *IWORK, INTEGER *INFO) { - std::cerr << "dgeevx: N = " << *N << std::endl; - using std::max; using std::min; // diff --git a/flens/lapack/test.tgz b/flens/lapack/test.tgz index 052572a5..c3aad297 100644 Binary files a/flens/lapack/test.tgz and b/flens/lapack/test.tgz differ diff --git a/flens/scalaroperations/acos.h b/flens/scalaroperations/acos.h new file mode 100644 index 00000000..b1147f17 --- /dev/null +++ b/flens/scalaroperations/acos.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ACOS_H +#define FLENS_SCALAROPERATIONS_ACOS_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpACos {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + ACos(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ACOS_H diff --git a/flens/scalaroperations/acos.tcc b/flens/scalaroperations/acos.tcc new file mode 100644 index 00000000..d5321162 --- /dev/null +++ b/flens/scalaroperations/acos.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ACOS_TCC +#define FLENS_SCALAROPERATIONS_ACOS_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return acos(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +ACos(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ACOS_TCC diff --git a/flens/scalaroperations/asin.h b/flens/scalaroperations/asin.h new file mode 100644 index 00000000..cdf3c097 --- /dev/null +++ b/flens/scalaroperations/asin.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ASIN_H +#define FLENS_SCALAROPERATIONS_ASIN_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpASin {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + ASin(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ASIN_H diff --git a/flens/scalaroperations/asin.tcc b/flens/scalaroperations/asin.tcc new file mode 100644 index 00000000..1a07ac5d --- /dev/null +++ b/flens/scalaroperations/asin.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ASIN_TCC +#define FLENS_SCALAROPERATIONS_ASIN_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return asin(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +ASin(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ASIN_TCC diff --git a/flens/scalaroperations/atan.h b/flens/scalaroperations/atan.h new file mode 100644 index 00000000..5d0fdf34 --- /dev/null +++ b/flens/scalaroperations/atan.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ATAN_H +#define FLENS_SCALAROPERATIONS_ATAN_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpATan {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + ATan(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ATAN_H diff --git a/flens/scalaroperations/atan.tcc b/flens/scalaroperations/atan.tcc new file mode 100644 index 00000000..5892d2c8 --- /dev/null +++ b/flens/scalaroperations/atan.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ATAN_TCC +#define FLENS_SCALAROPERATIONS_ATAN_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return atan(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +ATan(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ATAN_TCC diff --git a/flens/scalaroperations/atan2.h b/flens/scalaroperations/atan2.h new file mode 100644 index 00000000..fa5d7c01 --- /dev/null +++ b/flens/scalaroperations/atan2.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ATAN2_H +#define FLENS_SCALAROPERATIONS_ATAN2_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpATan2 {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + ATan2(const Scalar &y, const Scalar &x); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ATAN2_H diff --git a/flens/scalaroperations/atan2.tcc b/flens/scalaroperations/atan2.tcc new file mode 100644 index 00000000..12b593e1 --- /dev/null +++ b/flens/scalaroperations/atan2.tcc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_ATAN2_TCC +#define FLENS_SCALAROPERATIONS_ATAN2_TCC 1 + +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return atan2(exp.left().value(), exp.right().value()); +} + +//-- operator overloading +template +const ScalarClosure +ATan2(const Scalar &y, const Scalar &x) +{ + typedef ScalarClosure SC; + return SC(y.impl(), x.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_ATAN2_TCC + diff --git a/flens/scalaroperations/double.h b/flens/scalaroperations/double.h new file mode 100644 index 00000000..b74e0802 --- /dev/null +++ b/flens/scalaroperations/double.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_DOUBLE_H +#define FLENS_SCALAROPERATIONS_DOUBLE_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpDouble {}; + +template +struct ElementType > +{ + typedef double Type; +}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Double(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_DOUBLE_H diff --git a/flens/scalaroperations/double.tcc b/flens/scalaroperations/double.tcc new file mode 100644 index 00000000..6bfbf9d9 --- /dev/null +++ b/flens/scalaroperations/double.tcc @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_DOUBLE_TCC +#define FLENS_SCALAROPERATIONS_DOUBLE_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return double(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +Double(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_DOUBLE_TCC diff --git a/flens/scalaroperations/exp.h b/flens/scalaroperations/exp.h new file mode 100644 index 00000000..fb1cd8a9 --- /dev/null +++ b/flens/scalaroperations/exp.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_EXP_H +#define FLENS_SCALAROPERATIONS_EXP_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpExp {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Exp(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_EXP_H diff --git a/flens/scalaroperations/exp.tcc b/flens/scalaroperations/exp.tcc new file mode 100644 index 00000000..f428ee9a --- /dev/null +++ b/flens/scalaroperations/exp.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_EXP_TCC +#define FLENS_SCALAROPERATIONS_EXP_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &expression) +{ + return exp(expression.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +Exp(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_EXP_TCC diff --git a/flens/scalaroperations/log.h b/flens/scalaroperations/log.h new file mode 100644 index 00000000..3f4bfe91 --- /dev/null +++ b/flens/scalaroperations/log.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_LOG_H +#define FLENS_SCALAROPERATIONS_LOG_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpLog {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Log(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_LOG_H diff --git a/flens/scalaroperations/log.tcc b/flens/scalaroperations/log.tcc new file mode 100644 index 00000000..9557369b --- /dev/null +++ b/flens/scalaroperations/log.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_LOG_TCC +#define FLENS_SCALAROPERATIONS_LOG_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return log(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +Log(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_LOG_TCC diff --git a/flens/scalaroperations/pow.h b/flens/scalaroperations/pow.h new file mode 100644 index 00000000..5df2b9ba --- /dev/null +++ b/flens/scalaroperations/pow.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_POW_H +#define FLENS_SCALAROPERATIONS_POW_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpPow {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Pow(const Scalar &y, const Scalar &x); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_POW_H diff --git a/flens/scalaroperations/pow.tcc b/flens/scalaroperations/pow.tcc new file mode 100644 index 00000000..2f3f6ef4 --- /dev/null +++ b/flens/scalaroperations/pow.tcc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_POW_TCC +#define FLENS_SCALAROPERATIONS_POW_TCC 1 + +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return pow(exp.left().value(), exp.right().value()); +} + +//-- operator overloading +template +const ScalarClosure +Pow(const Scalar &y, const Scalar &x) +{ + typedef ScalarClosure SC; + return SC(y.impl(), x.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_POW_TCC + diff --git a/flens/scalaroperations/scalaroperations.h b/flens/scalaroperations/scalaroperations.h index 10ffe13d..148f1ad2 100644 --- a/flens/scalaroperations/scalaroperations.h +++ b/flens/scalaroperations/scalaroperations.h @@ -34,14 +34,24 @@ #define FLENS_SCALAROPERATIONS_SCALAROPERATIONS_H 1 #include +#include +#include +#include +#include #include #include #include +#include +#include #include +#include #include #include +#include #include #include #include +#include +#include #endif // FLENS_SCALAROPERATIONS_SCALAROPERATIONS_H diff --git a/flens/scalaroperations/scalaroperations.tcc b/flens/scalaroperations/scalaroperations.tcc index 38994024..be358ced 100644 --- a/flens/scalaroperations/scalaroperations.tcc +++ b/flens/scalaroperations/scalaroperations.tcc @@ -34,14 +34,24 @@ #define FLENS_SCALAROPERATIONS_SCALAROPERATIONS_TCC 1 #include +#include +#include +#include +#include #include #include #include +#include +#include #include +#include #include #include #include +#include #include #include +#include +#include #endif // FLENS_SCALAROPERATIONS_SCALAROPERATIONS_TCC diff --git a/flens/scalaroperations/sqrt.h b/flens/scalaroperations/sqrt.h new file mode 100644 index 00000000..328231e5 --- /dev/null +++ b/flens/scalaroperations/sqrt.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_SQRT_H +#define FLENS_SCALAROPERATIONS_SQRT_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpSqrt {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Sqrt(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_SQRT_H diff --git a/flens/scalaroperations/sqrt.tcc b/flens/scalaroperations/sqrt.tcc new file mode 100644 index 00000000..c0d1ce8b --- /dev/null +++ b/flens/scalaroperations/sqrt.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_SQRT_TCC +#define FLENS_SCALAROPERATIONS_SQRT_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return sqrt(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +Sqrt(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_SQRT_TCC diff --git a/flens/scalaroperations/tan.h b/flens/scalaroperations/tan.h new file mode 100644 index 00000000..ef8cdb51 --- /dev/null +++ b/flens/scalaroperations/tan.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_TAN_H +#define FLENS_SCALAROPERATIONS_TAN_H 1 + +#include +#include +#include + +namespace flens { + +struct ScalarOpTan {}; + +template + const typename ScalarClosure::ElementType + evalScalarClosure(const ScalarClosure &exp); + +//-- operator overloading +template + const ScalarClosure + Tan(const Scalar &s); + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_TAN diff --git a/flens/scalaroperations/tan.tcc b/flens/scalaroperations/tan.tcc new file mode 100644 index 00000000..5c7e5b33 --- /dev/null +++ b/flens/scalaroperations/tan.tcc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Michael Lehn + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3) Neither the name of the FLENS development group nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FLENS_SCALAROPERATIONS_TAN_TCC +#define FLENS_SCALAROPERATIONS_TAN_TCC 1 + +#include +#include +#include +#include +#include + +namespace flens { + +template +const typename ScalarClosure::ElementType +evalScalarClosure(const ScalarClosure &exp) +{ + return tan(exp.left().value()); +} + +//-- operator overloading +template +const ScalarClosure +Tan(const Scalar &s) +{ + typedef ScalarClosure SC; + return SC(s.impl(), s.impl()); +} + +} // namespace flens + +#endif // FLENS_SCALAROPERATIONS_TAN_TCC