covariance

Obtain vertices of the ellipse on an ellipse covariance plot (created by `car::ellipse`)

一曲冷凌霜 提交于 2019-12-19 02:59:10
问题 By following this post one can draw an ellipse with a given shape matrix (A): library(car) A <- matrix(c(20.43, -8.59,-8.59, 24.03), nrow = 2) ellipse(c(-0.05, 0.09), shape=A, radius=1.44, col="red", lty=2, asp = 1) Now how to get the major/minor (pair of intersect points of the major/minor axis and the ellipse) vertices of this ellipse? 回答1: For practical purposes, @Tensibai's answer is probably good enough. Just use a large enough value for the segments argument so that the points give a

Covariance Matrix of an Ellipse

怎甘沉沦 提交于 2019-12-19 02:37:16
问题 I've been trying to solve a problem. I'm surprised I haven't been able to find anything really useful on the net. I know that from the eigenvalues of the covariance matrix of the ellipse, the major and the minor axis of the ellipse can be computed. As the following: a1 = 2*sqrt(e1) a2 = 2*sqrt(e2) where a1 and a2 are the major and minor axis, e1 and e2 are the eigenvalues of covariance matrix. My question is: given an edge points (xi,yi) of the image ellipse, how it possible to find the 2×2

Delegate Covariance Confusion Conundrum!

自作多情 提交于 2019-12-18 15:52:08
问题 Why does this not work? Do I not understand delegate covariance correctly? public delegate void MyDelegate(object obj) public class MyClass { public MyClass() { //Error: Expected method with 'void MyDelegate(object)' signature _delegate = MyMethod; } private MyDelegate _delegate; public void MyMethod(SomeObject obj) {} } 回答1: Correct - you don't understand covariance correctly - yet :) Your code would work if you had the same types but as return values, like this: public delegate object

c#4.0: int a real subtype of object? covariance, ienumerable and value types

て烟熏妆下的殇ゞ 提交于 2019-12-18 15:35:11
问题 I wonder why IEnumerable<int> can't be assigned to a IEnumerable<object> . After all IEnumerable is one of the few interfaces that supports covariance... The subtype relation and covariance stuff works with reference types int seems to be a proper subtype of object The combination of both features doesn't work however... class A { } class B : A { } class Program { static void Main(string[] args) { bool b; b = typeof(IEnumerable<A>).IsAssignableFrom(typeof(List<B>)); Console.WriteLine(

Covariance and Contravariance on the same type argument

99封情书 提交于 2019-12-18 15:23:29
问题 The C# spec states that an argument type cannot be both covariant and contravariant at the same time. This is apparent when creating a covariant or contravariant interface you decorate your type parameters with "out" or "in" respectively. There is not option that allows both at the same time ("outin"). Is this limitation simply a language specific constraint or are there deeper, more fundamental reasons based in category theory that would make you not want your type to be both covariant and

Covariance and Contravariance on the same type argument

馋奶兔 提交于 2019-12-18 15:23:09
问题 The C# spec states that an argument type cannot be both covariant and contravariant at the same time. This is apparent when creating a covariant or contravariant interface you decorate your type parameters with "out" or "in" respectively. There is not option that allows both at the same time ("outin"). Is this limitation simply a language specific constraint or are there deeper, more fundamental reasons based in category theory that would make you not want your type to be both covariant and

Covariance and Contravariance on the same type argument

╄→гoц情女王★ 提交于 2019-12-18 15:22:26
问题 The C# spec states that an argument type cannot be both covariant and contravariant at the same time. This is apparent when creating a covariant or contravariant interface you decorate your type parameters with "out" or "in" respectively. There is not option that allows both at the same time ("outin"). Is this limitation simply a language specific constraint or are there deeper, more fundamental reasons based in category theory that would make you not want your type to be both covariant and

Can a String[] hold System.Object inside it?

徘徊边缘 提交于 2019-12-18 13:13:58
问题 Do you feel question is strange? yes what happened also strange. let me explain. I have found a snippet from this Covariance and Contravariance with C# Arrays string[] strings = new string[1]; object[] objects = strings; objects[0] = new object(); Jon skeet explains that above code will throw ArrayTypeMismatchException , as said yes it does. what I did is I put a breakpoint in line 3, Using DebuggerVisualizer I manually set objects[0] = new object() it doesn't throw any error and it works.

Covariance of Box type in Rust

点点圈 提交于 2019-12-18 08:55:40
问题 After I read the subtyping chapter of the Nomicon, I couldn't wrap my head around covariance of a type parameter. Especially for the Box<T> type, which is described as: T is covariant . However, if I write this code: trait A {} trait B: A {} struct C; impl A for C {} impl B for C {} fn foo(v: Box<A>) {} fn main() { let c = C; let b: Box<B> = Box::new(c); foo(b); } (Playground) error[E0308]: mismatched types --> src/main.rs:13:9 | 13 | foo(b); | ^ expected trait `A`, found trait `B` | = note:

Is it possible to override a property and return a derived type in VB.NET?

南笙酒味 提交于 2019-12-18 08:09:08
问题 Consider the following classes representing an Ordering system: Public Class OrderBase Public MustOverride Property OrderItem as OrderItemBase End Class Public Class OrderItemBase End Class Now, suppose we want to extend these classes to a more specific set of order classes, keeping the aggregate nature of OrderBase: Public Class WebOrder Inherits OrderBase Public Overrides Property OrderItem as WebOrderItem End Property End Class Public Class WebOrderItem Inherits OrderItemBase End Class The