~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/Eigen3/Eigen/src/Core/products/CoeffBasedProduct.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5
5
// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
6
6
//
7
 
// Eigen is free software; you can redistribute it and/or
8
 
// modify it under the terms of the GNU Lesser General Public
9
 
// License as published by the Free Software Foundation; either
10
 
// version 3 of the License, or (at your option) any later version.
11
 
//
12
 
// Alternatively, you can redistribute it and/or
13
 
// modify it under the terms of the GNU General Public License as
14
 
// published by the Free Software Foundation; either version 2 of
15
 
// the License, or (at your option) any later version.
16
 
//
17
 
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
18
 
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
20
 
// GNU General Public License for more details.
21
 
//
22
 
// You should have received a copy of the GNU Lesser General Public
23
 
// License and a copy of the GNU General Public License along with
24
 
// Eigen. If not, see <http://www.gnu.org/licenses/>.
 
7
// This Source Code Form is subject to the terms of the Mozilla
 
8
// Public License v. 2.0. If a copy of the MPL was not distributed
 
9
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
25
10
 
26
11
#ifndef EIGEN_COEFFBASED_PRODUCT_H
27
12
#define EIGEN_COEFFBASED_PRODUCT_H
28
13
 
 
14
namespace Eigen { 
 
15
 
29
16
namespace internal {
30
17
 
31
18
/*********************************************************************************
224
211
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this).diagonal(index); }
225
212
 
226
213
  protected:
227
 
    const LhsNested m_lhs;
228
 
    const RhsNested m_rhs;
 
214
    typename internal::add_const_on_value_type<LhsNested>::type m_lhs;
 
215
    typename internal::add_const_on_value_type<RhsNested>::type m_rhs;
229
216
 
230
217
    mutable PlainObject m_result;
231
218
};
252
239
struct product_coeff_impl<DefaultTraversal, UnrollingIndex, Lhs, Rhs, RetScalar>
253
240
{
254
241
  typedef typename Lhs::Index Index;
255
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
 
242
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
256
243
  {
257
244
    product_coeff_impl<DefaultTraversal, UnrollingIndex-1, Lhs, Rhs, RetScalar>::run(row, col, lhs, rhs, res);
258
245
    res += lhs.coeff(row, UnrollingIndex) * rhs.coeff(UnrollingIndex, col);
263
250
struct product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar>
264
251
{
265
252
  typedef typename Lhs::Index Index;
266
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
 
253
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
267
254
  {
268
255
    res = lhs.coeff(row, 0) * rhs.coeff(0, col);
269
256
  }
273
260
struct product_coeff_impl<DefaultTraversal, Dynamic, Lhs, Rhs, RetScalar>
274
261
{
275
262
  typedef typename Lhs::Index Index;
276
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar& res)
 
263
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar& res)
277
264
  {
278
265
    eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
279
266
    res = lhs.coeff(row, 0) * rhs.coeff(0, col);
291
278
{
292
279
  typedef typename Lhs::Index Index;
293
280
  enum { PacketSize = packet_traits<typename Lhs::Scalar>::size };
294
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
 
281
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
295
282
  {
296
283
    product_coeff_vectorized_unroller<UnrollingIndex-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres);
297
284
    pres = padd(pres, pmul( lhs.template packet<Aligned>(row, UnrollingIndex) , rhs.template packet<Aligned>(UnrollingIndex, col) ));
302
289
struct product_coeff_vectorized_unroller<0, Lhs, Rhs, Packet>
303
290
{
304
291
  typedef typename Lhs::Index Index;
305
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
 
292
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
306
293
  {
307
294
    pres = pmul(lhs.template packet<Aligned>(row, 0) , rhs.template packet<Aligned>(0, col));
308
295
  }
314
301
  typedef typename Lhs::PacketScalar Packet;
315
302
  typedef typename Lhs::Index Index;
316
303
  enum { PacketSize = packet_traits<typename Lhs::Scalar>::size };
317
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
 
304
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
318
305
  {
319
306
    Packet pres;
320
307
    product_coeff_vectorized_unroller<UnrollingIndex+1-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres);
327
314
struct product_coeff_vectorized_dyn_selector
328
315
{
329
316
  typedef typename Lhs::Index Index;
330
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
 
317
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
331
318
  {
332
319
    res = lhs.row(row).transpose().cwiseProduct(rhs.col(col)).sum();
333
320
  }
339
326
struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,RhsCols>
340
327
{
341
328
  typedef typename Lhs::Index Index;
342
 
  EIGEN_STRONG_INLINE static void run(Index /*row*/, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
 
329
  static EIGEN_STRONG_INLINE void run(Index /*row*/, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
343
330
  {
344
331
    res = lhs.transpose().cwiseProduct(rhs.col(col)).sum();
345
332
  }
349
336
struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,LhsRows,1>
350
337
{
351
338
  typedef typename Lhs::Index Index;
352
 
  EIGEN_STRONG_INLINE static void run(Index row, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
 
339
  static EIGEN_STRONG_INLINE void run(Index row, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
353
340
  {
354
341
    res = lhs.row(row).transpose().cwiseProduct(rhs).sum();
355
342
  }
359
346
struct product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,1>
360
347
{
361
348
  typedef typename Lhs::Index Index;
362
 
  EIGEN_STRONG_INLINE static void run(Index /*row*/, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
 
349
  static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
363
350
  {
364
351
    res = lhs.transpose().cwiseProduct(rhs).sum();
365
352
  }
369
356
struct product_coeff_impl<InnerVectorizedTraversal, Dynamic, Lhs, Rhs, RetScalar>
370
357
{
371
358
  typedef typename Lhs::Index Index;
372
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
 
359
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
373
360
  {
374
361
    product_coeff_vectorized_dyn_selector<Lhs,Rhs>::run(row, col, lhs, rhs, res);
375
362
  }
383
370
struct product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>
384
371
{
385
372
  typedef typename Lhs::Index Index;
386
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
 
373
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
387
374
  {
388
375
    product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res);
389
376
    res =  pmadd(pset1<Packet>(lhs.coeff(row, UnrollingIndex)), rhs.template packet<LoadMode>(UnrollingIndex, col), res);
394
381
struct product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>
395
382
{
396
383
  typedef typename Lhs::Index Index;
397
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
 
384
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
398
385
  {
399
386
    product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res);
400
387
    res =  pmadd(lhs.template packet<LoadMode>(row, UnrollingIndex), pset1<Packet>(rhs.coeff(UnrollingIndex, col)), res);
405
392
struct product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode>
406
393
{
407
394
  typedef typename Lhs::Index Index;
408
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
 
395
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
409
396
  {
410
397
    res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col));
411
398
  }
415
402
struct product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode>
416
403
{
417
404
  typedef typename Lhs::Index Index;
418
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
 
405
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
419
406
  {
420
407
    res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col)));
421
408
  }
425
412
struct product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>
426
413
{
427
414
  typedef typename Lhs::Index Index;
428
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
 
415
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
429
416
  {
430
417
    eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
431
418
    res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col));
438
425
struct product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>
439
426
{
440
427
  typedef typename Lhs::Index Index;
441
 
  EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
 
428
  static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
442
429
  {
443
430
    eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
444
431
    res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col)));
449
436
 
450
437
} // end namespace internal
451
438
 
 
439
} // end namespace Eigen
 
440
 
452
441
#endif // EIGEN_COEFFBASED_PRODUCT_H