pose_estimation/gramian/functions.py
def gramian_measures(gram):
    '''
    compute various measures of the gramian

    input:
    gram: an array of Gramians, of dimension (n_rows, n_cols, n_gramians)

    output:
    a dictionary containing the trace, determinant, minimum eigenvalue of each
    gramian, as well as the normalized values and normalized inverses of all of
    these measures
    '''

    # arrays to be filled
    n_gram = gram.shape[2]
    trace = np.full(n_gram, np.nan)
    det = np.full(n_gram, np.nan) # determinant
    min_eval = np.full(n_gram, np.nan) # minimum eigenvalue
    cond_num = np.full(n_gram, np.nan) # condition number
    trace_inv = np.full(n_gram, np.nan)
    det_inv = np.full(n_gram, np.nan) # determinant
    min_eval_inv = np.full(n_gram, np.nan) # minimum eigenvalue
    cond_num_inv = np.full(n_gram, np.nan) # condition number

    # loop over all gramians
    for i in range(n_gram):
        gram_i = gram[:, :, i]
        gram_inv_i = np.linalg.inv(gram_i)

        # measures
        trace[i] = np.trace(gram_i) 
        det[i] = np.linalg.det(gram_i)
        val_i, vec_i = np.linalg.eig(gram_i)
        min_eval[i] = np.amin(val_i)
        cond_num[i] = np.amax(val_i)/np.amin(val_i)
        
        # measures of inverse (i.e. unobservability indices)
        trace_inv[i] = np.trace(gram_inv_i) 
        det_inv[i] = np.linalg.det(gram_inv_i)
        val_i, vec_i = np.linalg.eig(gram_inv_i)
        min_eval_inv[i] = np.amin(val_i)
        cond_num_inv[i] = np.amax(val_i)/np.amin(val_i)

    # normalized measures
    det_nrm = tm.normalize_array(det)
    trace_nrm = tm.normalize_array(trace)
    min_eval_nrm = tm.normalize_array(min_eval)

    # inverse normalized measures
    trace_inv_nrm = tm.normalize_array(trace_inv)
    det_inv_nrm = tm.normalize_array(det_inv)
    min_eval_inv_nrm = tm.normalize_array(min_eval_inv)

    # gramian measures as a dictionary
    gram_dict = {'det': det,
                 'trace': trace,
                 'min_eval': min_eval,
                 'cond_num': cond_num,
                 'det_nrm': det_nrm,
                 'trace_nrm': trace_nrm,
                 'min_eval_nrm': min_eval_nrm,
                 'det_inv_nrm': det_inv_nrm,
                 'trace_inv_nrm': trace_inv_nrm,
                 'min_eval_inv_nrm': min_eval_inv_nrm}

    return gram_dict

    compute various measures of the gramian

    input:
    gram: an array of Gramians, of dimension (n_rows, n_cols, n_gramians)

    output:
    a dictionary containing the trace, determinant, minimum eigenvalue of each
    gramian, as well as the normalized values and normalized inverses of all of
    these measures
    
compute various measures of the gramian
input:
gram: an array of Gramians, of dimension (n_rows, n_cols, n_gramians)

