<commit_before>// Copyright 2016 The Gosl Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ode

import (
	"math"

	"github.com/cpmech/gosl/chk"
	"github.com/cpmech/gosl/fun"
	"github.com/cpmech/gosl/io"
	"github.com/cpmech/gosl/la"
	"github.com/cpmech/gosl/plt"
	"github.com/cpmech/gosl/utl"
)

// Problem defines the data for an ODE problems (e.g. for testing)
type Problem struct {
	Yana YanaF       // analytical solution
	Fcn  Func        // the function f(x,y) = dy/df
	Jac  JacF        // df/dy function
	Dx   float64     // timestep for fixedStep tests
	Xf   float64     // final x
	Y    la.Vector   // initial (current) y vector
	Ndim int         // dimension == len(Y)
	M    *la.Triplet // "mass" matrix
	Ytmp la.Vector   // to use with Yana
}

// Solve solves ODE problem using standard parameters
// NOTE: this solver doesn't change o.Y
func (o *Problem) Solve(method string, fixedStp, numJac bool) (y la.Vector, stat *Stat, out *Output, err error) {

	// current y vector
	y = la.NewVector(o.Ndim)
	y.Apply(1, o.Y)

	// configuration
	conf, err := NewConfig(method, "", nil)
	if fixedStp {
		conf.SetFixedH(o.Dx, o.Xf)
	}
	conf.SetStepOut(true, nil)

	// output handler
	out = NewOutput(o.Ndim, conf)

	// allocate solver
	jac := o.Jac
	if numJac {
		jac = nil
	}
	sol, err := NewSolver(o.Ndim, conf, out, o.Fcn, jac, nil)<commit_msg>Catch error<commit_after>// Copyright 2016 The Gosl Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ode

import (
	"math"

	"github.com/cpmech/gosl/chk"
	"github.com/cpmech/gosl/fun"
	"github.com/cpmech/gosl/io"
	"github.com/cpmech/gosl/la"
	"github.com/cpmech/gosl/plt"
	"github.com/cpmech/gosl/utl"
)

// Problem defines the data for an ODE problems (e.g. for testing)
type Problem struct {
	Yana YanaF       // analytical solution
	Fcn  Func        // the function f(x,y) = dy/df
	Jac  JacF        // df/dy function
	Dx   float64     // timestep for fixedStep tests
	Xf   float64     // final x
	Y    la.Vector   // initial (current) y vector
	Ndim int         // dimension == len(Y)
	M    *la.Triplet // "mass" matrix
	Ytmp la.Vector   // to use with Yana
}

// Solve solves ODE problem using standard parameters
// NOTE: this solver doesn't change o.Y
func (o *Problem) Solve(method string, fixedStp, numJac bool) (y la.Vector, stat *Stat, out *Output, err error) {

	// current y vector
	y = la.NewVector(o.Ndim)
	y.Apply(1, o.Y)

	// configuration
	conf, err := NewConfig(method, "", nil)
	if err != nil {
		return
	}
	if fixedStp {
		conf.SetFixedH(o.Dx, o.Xf)
	}
	conf.SetStepOut(true, nil)

	// output handler
	out = NewOutput(o.Ndim, conf)

	// allocate solver
	jac := o.Jac
	if numJac {
		jac = nil
	}
	sol, err := NewSolver(o.Ndim, conf, out, o.Fcn, jac, nil)
{'fraction_non_alphanumeric': 0.12659098727210183, 'fraction_numerical': 0.006191950464396285, 'mean_word_length': 2.742599742599743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1725070', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1090, 'n_words': 332}