add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(matrix)

View File

@@ -0,0 +1,54 @@
# Matrix Operations Example
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example demonstrates how to use Mat class functionality from esp-dsp library. Example does the following steps:
1. Initialize a matrix A and matirx x
2. Calculate matrix b: b = A*x
3. Find roots x1_: A*x1_ = b, with different methods
4. Print result
## How to use example
### Hardware required
This example does not require any special hardware, and can be run on any common development board.
### Configure the project
Under Component Config ---> DSP Library ---> DSP Optimization, it's possible to choose either the optimized or ANSI implementation, to compare them.
### Build and flash
Build the project and flash it to the board, then run monitor tool to view serial output (replace PORT with serial port name):
```
idf.py -p PORT flash monitor
```
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Example output
Here is an typical example console output.
```
I (215) main: Start Example.
I (215) main: Original vector x:
0
1
2
I (215) main: Solve result:
0
1
2
I (215) main: Roots result:
0
1
2
I (215) main: End Example.
```

View File

@@ -0,0 +1 @@
idf_component_register(SRCS "dspm_matrix_main.cpp")

View File

@@ -0,0 +1,62 @@
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dsp_platform.h"
#include "esp_log.h"
#include "esp_dsp.h"
static const char *TAG = "main";
// This example shows how to use Mat class from esp-dsp library.
//
// First we create matix A and x, and then calculating matrix b as result
// A*x = b
// Then we can find x as roots of matrices X and b
//
extern "C" void app_main();
void app_main()
{
ESP_LOGI(TAG, "Start Example.");
int M = 3;
int N = 3;
dspm::Mat A(M, N);
dspm::Mat x(N, 1);
for (int m = 0 ; m < M ; m++) {
for (int n = 0 ; n < N ; n++) {
A(m, n) = N * m + n;
}
x(m, 0) = m;
}
A(0, 0) = 10;
A(0, 1) = 11;
dspm::Mat b = A * x;
// Gaussian method
dspm::Mat x1_ = dspm::Mat::solve(A, b);
// Non Gaussian method
dspm::Mat x2_ = dspm::Mat::roots(A, b);
ESP_LOGI(TAG, "Original vector x:");
std::cout << x;
ESP_LOGI(TAG, "Solve result:");
std::cout << x1_;
ESP_LOGI(TAG, "Roots result:");
std::cout << x2_;
ESP_LOGI(TAG, "End Example.");
}

View File

@@ -0,0 +1,4 @@
dependencies:
espressif/esp-dsp:
override_path: "../../../"
version: "*"

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_OFFSET=0x9000