<commit_before>/*M///////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015, <NAME>
// Copyright (c) 2015, ELM Library Project
// 3-clause BSD License
//
//M*/
/** @file template utility definitions that have to be defined inline
  */
#ifndef _ELM_CORE_MAT_UTILS_INL_H__
#define _ELM_CORE_MAT_UTILS_INL_H__

#include "elm/core/cv/typedefs_fwd.h"
#include "elm/core/defs.h"
#include "elm/core/exception.h"

namespace elm {

/**
 * @brief get first index of element with a specific value in matrix
 * Inspired by this Stack Overflow post: @see http://stackoverflow.com/questions/25835587/find-element-in-opencv-mat-efficiently
 *
 * @param[in] matrix to search in
 * @param[in] value to search for
 * @param[out] first index containing this value, only meaningful if found
 * @return true if sucessfully found, always flase for empty input.
 *
 * @throws ExceptionBadDims if no. of channels != 1, ExceptionTypeError for non-continuous matrix input.
 */
template <class T>
bool find_first_of(const cv::Mat &m, const T &value, int &index=elm::NA_IDX)
{
    if(!m.empty()) {

        if(m.channels() != 1) { ELM_THROW_BAD_DIMS("Only single-channel matrices supported for now."); }
        if(!m.isContinuous()) { ELM_THROW_TYPE_ERROR("Only continuous matrices supported for now."); }
    }
    else if(m.channels() > 1) { ELM_THROW_BAD_DIMS("Only single-channel matrices supported for now."); }

    for(int r=0; r < m.rows; r++) {

        const T* row = m.ptr<T>(r);
        const T* result = std::find(row, row + m.cols, value);
        if(result != row + m.cols) {<commit_msg>add extern templates<commit_after>/*M///////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015, <NAME>
// Copyright (c) 2015, ELM Library Project
// 3-clause BSD License
//
//M*/
/** @file template utility definitions that have to be defined inline
  */
#ifndef _ELM_CORE_MAT_UTILS_INL_H__
#define _ELM_CORE_MAT_UTILS_INL_H__

#include "elm/core/cv/typedefs_fwd.h"
#include "elm/core/defs.h"
#include "elm/core/exception.h"

extern template class cv::Mat_<float>;
extern template class cv::Mat_<int>;

namespace elm {

/**
 * @brief get first index of element with a specific value in matrix
 * Inspired by this Stack Overflow post: @see http://stackoverflow.com/questions/25835587/find-element-in-opencv-mat-efficiently
 *
 * @param[in] matrix to search in
 * @param[in] value to search for
 * @param[out] first index containing this value, only meaningful if found
 * @return true if sucessfully found, always flase for empty input.
 *
 * @throws ExceptionBadDims if no. of channels != 1, ExceptionTypeError for non-continuous matrix input.
 */
template <class T>
bool find_first_of(const cv::Mat &m, const T &value, int &index=elm::NA_IDX)
{
    if(!m.empty()) {

        if(m.channels() != 1) { ELM_THROW_BAD_DIMS("Only single-channel matrices supported for now."); }
        if(!m.isContinuous()) { ELM_THROW_TYPE_ERROR("Only continuous matrices supported for now."); }
    }
    else if(m.channels() > 1) { ELM_THROW_BAD_DIMS("Only single-channel matrices supported for now."); }

    for(int r=0; r < m.rows; r++) {

        const T* row = m.ptr<T>(r);
        const T* result = std::find(row, row + m.cols, value);
        if(result != row + m.cols) {
{'fraction_non_alphanumeric': 0.18002392344497609, 'fraction_numerical': 0.012559808612440191, 'mean_word_length': 3.0107913669064748, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6941828', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1063, 'n_words': 320}