public static int[] calcMixedBitDepths(int[] ntdepth, int ttype, int[] tdepth)
{
if (ntdepth.Length < 3 && ttype != NONE)
{
throw new System.ArgumentException();
}
if (tdepth == null)
{
tdepth = new int[ntdepth.Length];
}
switch (ttype)
{
case NONE:
Array.Copy(ntdepth, 0, tdepth, 0, ntdepth.Length);
break;
case FORW_RCT:
if (ntdepth.Length > 3)
{
Array.Copy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3);
}
// The formulas are:
// tdepth[0] = ceil(log2(2^(ntdepth[0])+2^ntdepth[1]+
// 2^(ntdepth[2])))-2+1
// tdepth[1] = ceil(log2(2^(ntdepth[1])+2^(ntdepth[2])-1))+1
// tdepth[2] = ceil(log2(2^(ntdepth[0])+2^(ntdepth[1])-1))+1
// The MathUtil.log2(x) function calculates floor(log2(x)), so we
// use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x))
// for any x>=1, x integer.
tdepth[0] = MathUtil.log2((1 << ntdepth[0]) + (2 << ntdepth[1]) + (1 << ntdepth[2]) - 1) - 2 + 1;
tdepth[1] = MathUtil.log2((1 << ntdepth[2]) + (1 << ntdepth[1]) - 1) + 1;
tdepth[2] = MathUtil.log2((1 << ntdepth[0]) + (1 << ntdepth[1]) - 1) + 1;
break;
case FORW_ICT:
if (ntdepth.Length > 3)
{
Array.Copy(ntdepth, 3, tdepth, 3, ntdepth.Length - 3);
}
// The MathUtil.log2(x) function calculates floor(log2(x)), so we
// use 'MathUtil.log2(2*x-1)+1', which calculates ceil(log2(x))
// for any x>=1, x integer.
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
tdepth[0] = MathUtil.log2((int) System.Math.Floor((1 << ntdepth[0]) * 0.299072 + (1 << ntdepth[1]) * 0.586914 + (1 << ntdepth[2]) * 0.114014) - 1) + 1;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
tdepth[1] = MathUtil.log2((int) System.Math.Floor((1 << ntdepth[0]) * 0.168701 + (1 << ntdepth[1]) * 0.331299 + (1 << ntdepth[2]) * 0.5) - 1) + 1;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
tdepth[2] = MathUtil.log2((int) System.Math.Floor((1 << ntdepth[0]) * 0.5 + (1 << ntdepth[1]) * 0.418701 + (1 << ntdepth[2]) * 0.081299) - 1) + 1;
break;
}
return tdepth;
}