<commit_before>//=======================================================================
// Copyright (c) 2014-2015 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "../../traits_lite.hpp"

namespace etl {

namespace impl {

namespace standard {

template<typename A, typename B, typename C>
static void mm_mul(A&& a, B&& b, C&& c){
    c = 0;

    for(std::size_t i = 0; i < rows(a); i++){
        for(std::size_t k = 0; k < columns(a); k++){
            for(std::size_t j = 0; j < columns(b); j++){
                c(i,j) += a(i,k) * b(k,j);
            }
        }
    }
}

template<typename A, typename B, typename C>
static void vm_mul(A&& a, B&& b, C&& c){
    c = 0;

    for(std::size_t k = 0; k < etl::dim<0>(a); k++){
        for(std::size_t j = 0; j < columns(b); j++){
            c(j) += a(k) * b(k,j);
        }
    }
}

template<typename A, typename B, typename C>
static void mv_mul(A&& a, B&& b, C&& c){
    c = 0;

    for(std::size_t i = 0; i < rows(a); i++){
        for(std::size_t k = 0; k < columns(a); k++){
            c(i) += a(i,k) * b(k);
        }
    }
}

} //end of namespace standard

} //end of namespace impl<commit_msg>Optimize for column major<commit_after>//=======================================================================
// Copyright (c) 2014-2015 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#pragma once

#include "../../traits_lite.hpp"

namespace etl {

namespace impl {

namespace standard {

template<typename A, typename B, typename C>
static void mm_mul(A&& a, B&& b, C&& c){
    bool row_major = decay_traits<A>::storage_order == order::RowMajor;

    c = 0;

    if(row_major){
        for(std::size_t i = 0; i < rows(a); i++){
            for(std::size_t k = 0; k < columns(a); k++){
                for(std::size_t j = 0; j < columns(b); j++){
                    c(i,j) += a(i,k) * b(k,j);
                }
            }
        }
    } else {
        for(std::size_t j = 0; j < columns(b); j++){
            for(std::size_t k = 0; k < columns(a); k++){
                for(std::size_t i = 0; i < rows(a); i++){
                    c(i,j) += a(i,k) * b(k,j);
                }
            }
        }
    }
}

template<typename A, typename B, typename C>
static void vm_mul(A&& a, B&& b, C&& c){
    bool row_major = decay_traits<B>::storage_order == order::RowMajor;

    c = 0;

    if(row_major){
        for(std::size_t k = 0; k < etl::dim<0>(a); k++){
            for(std::size_t j = 0; j < columns(b); j++){
                c(j) += a(k) * b(k,j);
            }
        }
    } else {
        for(std::size_t j = 0; j < columns(b); j++){
            for(std::size_t k = 0; k < etl::dim<0>(a); k++){
                c(j) += a(k) * b(k,j);
            }
        }
    }
}

template<typename A, typename B, typename C>
static void mv_mul(A&& a, B&& b, C&& c){
    bool row_major = decay_traits<A>::storage_order == order::RowMajor;

    c = 0;

    if(row_major){
        for(std::size_t i = 0; i < rows(a); i++){
            for(std::size_t k = 0; k < columns(a); k++){
                c(i) += a(i,k) * b(k);
            }
        }
    } else {
        for(std::size_t k = 0; k < columns(a); k++){
            for(std::size_t i = 0; i < rows(a); i++){
                c(i) += a(i,k) * b(k);
            }
        }
    }
}

} //end of namespace standard

} //end of namespace impl
{'fraction_non_alphanumeric': 0.2558641143165274, 'fraction_numerical': 0.01240226476139121, 'mean_word_length': 2.1387478849407784, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 17, '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': '1336407', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1275, 'n_words': 347}