/*****************************************************************
 * matrixChain.cpp
 *****************************************************************/

#include "chain.h"

/*****************************************************************
 * call the constructor from chain
 *****************************************************************/
matrixChain::matrixChain(link *linkList, int linkNum) :
    chain(linkList, linkNum) {
    // table size bigger than linkNum for matrices
    initTable(linkNum + 1);
}

/*****************************************************************
 * componentWeight: return the number of multiplications required when
 * M1 has linkList[i].x rows, linkList[j].x rows
 * and M2 has linkList[k].x (== linkList[k-1].y) rows.
 *****************************************************************/
double matrixChain::componentWeight (int i, int j, int k) {
    return linkList[i].x * linkList[j].x * linkList[k-1].y;
}

/*****************************************************************
 * matrixChain::minPartition acts as a trivial front-end to
 * chain::minPartition.
 ****************************************************************/
componentNode *matrixChain::minPartition(int linkNum) {
    return chain::minPartition(0, linkNum);
}

