Changeset 14000


Ignore:
Timestamp:
Nov 8, 2019 12:47:46 PM (11 days ago)
Author:
Christian Andersson
Message:

Minor cleanup. Related to ticket:5868

Location:
branches/dev-cw-2658/RuntimeLibrary/src/jmi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-2658/RuntimeLibrary/src/jmi/jmi_linear_algebra.c

    r9915 r14000  
    2222#include <math.h>
    2323#include <stdlib.h>
     24
     25/* Computes y = x.*y (element-wise multiplication)*/
     26void jmi_linear_algebra_dxemy(jmi_real_t* x, jmi_real_t* y, jmi_int_t N) {
     27    jmi_int_t i;
     28   
     29    for (i = 0; i < N; i++) {
     30        y[i] = y[i]*x[i];
     31    }
     32}
    2433
    2534/* Computes a = sqrt( sum( (wi*xi)^2) / N) */
     
    117126/* Find the index of the max absolute value */
    118127jmi_int_t jmi_linear_algebra_idamax(jmi_real_t *x, jmi_int_t N) {
    119     int i = 0;
    120     int j=0;
     128    int i = 0, j = 0;
     129
    121130    jmi_real_t cmax = JMI_ABS(x[i]);
    122     for(i=1; i<N; i++) {
    123         if(JMI_ABS(x[i])>cmax) {
     131    jmi_real_t tmp;
     132    for(i=1; i < N; i++) {
     133        tmp = JMI_ABS(x[i]);
     134        if(tmp > cmax) {
     135            cmax = tmp;
    124136            j=i;
    125137        }
  • branches/dev-cw-2658/RuntimeLibrary/src/jmi/jmi_linear_algebra.h

    r9911 r14000  
    150150jmi_real_t jmi_linear_algebra_dlange(jmi_real_t* A, jmi_int_t N, char norm_type);
    151151
     152/**
     153 * \brief Computes the element-wise multiplication of two vectors
     154 *
     155 * @param jmi_real_t* A real pointer to the x vector.
     156 * @param jmi_real_t* A real pointer to the y vector (result saved in this vector).
     157 * @param jmi_int_t The number of elements.
     158 */
     159void jmi_linear_algebra_dxemy(jmi_real_t* x, jmi_real_t* y, jmi_int_t N);
    152160
    153161#endif
  • branches/dev-cw-2658/RuntimeLibrary/src/jmi/jmi_realtime_solver.c

    r11712 r14000  
    2525#include <string.h>
    2626
    27 #define JMI_REALTIME_SOLVER_MAX_ITER 20
     27#define JMI_REALTIME_SOLVER_MAX_ITER 10
    2828#define JMI_REALTIME_UPDATE_JACOBIAN_ITER 10
    2929#define JMI_REALTIME_PROGRESS_LOG_LEVEL 4
    30 
     30#define JMI_REALTIME_INFO_LOG_LEVEL 5
     31#define JMI_REALTIME_DEBUG_LOG_LEVEL 6
    3132
    3233static void progress_reset_char_log(jmi_block_solver_t* block) {
     
    176177   
    177178    /* Open log and log the Jacobian.*/
    178     if((block->callbacks->log_options.log_level >= 5)) {
     179    if((block->callbacks->log_options.log_level >= JMI_REALTIME_INFO_LOG_LEVEL)) {
    179180        destnode = jmi_log_enter_fmt(block->log, logInfo, "RealtimeSolver",
    180181                                     "Realtime solver invoked for <block:%s>", block->label);
    181182        jmi_log_reals(block->log, destnode, logInfo, "ivs", block->x, block->n);
    182         if((block->callbacks->log_options.log_level >= 6)) {
     183        if((block->callbacks->log_options.log_level >= JMI_REALTIME_DEBUG_LOG_LEVEL)) {
    183184            jmi_log_real_matrix(block->log, destnode, logInfo, "LU", solver->factorization, block->n, block->n);
    184185        }
     
    208209        /* Logging compute the id of the largest (weighted) step */
    209210        if (block->callbacks->log_options.log_level >= JMI_REALTIME_PROGRESS_LOG_LEVEL) {
    210             jmi_linear_algebra_ddot(solver->weights, block->res, block->n);
     211            jmi_linear_algebra_dxemy(solver->weights, block->res, block->n);
    211212            solver->last_wrms_id = jmi_linear_algebra_idamax(block->res, block->n);
    212213        }
     
    231232   
    232233    /* Close log.*/
    233     if((block->callbacks->log_options.log_level >= 5)) {
     234    if((block->callbacks->log_options.log_level >= JMI_REALTIME_INFO_LOG_LEVEL)) {
    234235        jmi_log_reals(block->log, destnode, logInfo, "ivs", block->x, block->n);
    235236        jmi_log_reals(block->log, destnode, logInfo, "residual", block->res, block->n);
Note: See TracChangeset for help on using the changeset viewer.