inner_product.fp

来自「PDE simulator on GPU.」· FP 代码 · 共 30 行

FP
30
字号
!!FP1.0
#here compute the inner product of vector x and vector y which in 2d Textures
#add all elements together into ONE element
DECLARE TexOffset0 ={0.5,0,0,0};
DECLARE TexOffset1 ={0,0.5,0,0};
DECLARE TexOffset2 ={0.5,0.5,0,0};

#multiply xi and yi
TEX R0, f[TEX0], TEX0, 2D;
TEX R1, f[TEX1], TEX1, 2D;
MUL R0, R0, R1;

#offset the texture coordinates of the multiply product of x and y 
ADD R1, R0, TexOffset0;
ADD R2, R0, TexOffset1;
ADD R3, R0, TexOffset2;

TEX R0, R0, TEX0, 2D;
TEX R1, R1, TEX0, 2D;
TEX R2, R2, TEX0, 2D;
TEX R3, R3, TEX0, 2D;

#sum together
ADD R0, R0, R1;
ADD R0, R2, R0;
ADD R0, R3, R0;

MOV o[COLR], R0;
END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?