void knapsack(int n)
{
    for(int i = 0; i <= totalWeight; i++)
    {
        v[0][i] = 0;
    }

    for(int i = 1; i <= n; i++)
    {
        v[i][0] = 0;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= totalWeight; j++)
        {
            if(w[i] <= j)
            {
                v[i][j] = getMaxVal(i, j);
            }

            else
            {
                v[i][j] = v[i-1][j];
            }
        }
    }
}
Example #2
0
void ArrayTest::get_minmax_bounds( int i, int /*j*/, int type, Scalar& low, Scalar& high )
{
    double l, u;
    int depth = CV_MAT_DEPTH(type);

    if( i == MASK )
    {
        l = -2;
        u = 2;
    }
    else if( depth < CV_32S )
    {
        l = getMinVal(type);
        u = getMaxVal(type);
    }
    else
    {
        u = depth == CV_32S ? 1000000 : 1000.;
        l = -u;
    }

    low = Scalar::all(l);
    high = Scalar::all(u);
}
	float getMaxVal(const Mat& mat) {
		return getMaxVal(mat.depth());
	}