I would like to know if there is a fast way to create the following matrix (note that the matrix is defined with arbitrary precision):
ny=500;
nyt=ny-100;
$MinPrecision=100;
t1 = AbsoluteTime[];
If[ny == nyt,
Miy = IdentityMatrix[ny + 1]
,
ct[j_] := If[j == 0 || j == nyt, 2, 1];
Cm = Table[
N[2/(nyt ct[j] ct[i]) Cos[(i j \[Pi])/nyt], $MinPrecision], {i, 0,
nyt}, {j, 0, nyt}];
Cm = If[ny - nyt == 0, Cm,
Flatten[Join[{Cm, ConstantArray[0, {ny - nyt, nyt + 1}]}], 1]];
CIm = Table[
N[Cos[(i j \[Pi])/ny], $MinPrecision], {i, 0, ny}, {j, 0, ny}];
Miy = CIm.Cm;
Clear[ct, Cm, CIm];
Print[" Delta t= ", AbsoluteTime[] - t1];
Clear[t1]
];
This matrix is needed to interpolate (via matrix multiplication) a function f(x) defined on a Chebyshev grid with nyt points, into a Chebyshev grid with ny points, with nyt>ny.
cccontains the coefficients of the Chebyshev expansion of the interpolating polynomial at the Chebyshev nodes. – Michael E2 Apr 07 '20 at 22:29fas a function, but in my case I only knowfat some number of pointsnyt<ny. – user12588 Apr 08 '20 at 00:53