sumabs2(A,dims)

sumabs2(A, dims)

Sum squared absolute values of elements of an array over the given dimensions.

Examples

  1. Calculate the sum of squared absolute values of an array:

    julia> arr = [1, -2, 3, -4, 5];
    julia> sumabs2(arr)
    55

    This example calculates the sum of squared absolute values of all elements in the array arr.

  2. Calculate the sum of squared absolute values of a range:

    julia> rng = -5:5;
    julia> sumabs2(rng)
    110

    It calculates the sum of squared absolute values of all elements in the range -5:5.

  3. Calculate the sum of squared absolute values of a vector of complex numbers:
    julia> complex_nums = [1+2im, -3+4im, 5-6im];
    julia> sumabs2(complex_nums)
    147.0

    It computes the sum of squared absolute values of all elements in the vector of complex numbers.

Common mistake example:

julia> my_tuple = (1, 2, 3);
julia> sumabs2(my_tuple)
ERROR: MethodError: no method matching sumabs2(::Tuple{Int64, Int64, Int64})

In this example, the sumabs2 function cannot be applied to a tuple. It only works on collections like arrays, ranges, or vectors. Make sure to provide a valid collection as an argument to sumabs2.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: