#pragma once

#include "./core/omp_config.h"

#include "./utils/vector.h"
#include "./utils/matrix.h"

#include "./numerics/matmax.h"
#include "./numerics/matsubtract.h"
#include "./numerics/matexp.h"
#include "./numerics/matdiv.h"


namespace neural_networks{

	template <typename T>
	struct Activation_Softmax{

			utils::Matrix<T> exp_values;
			utils::Matrix<T> probabilities;
			utils::Matrix<T> outputs;

	        void forward(const utils::Matrix<T>& inputs){
	
	        	// Get unnormalized probabilities
			    exp_values = numerics::matexp(numerics::matsubtract(inputs, numerics::matmax(inputs, "rows"), "col"));

			    // Normalize them for each sample
			    probabilities = numerics::matdiv(exp_values, numerics::matsum(exp_values, "col"), "col");


			    outputs = probabilities;

	        }

	};



} // end namespace neural_networks