<commit_before><commit_msg>Added ScalarOperation<commit_after>package es.usc.citius.lab.hipster.function.impl;

import es.usc.citius.lab.hipster.function.ScalarFunction;

/**
 * A scalar operation is an implementation of {@link ScalarFunction} that
 * also defines:
 * <ul>
 * 		<li>identity element (A*i = A)</li>
 * </ul>
 * 
 * @author <NAME> <<EMAIL>>
 *
 * @param <E> operator class
 */
public class ScalarOperation<E extends Comparable<E>> implements ScalarFunction<E> {

	private double identityElem;
	private ScalarFunction<E> op;

	/**
	 * Unique constructor for {@link ScalarOperation}, that takes the {@link ScalarFunction}
	 * applied and the identity element.
	 * 
	 * @param operation
	 * @param identityElem
	 */
	public ScalarOperation(ScalarFunction<E> operation, double identityElem) {
		this.identityElem = identityElem;
		this.op = operation;
	}

	@Override
	public E scale(E a, double b) {
		return this.op.scale(a, b);
	}
	
	public double getIdentityElem() {
		return identityElem;
	}
	
	/**
	 * Builds the scaling operation for Doubles, that is the multiplying
	 * operation for the factor.
	 * 
	 * @return {@link ScalarOperation} for Double 
	 */
	public static ScalarOperation<Double> doubleMultiplicationOp() {
		return new ScalarOperation<Double>(new ScalarFunction<Double>() {

			@Override
			public Double scale(Double a, double b) {
				return a * b;
			}

		}, 1d);
	}
	
}
{'fraction_non_alphanumeric': 0.11743772241992882, 'fraction_numerical': 0.0007117437722419929, 'mean_word_length': 4.00355871886121, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5014358', 'n_tokens_mistral': 469, 'n_tokens_neox': 424, 'n_words': 124}