<commit_before>// @(#)root/smatrix:$Name:  $:$Id: HelperOps.h,v 1.7 2006/03/30 16:18:05 moneta Exp $
// Authors: <NAME>    2006  

#ifndef ROOT_Math_HelperOps_h 
#define ROOT_Math_HelperOps_h 1

// Include files

/** @class HelperOps HelperOps.h Math/HelperOps.h
 *  
 *
 *  @author <NAME>
 *  @date   2006-01-11
 *
 *  Specialised helper classes for binary operators =, +=, -=
 *  between SMatrices and Expressions with arbitrary representations.
 *  Specialisations at the moment only for Symmetric LHS and Generic RHS
 *  and used to throw static assert.
 */
#include "Math/StaticCheck.h"

namespace ROOT { 

  namespace Math {

    template <class T, unsigned int D1, unsigned int D2, class R>
    class SMatrix;

    template <class A, class T, unsigned int D1, unsigned int D2, class R>
    class Expr;

    //=========================================================================
    // for generic matrices 
    template <class T, 
              unsigned int D1, unsigned int D2, 
              class A, class R1, class R2>

    struct Assign
    {
      static void Evaluate(SMatrix<T,D1,D2,R1>& lhs,  const Expr<A,T,D1,D2,R2>& rhs) 
      {
	if (! rhs.IsInUse(lhs.begin() ) ) { 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<D2; ++j) { 
	      lhs.fRep[l] = rhs(i,j);
	      l++;
	    }
	}
	// lhs is in use in expression, need to create a temporary with the result
	else { 
	  T tmp[D1*D2]; 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<D2; ++j) { 
	      tmp[l] = rhs(i,j);
	      l++;
	    }
	  // copy now the temp object 
	  for(unsigned int i=0; i<D1*D2; ++i) lhs.fRep[i] = tmp[i];
	}

      }
	    
    };
    // specialization in case of symmetric expression to symmetric matrices :  
    template <class T, 
              unsigned int D1, unsigned int D2, 
              class A>

    struct Assign<T, D1, D2, A, MatRepSym<T,D1>, MatRepSym<T,D1> > 
    {
      static void Evaluate(SMatrix<T,D1,D2,MatRepSym<T,D1> >& lhs,  
                           const Expr<A,T,D1,D2,MatRepSym<T,D1> >& rhs) 
      {
	if (! rhs.IsInUse(lhs.begin() ) ) { 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i)
	    // storage of symmetric matrix is in lower block
	    for(unsigned int j=0; j<=i; ++j) { 
	      lhs.fRep.Array()[l] = rhs(i,j);
	      l++;
	    }
	}
	// create a temporary object to store result
	else { 
	  std::cout << "create temp obj since it is in use" << std::endl; 
	  T tmp[MatRepSym<T,D1>::kSize]; 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<=i; ++j) { 
	      tmp[l] = rhs(i,j);
	      l++;
	    }
	  // copy now the temp object 
	  for(unsigned int i=0; i<MatRepSym<T,D1>::kSize; ++i) lhs.fRep.Array()[i] = tmp[i];
	}
      }
    };
<commit_msg>remove  a  printout<commit_after>// @(#)root/smatrix:$Name:  $:$Id: HelperOps.h,v 1.8 2006/04/25 13:54:01 moneta Exp $
// Authors: <NAME>    2006  

#ifndef ROOT_Math_HelperOps_h 
#define ROOT_Math_HelperOps_h 1

// Include files

/** @class HelperOps HelperOps.h Math/HelperOps.h
 *  
 *
 *  @author <NAME>
 *  @date   2006-01-11
 *
 *  Specialised helper classes for binary operators =, +=, -=
 *  between SMatrices and Expressions with arbitrary representations.
 *  Specialisations at the moment only for Symmetric LHS and Generic RHS
 *  and used to throw static assert.
 */
#include "Math/StaticCheck.h"

namespace ROOT { 

  namespace Math {

    template <class T, unsigned int D1, unsigned int D2, class R>
    class SMatrix;

    template <class A, class T, unsigned int D1, unsigned int D2, class R>
    class Expr;

    //=========================================================================
    // for generic matrices 
    template <class T, 
              unsigned int D1, unsigned int D2, 
              class A, class R1, class R2>

    struct Assign
    {
      static void Evaluate(SMatrix<T,D1,D2,R1>& lhs,  const Expr<A,T,D1,D2,R2>& rhs) 
      {
	if (! rhs.IsInUse(lhs.begin() ) ) { 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<D2; ++j) { 
	      lhs.fRep[l] = rhs(i,j);
	      l++;
	    }
	}
	// lhs is in use in expression, need to create a temporary with the result
	else { 
	  T tmp[D1*D2]; 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<D2; ++j) { 
	      tmp[l] = rhs(i,j);
	      l++;
	    }
	  // copy now the temp object 
	  for(unsigned int i=0; i<D1*D2; ++i) lhs.fRep[i] = tmp[i];
	}

      }
	    
    };
    // specialization in case of symmetric expression to symmetric matrices :  
    template <class T, 
              unsigned int D1, unsigned int D2, 
              class A>

    struct Assign<T, D1, D2, A, MatRepSym<T,D1>, MatRepSym<T,D1> > 
    {
      static void Evaluate(SMatrix<T,D1,D2,MatRepSym<T,D1> >& lhs,  
                           const Expr<A,T,D1,D2,MatRepSym<T,D1> >& rhs) 
      {
	if (! rhs.IsInUse(lhs.begin() ) ) { 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i)
	    // storage of symmetric matrix is in lower block
	    for(unsigned int j=0; j<=i; ++j) { 
	      lhs.fRep.Array()[l] = rhs(i,j);
	      l++;
	    }
	}
	// create a temporary object to store result
	else { 
	  T tmp[MatRepSym<T,D1>::kSize]; 
	  unsigned int l = 0; 
	  for(unsigned int i=0; i<D1; ++i) 
	    for(unsigned int j=0; j<=i; ++j) { 
	      tmp[l] = rhs(i,j);
	      l++;
	    }
	  // copy now the temp object 
	  for(unsigned int i=0; i<MatRepSym<T,D1>::kSize; ++i) lhs.fRep.Array()[i] = tmp[i];
	}
      }
    };

{'fraction_non_alphanumeric': 0.16493553008595987, 'fraction_numerical': 0.029011461318051577, 'mean_word_length': 2.3869011522134627, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '789204', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2046, 'n_words': 578}