> For the complete documentation index, see [llms.txt](https://ceres-solver-tutorial-cn.gitbook.io/ceres/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ceres-solver-tutorial-cn.gitbook.io/ceres/modeling-non-linear-least-squares/main-class-interface/sizecostfunction.md).

# SizeCostFunction

```cpp
class SizedCostFunction
```

如果在编译时就知道参数块的大小和残差向量的大小（这是常见的情况），则可以使用 `SizeCostFunction` 将这些值指定为模板参数，用户只需重写 `CostFunction::Evaluate()` 即可。

```cpp
template<int kNumResiduals, int... Ns>
class SizedCostFunction : public CostFunction {
 public:
  virtual bool Evaluate(double const* const* parameters,
                        double* residuals,
                        double** jacobians) const = 0;
};
```
