переведи на Java procedure FFT(var D: TComplex; const TableExp: TComplex); var…
- User
переведи на Java procedure FFT(var D: TComplex; const TableExp: TComplex); var I,J,NChIndex,TableExpIndex,Len,StartIndex,LenBlock,HalfBlock:Integer; TempBn:TComplex; begin Len := Length(D); LenBlock := 2; HalfBlock := 1; While LenBlock <= Len do //Пробегаем блоки от 2 до Len begin I:=0; NChIndex := HalfBlock; StartIndex:= 0; TableExpIndex := HalfBlock; Dec(HalfBlock); while I<Len do //Пробегаем блоки begin for J:=0 to HalfBlock do //Работаем в конкретном блоке begin //(Бабочка БПФ) TempBn :=D[NChIndex]*TableExp[TableExpIndex+J]; D[NChIndex] :=D[StartIndex]-TempBn; D[StartIndex] :=D[StartIndex]+TempBn; Inc(NChIndex); Inc(StartIndex); end; I := I + LenBlock; NChIndex := I + HalfBlock+1; StartIndex:= I; end; HalfBlock := LenBlock; LenBlock := LenBlock shl 1; end; end;
- Assistant
public void FFT(TComplex[] D, TComplex[] TableExp) { int I, J, NChIndex, TableExpIndex, Len, StartIndex, LenBlock, HalfBlock; TComplex TempBn; Len = D.length; LenBlock = 2; HalfBlock = 1; while (LenBlock <= Len) { I = 0; NChIndex = HalfBlock; StartIndex = 0; TableExpIndex = HalfBlock; HalfBlock--; while (I < Len) { for (J = 0; J <= HalfBlock; J++) { TempBn = D[NChIndex].multiply(TableExp[TableExpIndex + J]); D[NChIndex] = D[StartIndex].subtract(TempBn); D[StartIndex] = D[StartIndex].add(TempBn); NChIndex++; StartIndex++; } I = I + LenBlock; NChIndex = I + HalfBlock + 1; StartIndex = I; } HalfBlock = LenBlock; LenBlock = LenBlock << 1; } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.