I would like to use a dotted version of a scalar function to calculate values for an entire matrix of inputs. The function is defined as follows:
function SpecificCharge(U, r, B)
( 2 * U ) / ( r^2 * B^2 )
end
and I would like to give it the following inputs:
const Us = [ # voltages U
228.9, 243, 257, 271, 285, 300
]
const Rs = [ # radii r
9 7 5.8 5 4.3 3.9;
10.5 8.1 6.7 5.7 4.9 4.5;
10.1 8.3 7.1 6.5 6 4.8;
11.1 9.0 7.2 6.5 5.6 5.1;
10.5 8.3 7.8 6.5 5.7 5.4;
11.9 8.9 8.0 7.4 6.2 5.5
]
const Bs = [ # flux densities B
0.0007332339999999999, 0.00089328, 0.0010421599999999999, 0.00119104, 0.00133992, 0.0014873112
]
# Calling the dotted version of the function
specific_charges = SpecificCharge.(Us, Rs, Bs)
The result should be a matrix of same dimensions as Rs, with each radius replaced by the corresponding specific charge, given by SpecificCharge. There is one flux density corresponding to each U--B pair, and the rows in Rs correspond to voltages U and columns to flux densities B.
The problem is, I'm not sure how broadcasting works in Julia. Does the function SpecificCharge. work as is, if I just transpose the vectors Us and Bs appropriately, or do I need to complicate the function itself to make this work?