<commit_before>/*
 * malgorithm.hpp
 *
 *  Created on: Mar 1, 2015
 *      Author: hugo
 */

#ifndef MFLASH_CPP_CORE_MALGORITHM_HPP_
#define MFLASH_CPP_CORE_MALGORITHM_HPP_

#include "type.hpp"
#include "matrixworker.hpp"

namespace mflash{


  template <class VSource, class VDestination, class E>
	class MAlgorithm{
		public:

	    /**
	     * Called before start the processing of each column to initialize the values of the output or the accumulators.
	     */
			virtual void initialize(MatrixWorker<E> &worker, Element<VDestination> &destination) = 0;

			/**
       * Called for each edge to transfers data since source to destination. On the destination is accumulated temporal state for the destination vertex,
       * if it is used multi-thread each thread maintain its own accumulator.
       */
			virtual void gather(MatrixWorker<E> &worker, Element<VSource> &source, Element<VDestination> &destination, E &edge_data) = 0;

			/**
			 * Called to combine accumulators between threads.
			 */
			virtual void sum(Element<VDestination> &accumulator1, Element<VDestination> &accumulator2, Element<VDestination> &out_accumulator) = 0;

			/**
			 * Called after combine the accumulators for each vertex to update the vertex value.
			 */
			virtual void apply(MatrixWorker<E> &worker, Element<VDestination> &out_element) = 0;

			/**
       *  Check is the initialized method is executed. By default is true.
       */
			virtual bool is_initialized(){
			  return true;
			}

			/**
       *  Check is the apply method is executed. By default is true.
       */
			virtual bool is_applied(){
			  return true;
			}

			/**
			 * Called before an iteration starts.
			 */
			virtual void before_iteration(int iteration, MatrixWorker<E> &worker){

			}

			/**
			 * Called after an iteration has finished.
			 */
      virtual void after_iteration(int iteration, MatrixWorker<E> &worker){
      }

	};

}


#endif /* MFLASH_CPP_CORE_MALGORITHM_HPP_ */
<commit_msg>Adding method to initialize source values<commit_after>/*
 * malgorithm.hpp
 *
 *  Created on: Mar 1, 2015
 *      Author: hugo
 */

#ifndef MFLASH_CPP_CORE_MALGORITHM_HPP_
#define MFLASH_CPP_CORE_MALGORITHM_HPP_

#include "type.hpp"
#include "matrixworker.hpp"

namespace mflash{


  template <class VSource, class VDestination, class E>
	class MAlgorithm{
		public:

      /**
       * Called before start the processing of each edge to initialize the values to transfer using edges.
       *
       */
      virtual void initialize_source(MatrixWorker<E> &worker, Element<VSource> &destination) {}

	    /**
	     * Called before start the processing of each each to initialize the values of the output or the accumulators.
	     */
			virtual void initialize(MatrixWorker<E> &worker, Element<VDestination> &destination) = 0;

			/**
       * Called for each edge to transfers data since source to destination. On the destination is accumulated temporal state for the destination vertex,
       * if it is used multi-thread each thread maintain its own accumulator.
       */
			virtual void gather(MatrixWorker<E> &worker, Element<VSource> &source, Element<VDestination> &destination, E &edge_data) = 0;

			/**
			 * Called to combine accumulators between threads.
			 */
			virtual void sum(Element<VDestination> &accumulator1, Element<VDestination> &accumulator2, Element<VDestination> &out_accumulator) = 0;

			/**
			 * Called after combine the accumulators for each vertex to update the vertex value.
			 */
			virtual void apply(MatrixWorker<E> &worker, Element<VDestination> &out_element) = 0;


			/**
       *  Check is the initialized method is executed. By default is false and MFlash uses the current value stored.
       *  When it is true, it is executed before iteration starts and after before_iteration method.
       *
       */
      virtual bool is_source_initialized(){
        return false;
      }

			/**
       *  Check is the initialized method is executed. By default is true.
       */
			virtual bool is_initialized(){
			  return true;
			}

			/**
       *  Check is the apply method is executed. By default is true.
       */
			virtual bool is_applied(){
			  return true;
			}

			/**
			 * Called before an iteration starts.
			 */
			virtual void before_iteration(int iteration, MatrixWorker<E> &worker){

			}

			/**
			 * Called after an iteration has finished.
			 */
      virtual void after_iteration(int iteration, MatrixWorker<E> &worker){
      }

      virtual ~MAlgorithm(){}
	};

}


#endif /* MFLASH_CPP_CORE_MALGORITHM_HPP_ */

{'fraction_non_alphanumeric': 0.08887425938117183, 'fraction_numerical': 0.0048277375466315555, 'mean_word_length': 3.0300618921308575, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '7205679', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1270, 'n_words': 446}