The following collapse C functions take two input sequences, left and right, and produce the result sequence of type double where the computed scalar result is the first element.
The two input sequences must be of the same type. If the two input sequences are of different lengths the operation will be performed on only the number of elements in the shorter of the two sequences.
The function signatures are of the following form:
MCO_RET mco_seq_operation_TYPE(mco_seq_iterator_h result, mco_seq_iterator_h left, mco_seq_iterator_h right);where TYPE is one of the types listed in the Analytics Functions page and operation is one of the following:
mco_seq_wsum_TYPE() The first element of the result sequence is the weighted sum of the two sequences: left and right mco_seq_wavg_TYPE() The first element of the result sequence is the weighted average of the two sequences: left and right mco_seq_cov_TYPE() The first element of the result sequence is the covariance of the two sequences: left and right mco_seq_corr_TYPE() The first element of the result sequence is the correlation of the two sequences: left and right Example
Following is an example code snippet demonstrating a collapse function:
{ mco_trans_h trans; mco_cursor_t quote_cursor; Quote quote; mco_seq_iterator_t high_iterator, low_iterator, result_iterator; MCO_RET rc; ... for (rc = mco_cursor_first(trans, "e_cursor); rc != MCO_S_CURSOR_END; rc = mco_cursor_next(trans, "e_cursor)) { Quote_from_cursor(trans, "e_cursor, "e); Quote_high_iterator("e, &high_iterator); Quote_low_iterator("e, &low_iterator); ... rc = mco_seq_corr_float(&result_iterator, &high_iterator, &low_iterator); ... } ... }