矩阵创建及运算
-
创建矩阵
m := [1,2,3,4]
create_matrix(2,2,[1.0,2.0,3.0,4.0],matrix_id)
create_matrix(2,2,[2,3,1,3],matrix_1_id) -
获取矩阵的值
-
获取单个值
get_value_matrix(matrix_id,1,0,value) -
获取所有值
get_full_matrix(matrix_id,values) -
设置矩阵元素值
set_value_matrix(matrix_1_id,1,1,-10)
*设置整个矩阵元素值
set_full_matrix(matrix_1_id,1)
-
获取矩阵大小
get_size_matrix(matrix_id,rows,cols) -
矩阵的逆
invert_matrix(matrix_id,‘general’,0,matrix_inv_id)
get_full_matrix(matrix_inv_id,values_inv) -
矩阵的范数
norm_matrix(matrix_id,‘2-norm’,value_norm)
m1 := [3.0,-3.0,2.0,-5.0,-3.0,2.0]
m2 := [3.0,-3.0,1.0,1.0,2.0,-1.0,-2.0,-1.0]
m3 := [1.0,0.5,2.0]
create_matrix(3,2,m1,matrix_a_id)
create_matrix(2,4,m2,matrix_b_id)
create_matrix(3,1,m3,matrix_c_id)
m3 := [1,2,3,4,5,6,7,8,9]
m4 := [1,2,3,1,2,3,1,2,3]
create_matrix(3,3,m3,matrix_3_id)
create_matrix(3,3,m4,matrix_4_id)
-
矩阵求和运算
-
按列求和
sum_matrix(matrix_3_id,‘columns’,matrix_sum_cols_id)
get_full_matrix(matrix_sum_cols_id,values_sum_cols) -
按行求和
sum_matrix(matrix_3_id,‘rows’,matrix_sum_rows_id)
get_full_matrix(matrix_sum_rows_id,values_sum_rows) -
整个矩阵求和
sum_matrix(matrix_3_id,‘full’,matrix_sum_full_id)
get_full_matrix(matrix_sum_full_id,values_sum_full) -
矩阵相加
add_matrix(matrix_3_id,matrix_4_id,matrix_add_id)
get_full_matrix(matrix_add_id,values_add) -
矩阵相减
sub_matrix(matrix_3_id,matrix_4_id,matrix_sub_id)
get_full_matrix(matrix_sub_id,values_sub) -
矩阵相乘
mult_matrix(matrix_a_id,matrix_b_id,‘AB’,matrix_mult_id)
get_full_matrix(matrix_mult_id,values_mult) -
矩阵与常量相乘
scale_matrix(matrix_3_id,1.5,matrix_scale_id)
get_full_matrix(matrix_scale_id,values_scale) -
矩阵相除
div_element_matrix(matrix_3_id,matrix_4_id,matrix_div_id)
get_full_matrix(matrix_div_id,values_matrix_div) -
矩阵 element-wise相乘
mult_element_matrix(matrix_3_id,matrix_4_id,mult_elems_id)
get_full_matrix(mult_elems_id,values_mult_elems)
-
获取对角矩阵
get_diagonal_matrix(matrix_3_id,0,vector_id)
get_full_matrix(vector_id,values_diagonal) -
获取矩阵均值
-
按列求均值
mean_matrix(matrix_3_id,‘columns’,matrix_mean_cols_id)
get_full_matrix(matrix_mean_cols_id,values_mean_cols) -
按行求均值
mean_matrix(matrix_3_id,‘rows’,matrix_mean_rows_id)
get_full_matrix(matrix_mean_rows_id,values_mean_rows) -
整个矩阵的均值
mean_matrix(matrix_3_id,‘full’,matrix_mean_full_id)
get_full_matrix(matrix_mean_full_id,values_mean_full) -
矩阵 element-wise 指数运算
pow_element_matrix(matrix_3_id,matrix_4_id,matrix_pow_elem_id)
get_full_matrix(matrix_pow_elem_id,values_pow_elem) -
矩阵指数运算
pow_scalar_element_matrix(matrix_3_id,3,matrix_pow_scale_id)
get_full_matrix(matrix_pow_scale_id,values_pow_scale) -
矩阵开方运算
sqrt_matrix(matrix_3_id,matrix_sqrt_id)
get_full_matrix(matrix_sqrt_id,values_sqrt) -
获取子矩阵
get_sub_matrix(matrix_3_id,0,0,2,2,matrix_submatrix_id)
get_full_matrix(matrix_submatrix_id,values_submatrix) -
获取矩阵最大值
-
按列获取
max_matrix(matrix_3_id,‘columns’,matrix_max_cols_id)
get_full_matrix(matrix_max_cols_id,values_max_cols) -
按行获取
max_matrix(matrix_3_id,‘rows’,matrix_max_rows_id)
get_full_matrix(matrix_max_rows_id,values_max_rows) -
整个矩阵最大值
max_matrix(matrix_3_id,‘full’,matrix_max_full_id)
get_full_matrix(matrix_max_full_id,values_max_full) -
获取矩阵最小值
-
按列获取
min_matrix(matrix_3_id,‘columns’,matrix_min_cols_id)
get_full_matrix(matrix_min_cols_id,values_min_cols) -
按行获取
min_matrix(matrix_3_id,‘rows’,matrix_min_rows_id)
get_full_matrix(matrix_min_rows_id,values_min_rows) -
整个矩阵最大值
min_matrix(matrix_3_id,‘full’,matrix_min_full_id)
get_full_matrix(matrix_min_full_id,values_min_full) -
矩阵线性求解
solve_matrix(matrix_3_id,‘general’,0,matrix_c_id,matrix_solve_result_id)
get_full_matrix(matrix_solve_result_id,values_matrix_solve) -
矩阵SVD求解
svd_matrix(matrix_3_id,‘full’,‘right’,matrix_u_id,matrix_s_id,matrix_v_id) -
get_full_matrix(matrix_u_id,values_u)
get_full_matrix(matrix_s_id,values_s)
get_full_matrix(matrix_v_id,values_v) -
矩阵转置
transpose_matrix(matrix_3_id,matrix_trans_id)
get_full_matrix(matrix_trans_id,values_trans) -
矩阵保存
write_matrix(matrix_3_id,‘binary’,’…/…/temp/matrix_3_id.dat’) -
读取矩阵
read_matrix(’…/…/temp/matrix_3_id.dat’,matrix_3_3_id)
get_full_matrix(matrix_3_3_id,values_read)