a dictionary containing the trace, determinant, minimum eigenvalue of each
gramian, as well as the normalized values and normalized inverses of all of
these measures
compute various measures of the gramian input : gram : an array of Gramians of dimension ( n_rows n_cols n_gramians ) a dictionary containing the trace determinant minimum eigenvalue of each gramian as well as the normalized values and normalized inverses of all of these measures
def gramian_measures(gram):
    n_gram = gram.shape[2]
    trace = np.full(n_gram, np.nan)
    det = np.full(n_gram, np.nan) 
    min_eval = np.full(n_gram, np.nan) 
    cond_num = np.full(n_gram, np.nan) 
    trace_inv = np.full(n_gram, np.nan)
    det_inv = np.full(n_gram, np.nan) 
    min_eval_inv = np.full(n_gram, np.nan) 
    cond_num_inv = np.full(n_gram, np.nan) 
    for i in range(n_gram):
        gram_i = gram[:, :, i]
        gram_inv_i = np.linalg.inv(gram_i)
        trace[i] = np.trace(gram_i) 
        det[i] = np.linalg.det(gram_i)
        val_i, vec_i = np.linalg.eig(gram_i)
        min_eval[i] = np.amin(val_i)
        cond_num[i] = np.amax(val_i)/np.amin(val_i)
         of inverse (i.e. unobservability indices)
        trace_inv[i] = np.trace(gram_inv_i) 
        det_inv[i] = np.linalg.det(gram_inv_i)
        val_i, vec_i = np.linalg.eig(gram_inv_i)
        min_eval_inv[i] = np.amin(val_i)
        cond_num_inv[i] = np.amax(val_i)/np.amin(val_i)
    det_nrm = tm.normalize_array(det)
    trace_nrm = tm.normalize_array(trace)
    min_eval_nrm = tm.normalize_array(min_eval)
    trace_inv_nrm = tm.normalize_array(trace_inv)
    det_inv_nrm = tm.normalize_array(det_inv)
    min_eval_inv_nrm = tm.normalize_array(min_eval_inv)
    gram_dict = {'det': det,
                 'trace': trace,
                 'min_eval': min_eval,
                 'cond_num': cond_num,
                 'det_nrm': det_nrm,
                 'trace_nrm': trace_nrm,
                 'min_eval_nrm': min_eval_nrm,
                 'det_inv_nrm': det_inv_nrm,
                 'trace_inv_nrm': trace_inv_nrm,
                 'min_eval_inv_nrm': min_eval_inv_nrm}
    return gram_dict
def gramian_measures ( gram ) : n_gram = gram . shape [ 2 ] trace = np . full ( n_gram , np . nan ) det = np . full ( n_gram , np . nan ) min_eval = np . full ( n_gram , np . nan ) cond_num = np . full ( n_gram , np . nan ) trace_inv = np . full ( n_gram , np . nan ) det_inv = np . full ( n_gram , np . nan ) min_eval_inv = np . full ( n_gram , np . nan ) cond_num_inv = np . full ( n_gram , np . nan ) for i in range ( n_gram ) : gram_i = gram [ : , : , i ] gram_inv_i = np . linalg . inv ( gram_i ) trace [ i ] = np . trace ( gram_i ) det [ i ] = np . linalg . det ( gram_i ) val_i , vec_i = np . linalg . eig ( gram_i ) min_eval [ i ] = np . amin ( val_i ) cond_num [ i ] = np . amax ( val_i ) / np . amin ( val_i ) trace_inv [ i ] = np . trace ( gram_inv_i ) det_inv [ i ] = np . linalg . det ( gram_inv_i ) val_i , vec_i = np . linalg . eig ( gram_inv_i ) min_eval_inv [ i ] = np . amin ( val_i ) cond_num_inv [ i ] = np . amax ( val_i ) / np . amin ( val_i ) det_nrm = tm . normalize_array ( det ) trace_nrm = tm . normalize_array ( trace ) min_eval_nrm = tm . normalize_array ( min_eval ) trace_inv_nrm = tm . normalize_array ( trace_inv ) det_inv_nrm = tm . normalize_array ( det_inv ) min_eval_inv_nrm = tm . normalize_array ( min_eval_inv ) gram_dict = { 'det' : det , 'trace' : trace , 'min_eval' : min_eval , 'cond_num' : cond_num , 'det_nrm' : det_nrm , 'trace_nrm' : trace_nrm , 'min_eval_nrm' : min_eval_nrm , 'det_inv_nrm' : det_inv_nrm , 'trace_inv_nrm' : trace_inv_nrm , 'min_eval_inv_nrm' : min_eval_inv_nrm } return gram_dict
compute various measures of the gramian
input:
gram: an array of Gramians, of dimension (n_rows, n_cols, n_gramians)
compute various measures of the gramian input : gram : an array of Gramians of dimension ( n_rows n_cols n_gramians )
'''
    compute various measures of the gramian

    input:
    gram: an array of Gramians, of dimension (n_rows, n_cols, n_gramians)

    output:
    a dictionary containing the trace, determinant, minimum eigenvalue of each
    gramian, as well as the normalized values and normalized inverses of all of
    these measures
    ''' # arrays to be filled # determinant # minimum eigenvalue # condition number # determinant # minimum eigenvalue # condition number # loop over all gramians # measures # measures of inverse (i.e. unobservability indices) # normalized measures # inverse normalized measures # gramian measures as a dictionary
gram