Matic Network是一种基于侧链的公共区块链扩展解决方案。它的基础是Plasma框架的调整实施。Matic提供了可扩展性,同时以安全和分散的方式确保了卓越的用户体验。它在KovanTestnet上为Etalum提供了一个工作实现。Matic打算在未来支持其他区块链,这将使它能够提供互操作性功能,同时为现有的公共区块链提供可伸缩性系统开发180.3831.9724。
#include<iostream>
using namespace std;
#define N 10
class Mat
{
public:
int m = 1, n = 1; //行数和列数
double mat[N][N] = { 0 }; //矩阵开始的元素
Mat() {}
Mat(int mm, int nn)
{
m = mm; n = nn;
}
void create();//创建矩阵
void Print();//输出矩阵
bool add(const Mat a, const Mat b);//加法
bool sub(const Mat a, const Mat b);//减法
bool mul(const Mat a, const Mat b);//乘法
};
void Mat::create()
{
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> mat[i][j];
}
}
}
void Mat::Print()
{
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
cout << mat[i][j] << "\t";
}
cout << endl;
}
}
bool Mat::add(const Mat a, const Mat b)
{
if (a.m != b.m || a.n != b.n)
{
cout << "行列数不一致,不能相加" << endl;
return false; //无法相加,返回false
}
m = a.m; n = a.n;
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
mat[i][j] = a.mat[i][j] + b.mat[i][j];
}
}
return true;
}
bool Mat::sub(const Mat a, const Mat b)
{
if (a.m != b.m || a.n != b.n)
{
cout << "行列数不一致,不能相减" << endl;
return false; //无法相减,返回false
}
m = a.m; n = a.n;
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
mat[i][j] = a.mat[i][j] - b.mat[i][j];
}
}
return true;
}
bool Mat::mul(const Mat a, const Mat b)
{
if (a.n != b.m)//乘法要求左边矩阵列数和右边矩阵行数相等
{
cout << "行列数不符合乘法要求,不能相乘" << endl;
return false; //无法相乘,返回false
}
m = a.m; n = b.n; //相乘后矩阵是a.m行b.n列
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
mat[i][j] = 0;
for (int k = 1; k <= a.n; k++)
{
mat[i][j] += a.mat[i][k] * b.mat[k][j];
}
}
}
return true;
}
int main()
{
Mat a(3, 5), b(5, 2);
cout << "请输入 " << a.m << "*" << a.n << " 的矩阵:" << endl;
a.create();
cout << "请输入 " << b.m << "*" << b.n << " 的矩阵:" << endl;
b.create();
Mat c;
if (c.add(a, b)) c.Print(); //求和
Mat d;
if (d.sub(a, b)) d.Print(); //求差
Mat e;
if (e.mul(a, b)) e.Print(); //求积
return 0;
}
Matic计划在未来支持其他区块链,这将使其能够提供互操作性功能,同时为现有公共区块链提供可扩展性。
使用侧链进行可扩展,安全和即时的区块链交易,同时使用Plasma框架和去中心化网络的权益证明(PoS)验证器确保资产安全。