本文整理汇总了Golang中github.com/verdverm/go-symexpr.Expr.StackSerial方法的典型用法代码示例。如果您正苦于以下问题:Golang Expr.StackSerial方法的具体用法?Golang Expr.StackSerial怎么用?Golang Expr.StackSerial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/verdverm/go-symexpr.Expr
的用法示例。
在下文中一共展示了Expr.StackSerial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StackLevmarExpr
func StackLevmarExpr(e expr.Expr, x_dims int, coeff []float64, c_ygiven, c_input []C_double) []float64 {
// fmt.Printf("Entering Stack Levmar: \n")
c_coeff := make([]C.double, len(coeff))
for i, c := range coeff {
c_coeff[i] = C.double(c)
}
// c_ygiven := make([]C.double, len(ygiven))
// for i, c := range ygiven {
// c_ygiven[i] = C.double(c)
// }
// c_input := make([]C.double, len(input))
// for i, c := range input {
// c_input[i] = C.double(c)
// }
cp := (*C.double)(unsafe.Pointer(&c_coeff[0]))
mi := C.int(len(coeff))
yp := (*C.double)(unsafe.Pointer(&c_ygiven[0]))
ni := C.int(len(c_ygiven))
var sd *C.StackData
sd = new(C.StackData)
// fmt.Printf("x_len: %d x_dim: %d\n", len(input), x_dims)
sd.x_len = C.int(len(c_input))
sd.x_dim = C.int(x_dims)
sd.x_data = (*C.double)(unsafe.Pointer(&c_input[0]))
serial := make([]int, 0)
serial = e.StackSerial(serial)
// fmt.Printf("StackSerial: %v\n", serial)
c_serial := make([]C.int, len(serial))
for i, I := range serial {
c_serial[i] = C.int(I)
}
sd.expr.serial = (*C.int)(unsafe.Pointer(&c_serial[0]))
sd.expr.s_len = C.int(len(serial))
// fmt.Printf("GOT HERE: %v\n", serial)
derivs := make([]C.StackExpr, len(coeff))
for i, _ := range coeff {
deriv := e.DerivConst(i)
dserial := make([]int, 0)
dserial = deriv.StackSerial(dserial)
d_serial := make([]C.int, len(dserial))
for i, I := range dserial {
d_serial[i] = C.int(I)
}
derivs[i].serial = (*C.int)(unsafe.Pointer(&d_serial[0]))
derivs[i].s_len = C.int(len(d_serial))
}
sd.derivs = (*C.StackExpr)(unsafe.Pointer(&derivs[0]))
sd.d_len = C.int(mi)
// fmt.Printf("Going into stack_levmar_dif\n")
C.stack_levmar_dif(yp, cp, mi, ni, unsafe.Pointer(sd))
// C.stack_levmar_der(yp, cp, mi, ni, unsafe.Pointer(sd))
// fmt.Printf("Returned from stack_levmar_dif\n")
c := make([]float64, len(c_coeff))
for i, _ := range c_coeff {
c[i] = float64(c_coeff[i])
}
// fmt.Printf("C0: %f\n", c[0])
return c
}