% ----------------- % Copyright © 2019 ACK Cyfronet AGH, Poland. % % This work was partially funded by EPOS Project funded in frame of PL-POIR4.2 % ----------------- function [out_vector]=basicVectorOperations(in_vector, numerator, denominator, k, operation_type) %% BASICVECTOROPERATION Tool for performing simple operations on a given number vector % % Input Arguments: % % in_vector - input vector % % numerator, denominator, k - scalar number - operands of the operation to be performed on the vector % % operation_type - name of operation to be performed on vector % % Output Arguments: % % out_vector - output vector that is the result of the operation % switch operation_type case {'^', 'POWER'} if(isempty(denominator)) denominator = 1; end out_vector = in_vector .^ (numerator/denominator); case {'FILL_FROM_INDEX'} if(k>length(in_vector)) error(['Index out of bound. Vector length is: %d, but index is %d'], length(in_vector), k); else out_vector = [in_vector(1:k) zeros(1,length(in_vector)-k)]; end case {'FILL_TO_INDEX'} if(k>length(in_vector)) error(['Index out of bound. Vector length is: %d, but index is %d'], length(in_vector), k); else out_vector = [zeros(1,k) in_vector(k+1:length(in_vector))]; end otherwise error(['unsupported operation: "' operation_type '"']); end end