Multivariate S2Fun edit page

Structural conventions of the input and output of multivariate S2FunHarmonic

In this part we deal with multivariate functions of the form

f:S2Rn.

  • the structure of the nodes is always interpreted as a column vector
  • the node index is the first dimension
  • the dimensions of the S2FunHarmonic itself is counted from the second dimension

For example we got four nodes v1,v2,v3 and v4 and six functions f1,f2,f3,f4,f5 and f6, which we want to store in a 3x2 array, then the following scheme applies to function evaluations:

F(:,:,1)=(f1(v1)f2(v1)f3(v1)f1(v2)f2(v2)f3(v2)f1(v3)f2(v3)f3(v3)f1(v4)f2(v4)f3(v4))andF(:,:,2)=(f4(v1)f5(v1)f6(v1)f4(v2)f5(v2)f6(v2)f4(v3)f5(v3)f6(v3)f4(v4)f5(v4)f6(v4)).

For the intern Fourier-coefficient matrix the first dimension is reserved for the Fourier-coefficients of a single function; the dimension of the functions itself begins again with the second dimension.

If ˆf1,ˆf2,ˆf3,ˆf4,ˆf5 and ˆf6 would be the column vectors of the Fourier-coefficients of the functions above, internally they would be stored in ˆF as follows. ˆF(:,:,1)=(ˆf1ˆf2ˆf3)andˆF(:,:,2)=(ˆf4ˆf5ˆf6).

Defining a multivariate S2FunHarmonic

Definition via function values

At first we need some vertices

nodes = equispacedS2Grid('points', 1e5);
nodes = nodes(:);

Next we define function values for the vertices

y = [S2Fun.smiley(nodes), (nodes.x.*nodes.y).^(1/4)];

Now the actual command to get a 2x1 sF1 of type S2FunHarmonic

sF1 = S2FunHarmonic.interpolate(nodes, y)
sF1 = S2FunHarmonic (y↑→x)
  size: 2 x 1
  bandwidth: 224

Definition via function handle

If we have a function handle for the function we could create a S2FunHarmonic via quadrature. At first let us define a function handle which takes vector3d as an argument and returns double:

f = @(v) [exp(v.x+v.y+v.z)+50*(v.y-cos(pi/3)).^3.*(v.y-cos(pi/3) > 0), v.x, v.y, v.z];

Next we convert this function handle into a S2FunHarmonic of size 4×1

sF2 = S2FunHarmonic(f, 'bandwidth', 50)
sF2 = S2FunHarmonic (y↑→x)
  size: 4 x 1
  bandwidth: 50
  isReal: true

Definition via Fourier-coefficients

If we already know the Fourier-coefficients, we can simply hand them in the format above to the constructor of S2FunHarmonic.

sF3 = S2FunHarmonic(eye(9))
sF3 = S2FunHarmonic (y↑→x)
  size: 9 x 1
  bandwidth: 2
  • This command stores the nine first spherical harmonics in sF3

Operations which differ from an univariate S2FunHarmonic

Some default matrix and vector operations

You can concatenate and refer to functions as MATLAB does with vectors and matrices

sF4 = [sF1; sF2];
sF4(2:3);

You can conjugate the Fourier-coefficients and transpose/ctranspose the multivariate S2FunHarmonic.

conj(sF1);
sF1.';
sF1';

Some other operations

length(sF1);
size(sF2);
sF3 = reshape(sF3, 3, []);

sum and mean

If we do not specify further options to sum or mean they give we the integral or the mean value back for each function. You could also calculate the conventional sum or the mean value over a dimension of a multivariate S2FunHarmonic.

sum(sF1, 1);
sum(sF3, 2);

min/max

If the min or max command gets a multivariate S2FunHarmonic the pointwise minimum or maximum can calculated along the dimension specified as third argument.

% this computes the minimum along the first dimension
min(sF3,[],1);

Remark on the matrix product

At this point the matrix product is implemented per element and not as the usual matrix product.

Visualization of multivariate S2FunHarmonic

The same plot commands as for univariate S2FunHarmonic work on multivariate as well. The difference is that, now, each component is plotted next to one another.