zoukankan      html  css  js  c++  java
  • (3) esp8266 官方库文件,没有求逆函数

    下载库文件

    #include <MatrixMath.h>
    
    
    #define N  (2)
    
    mtx_type A[N][N];
    mtx_type B[N][N];
    mtx_type C[N][N];
    mtx_type v[N];      // This is a row vector
    mtx_type w[N];
    
    mtx_type maxVal = 10;  // maxValimum random matrix entry range
    
    void setup()
    {
    	Serial.begin(9600);
    
    	// Initialize matrices
    	for (int i = 0; i < N; i++)
    	{
    		v[i] = i + 1;                  // vector of sequential numbers
    		for (int j = 0; j < N; j++)
    		{
    			A[i][j] = random(maxVal) - maxVal / 2.0f; // A is random
    			if (i == j)
    			{
    				B[i][j] = 1.0f;                  // B is identity
    			}
    			else
    			{
    				B[i][j] = 0.0f;
    			}
    		}
    	}
    
    }
    
    void loop()
    {
    
    	Matrix.Multiply((mtx_type*)A, (mtx_type*)B, N, N, N, (mtx_type*)C);
    
    	Serial.println("
    After multiplying C = A*B:");
    	Matrix.Print((mtx_type*)A, N, N, "A");
    
    	Matrix.Print((mtx_type*)B, N, N, "B");
    	Matrix.Print((mtx_type*)C, N, N, "C");
    	Matrix.Print((mtx_type*)v, N, 1, "v");
    
    	Matrix.Add((mtx_type*) B, (mtx_type*) C, N, N, (mtx_type*) C);
    	Serial.println("
    C = B+C (addition in-place)");
    	Matrix.Print((mtx_type*)C, N, N, "C");
    	Matrix.Print((mtx_type*)B, N, N, "B");
    
    	Matrix.Copy((mtx_type*)A, N, N, (mtx_type*)B);
    	Serial.println("
    Copied A to B:");
    	Matrix.Print((mtx_type*)B, N, N, "B");
    
    	Matrix.Invert((mtx_type*)A, N);
    	Serial.println("
    Inverted A:");
    	Matrix.Print((mtx_type*)A, N, N, "A");
    
    	Matrix.Multiply((mtx_type*)A, (mtx_type*)B, N, N, N, (mtx_type*)C);
    	Serial.println("
    C = A*B");
    	Matrix.Print((mtx_type*)C, N, N, "C");
    
    	// Because the library uses pointers and DIY indexing,
    	// a 1D vector can be smoothly handled as either a row or col vector
    	// depending on the dimensions we specify when calling a function
    	Matrix.Multiply((mtx_type*)C, (mtx_type*)v, N, N, 1, (mtx_type*)w);
    	Serial.println("
     C*v = w:");
    	Matrix.Print((mtx_type*)v, N, 1, "v");
    	Matrix.Print((mtx_type*)w, N, 1, "w");
    
    	while(1);
    }
    

      

  • 相关阅读:
    C# 读写 ini 配置文件
    [转]VB 读写ini 配置文件
    js实现隔行变色-------Day40
    Camel Games借助AWS在爆发式增长中提供优质游戏体验
    深入浅出--UNIX多进程编程之fork()函数
    【玩转微信公众平台之八】 演示样例代码分析
    jQuery 选择具有特殊属性的元素
    下载超星或读秀图书时,怎么搞定完整书签?
    意外的php之学习笔记
    POJ 1182 (经典食物链 /并查集扩展)
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/10800337.html
Copyright © 2011-2022 走看看