本文整理汇总了C#中Vector.SetToProduct方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.SetToProduct方法的具体用法?C# Vector.SetToProduct怎么用?C# Vector.SetToProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.SetToProduct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvaluateX
/// <summary>
/// Evaluates the kernel for a single vector (which is used for both slots)
/// </summary>
/// <param name="x">Vector</param>
/// <param name="xDeriv">Derivative of the kernel value with respect to x</param>
/// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
/// <returns></returns>
public override double EvaluateX(Vector x, ref Vector xDeriv, ref Vector logThetaDeriv)
{
int numInputs = variances.Count;
Vector dvec = Vector.Zero(numInputs);
dvec.SetToProduct(variances, x);
double result = x.Inner(dvec);
if (((object)logThetaDeriv) != null)
{
logThetaDeriv.SetToProduct(x, dvec);
}
if (((object)xDeriv) != null)
{
xDeriv.SetToProduct(dvec, 2.0);
}
return result;
}
示例2: EvaluateX1X2
/// <summary>
/// Evaluates the kernel for a pair of vectors
/// </summary>
/// <param name="x1">First vector</param>
/// <param name="x2">Second vector</param>
/// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
/// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
/// <returns></returns>
public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
{
if (Object.ReferenceEquals(x1,x2))
{
return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
}
else
{
int numInputs = variances.Count;
Vector dvec = Vector.Zero(numInputs);
dvec.SetToProduct(variances, x2);
double result = x1.Inner(dvec);
if (((object)logThetaDeriv) != null)
{
logThetaDeriv.SetToProduct(x1, dvec);
}
if (((object)x1Deriv) != null)
{
x1Deriv.SetTo(dvec);
}
return result;
}
}
示例3: EvaluateX1X2
/// <summary>
/// Evaluates the kernel for a pair of vectors
/// </summary>
/// <param name="x1">First vector</param>
/// <param name="x2">Second vector</param>
/// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
/// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
/// <returns></returns>
public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
{
if (object.ReferenceEquals(x1, x2)) {
return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
} else {
Vector dvec = Vector.Zero(x1.Count);
dvec.SetToDifference(x1, x2);
double d = lenMult * dvec.Inner(dvec);
double de = Math.Exp(d);
double result = signalVar * de;
if (((object)logThetaDeriv) != null) {
logThetaDeriv[0] = -2.0 * result * d;
logThetaDeriv[1] = 2.0 * signalVar * de;
}
if (((object)x1Deriv) != null) {
x1Deriv.SetToProduct(dvec, result * 2.0 * lenMult);
}
return result;
}
}
示例4: LogAverageFactor
/// <summary>
/// Evidence message for EP
/// </summary>
/// <param name="prob">Constant value for 'prob'.</param>
/// <param name="mean">Constant value for 'mean'.</param>
/// <param name="totalCount">Constant value for 'totalCount'.</param>
/// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
/// <remarks><para>
/// The formula for the result is <c>log(factor(prob,mean,totalCount))</c>.
/// </para></remarks>
public static double LogAverageFactor(Vector prob, Vector mean, double totalCount)
{
var temp = mean.Clone();
mean.SetToProduct(mean, totalCount);
var d = new Dirichlet(temp);
return d.GetLogProb(prob);
}
示例5: EvaluateX1X2
/// <summary>
/// Evaluates the kernel for a pair of vectors
/// </summary>
/// <param name="x1">First vector</param>
/// <param name="x2">Second vector</param>
/// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
/// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
/// <returns></returns>
public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
{
if (Object.ReferenceEquals(x1,x2))
{
return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
}
else
{
int numInputs = invLength.Count;
Vector dvec = Vector.Zero(numInputs);
dvec.SetToDifference(x1, x2);
// Factor in the inverse length
dvec.SetToProduct(dvec, invLength);
double d = -0.5 * dvec.Inner(dvec);
double de = Math.Exp(d);
double result = signalVar * de;
if (((object)logThetaDeriv) != null)
{
for (int i = 0; i < numInputs; i++)
{
logThetaDeriv[i] = result * dvec[i] * dvec[i];
}
logThetaDeriv[numInputs] = 2.0 * signalVar * de;
}
if (((object)x1Deriv) != null)
{
x1Deriv.SetToProduct(dvec, -result);
x1Deriv.SetToProduct(x1Deriv, invLength);
}
return result;
}
}
示例6: AverageColor
public static Vector AverageColor(Bitmap bitmap)
{
Vector sum = new Vector(2);
for (int x = 0; x < bitmap.Width; x++) {
for (int y = 0; y < bitmap.Height; y++) {
Color pixel = bitmap.GetPixel(x, y);
// we encode the Hue angle as a 2D vector, scaled by saturation and brightness.
double hue = pixel.GetHue()/360;
double saturation = pixel.GetSaturation();
double brightness = pixel.GetBrightness();
double vx = brightness*saturation*Math.Cos(hue*2*Math.PI);
double vy = brightness*saturation*Math.Sin(hue*2*Math.PI);
sum[0] += vx;
sum[1] += vy;
//sum[1] += pixel.GetSaturation();
//sum[2] += pixel.GetBrightness();
}
}
sum.SetToProduct(sum, 1.0 / ((double)bitmap.Width * bitmap.Height));
return sum;
}