CI / Lint e auditorias (push) Successful in 1m10s
CI / Trivy (dependências e segredos) (push) Successful in 12s
CI / Imagem Docker (linux/arm64) (push) Successful in 2m39s
Release / Plano (reaproveitar a imagem?) (push) Successful in 6s
Release / ci (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Successful in 18s
Release / Cria a release no Gitea (push) Successful in 5s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
38 lines
870 B
C
38 lines
870 B
C
#include <stdio.h>
|
|
#include "esp_dsp.h"
|
|
|
|
#define N 8 // 向量长度
|
|
|
|
void app_main(void)
|
|
{
|
|
// 输入向量(信号示例)
|
|
float x[N] = {1.0, -2.0, 3.0, -4.0, 2.5, -1.5, 0.0, 4.5};
|
|
float y[N]; // 输出向量
|
|
|
|
// 初始化 ESP-DSP
|
|
esp_err_t ret = dsps_fft2r_init_fc32(NULL, CONFIG_DSP_MAX_FFT_SIZE);
|
|
if (ret != ESP_OK) {
|
|
printf("Failed to initialize ESP-DSP!\n");
|
|
return;
|
|
}
|
|
|
|
printf("Input signal:\n");
|
|
for (int i = 0; i < N; i++) {
|
|
printf("%f ", x[i]);
|
|
}
|
|
printf("\n");
|
|
|
|
// 计算每个值的平方
|
|
dsps_mulc_f32(x, y, N, 1.0f);
|
|
dsps_mul_f32(y, y, y, N, 1, 1, 1);
|
|
|
|
// 对所有平方值求和
|
|
float soma = 0;
|
|
dsps_sum_f32(y, N, &soma, 1);
|
|
|
|
// 计算幅值(平方和的平方根)
|
|
float magnitude = sqrtf(soma);
|
|
|
|
printf("Vector magnitude: %f\n", magnitude);
|
|
}
|