Weather casting with Machine Learning (SVM and SRNN).

Dependencies:   EthernetInterface GraphicHandler NTPClient SRNN SVM SensorModule mbed-rtos mbed

ml_util/ml_util.cpp

Committer:
yukari_hinata
Date:
2015-02-22
Revision:
6:29d393d430d0
Parent:
2:20ecfe6edd71

File content as of revision 6:29d393d430d0:

#include "ml_util.hpp"

void multiply_mat_vec(float*  mat, // m * n 行列
                      float*  vec, // n * 1 ベクトル
                      float*  result, // m * 1 計算結果ベクトル
                      int     m,   // m
                      int     n)   // n
{
    register float mat_sum;
    for (int mat_mul_i = 0; mat_mul_i < m; mat_mul_i++) {
        mat_sum = 0;
        /*
        printf("result[%d] : %p, MATRIX_AT(mat,n,mat_mul_i,mat_mul_j) : %p, vec[0] : %p", mat_mul_i, 
                &(result[mat_mul_i]), &(MATRIX_AT(mat,n,mat_mul_i,0)), vec);
                */
        for (int mat_mul_j = 0; mat_mul_j < n; mat_mul_j++) {
            mat_sum += MATRIX_AT(mat,n,mat_mul_i,mat_mul_j) * vec[mat_mul_j];
        }
        result[mat_mul_i] = mat_sum;
    }
}