假设你有一个对称矩阵A,
例如
# A = | a b/2 |
# | b/2 c |
Run Code Online (Sandbox Code Playgroud)
并且您的等式代表圆锥曲线,您可以使用该conics包
你需要的是系数c(a,b,c,d,e,f)表示的向量
a.x^2 + b*x*y + c*y^2 + d*x + e*y + f
Run Code Online (Sandbox Code Playgroud)
在你的情况下,说你有
A <- matrix(c(2,1,1,2))
B <- c(-20,-28)
C <- 10
# create the vector
v <- append(c(diag(A),B,C),A[lower.tri(A)]*2), 1)
conicPlot(v)
Run Code Online (Sandbox Code Playgroud)

您可以轻松地将其包装multiplication out成一个简单的函数
# note this does no checking for symmetry or validity of arguments
expand.conic <- function(A, B, C){
append(c(diag(A),B,C),A[lower.tri(A)]*2), 1)
}
Run Code Online (Sandbox Code Playgroud)