nus-yam/ex-repair huggingface dataset:
Program: 150533
Project: 150533
Buggy source:
private String getJavaClassName0(Definition definition,String suffix){
  StringBuilder result=new StringBuilder();
  String name=GenerationUtil.convertToJavaIdentifier(definition.getName());
  result.append(StringUtils.toCamelCase(name));
  if (!"String_Node_Str".equals(suffix) && !StringUtils.isEmpty(suffix)) {
    result.append(suffix);
  }
  if (!StringUtils.isBlank(definition.getOverload())) {
    result.append(definition.getOverload());
  }
  return result.toString();
}

Fixed version (ground truth):
private String getJavaClassName0(Definition definition,String suffix){
  StringBuilder result=new StringBuilder();
  String n=(definition instanceof SchemaDefinition) ? definition.getDatabase().getOutputSchema(definition.getName()) : definition.getName();
  String name=GenerationUtil.convertToJavaIdentifier(n);
  result.append(StringUtils.toCamelCase(name));
  if (!"String_Node_Str".equals(suffix) && !StringUtils.isEmpty(suffix)) {
    result.append(suffix);
  }
  if (!StringUtils.isBlank(definition.getOverload())) {
    result.append(definition.getOverload());
  }
  return result.toString();
}
Program: 150534
Project: 150534
Buggy source:
@Override public String getJavaIdentifier(Definition definition){
  return GenerationUtil.convertToJavaIdentifier(definition.getName());
}

Fixed version (ground truth):
@Override public String getJavaIdentifier(Definition definition){
  String n=(definition instanceof SchemaDefinition) ? definition.getDatabase().getOutputSchema(definition.getName()) : definition.getName();
  return GenerationUtil.convertToJavaIdentifier(n);
}
Program: 150535
Project: 150535
Buggy source:
@Override public final List<SchemaDefinition> getSchemata(){
  if (schemata == null) {
    schemata=new ArrayList<SchemaDefinition>();
    for (    String name : getInputSchemata()) {
      schemata.add(new SchemaDefinition(this,getOutputSchema(name),null));
    }
  }
  return schemata;
}

Fixed version (ground truth):
@Override public final List<SchemaDefinition> getSchemata(){
  if (schemata == null) {
    schemata=new ArrayList<SchemaDefinition>();
    for (    String name : getInputSchemata()) {
      schemata.add(new SchemaDefinition(this,name,null));
    }
  }
  return schemata;
}
Program: 150536
Project: 150536
Buggy source:
@Override public final SchemaDefinition getSchema(String name){
  for (  SchemaDefinition schema : getSchemata()) {
    if (schema.getName().equals(getOutputSchema(name))) {
      return schema;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public final SchemaDefinition getSchema(String inputName){
  for (  SchemaDefinition schema : getSchemata()) {
    if (schema.getName().equals(inputName)) {
      return schema;
    }
  }
  return null;
}
Program: 150537
Project: 150537
Buggy source:
@Override public final String getQualifiedName(){
  if (StringUtils.isBlank(getSchema().getName())) {
    return getName();
  }
 else {
    return getSchema().getName() + "String_Node_Str" + getName();
  }
}

Fixed version (ground truth):
@Override public final String getQualifiedName(){
  if (StringUtils.isBlank(getSchema().getName())) {
    return getName();
  }
 else {
    return getDatabase().getOutputSchema(getSchema().getName()) + "String_Node_Str" + getName();
  }
}
Program: 150538
Project: 150538
Buggy source:
@Override public final String getQualifiedName(){
  if (StringUtils.isBlank(getSchema().getName())) {
    return getContainer().getName() + "String_Node_Str" + getName();
  }
 else {
    return getSchema().getName() + "String_Node_Str" + getContainer().getName()+ "String_Node_Str"+ getName();
  }
}

Fixed version (ground truth):
@Override public final String getQualifiedName(){
  if (StringUtils.isBlank(getSchema().getName())) {
    return getContainer().getName() + "String_Node_Str" + getName();
  }
 else {
    return getDatabase().getOutputSchema(getSchema().getName()) + "String_Node_Str" + getContainer().getName()+ "String_Node_Str"+ getName();
  }
}
Program: 150539
Project: 150539
Buggy source:
@Override public final String getQualifiedName(){
  return getName();
}

Fixed version (ground truth):
@Override public final String getQualifiedName(){
  return getDatabase().getOutputSchema(getName());
}
Program: 150540
Project: 150540
Buggy source:
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    if (Arrays.asList(DERBY,HSQLDB,MYSQL,POSTGRES).contains(context.getDialect())) {
      context.sql("String_Node_Str");
    }
    context.sql("String_Node_Str");
    context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
        if (context.declareTables() && aliasProvider instanceof ArrayTable) {
          Object o=aliasProvider;
          ArrayTable table=(ArrayTable)o;
          context.sql("String_Node_Str");
          Util.toSQLNames(context,table.getFields());
          context.sql("String_Node_Str");
        }
        break;
      }
  }
}
 else {
  context.literal(alias);
}
}

Fixed version (ground truth):
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    if (Arrays.asList(DERBY,HSQLDB,MYSQL,POSTGRES).contains(context.getDialect())) {
      context.sql("String_Node_Str");
    }
    context.sql("String_Node_Str");
    context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
        Object o=aliasProvider;
        if (context.declareTables() && o instanceof ArrayTable) {
          ArrayTable table=(ArrayTable)o;
          context.sql("String_Node_Str");
          Util.toSQLNames(context,table.getFields());
          context.sql("String_Node_Str");
        }
        break;
      }
  }
}
 else {
  context.literal(alias);
}
}
Program: 150541
Project: 150541
Buggy source:
private final Table<?> getTable(String name) throws Exception {
  if (schema() == null) {
    Class<?> tables=Class.forName("String_Node_Str" + getDialect().getName().toLowerCase() + "String_Node_Str");
    return (Table<?>)tables.getField(name).get(tables);
  }
 else {
    Table<?> result=schema().getTable(name);
    if (result == null) {
      result=schema().getTable(name.toUpperCase());
    }
    if (result == null) {
      result=schema().getTable(name.toLowerCase());
    }
    return result;
  }
}

Fixed version (ground truth):
private final Table<?> getTable(String name) throws Exception {
  Schema schema=TAuthor().getSchema();
  if (schema == null) {
    Class<?> tables=Class.forName("String_Node_Str" + getDialect().getName().toLowerCase() + "String_Node_Str");
    return (Table<?>)tables.getField(name).get(tables);
  }
 else {
    Table<?> result=schema.getTable(name);
    if (result == null) {
      result=schema.getTable(name.toUpperCase());
    }
    if (result == null) {
      result=schema.getTable(name.toLowerCase());
    }
    return result;
  }
}
Program: 150542
Project: 150542
Buggy source:
@SuppressWarnings("String_Node_Str") private final InsertImpl<R> values0(List<Field<?>> values){
  if (fields.size() == 0) {
    fields.addAll(into.getFields());
  }
  if (fields.size() != values.size()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  getDelegate().newRecord();
  for (int i=0; i < fields.size(); i++) {
    getDelegate().addValue((Field<Object>)fields.get(i),(Field<Object>)values.get(i));
  }
  return this;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private final InsertImpl<R> values0(List<Field<?>> values){
  if (fields.size() == 0) {
    fields.addAll(into.getFields());
  }
  if (fields.size() != values.size()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  getDelegate().newRecord();
  for (int i=0; i < fields.size(); i++) {
    getDelegate().addValue((Field<Void>)fields.get(i),(Field<Void>)values.get(i));
  }
  return this;
}
Program: 150543
Project: 150543
Buggy source:
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
switch (context.getDialect()) {
case POSTGRES:
case HSQLDB:
case DERBY:
case MYSQL:
      context.sql("String_Node_Str");
    break;
}
context.sql("String_Node_Str");
context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
    if (context.declareTables() && aliasProvider instanceof ArrayTable) {
      Table<?> table=(Table<?>)aliasProvider;
      context.sql("String_Node_Str");
      JooqUtil.toSQLNames(context,table.getFields());
      context.sql("String_Node_Str");
    }
    break;
  }
}
}
 else {
context.literal(alias);
}
}

Fixed version (ground truth):
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
switch (context.getDialect()) {
case POSTGRES:
case HSQLDB:
case DERBY:
case MYSQL:
      context.sql("String_Node_Str");
    break;
}
context.sql("String_Node_Str");
context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
    if (context.declareTables() && aliasProvider instanceof ArrayTable) {
      Object o=aliasProvider;
      ArrayTable<?> table=(ArrayTable<?>)o;
      context.sql("String_Node_Str");
      JooqUtil.toSQLNames(context,table.getFields());
      context.sql("String_Node_Str");
    }
    break;
  }
}
}
 else {
context.literal(alias);
}
}
Program: 150544
Project: 150544
Buggy source:
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
switch (context.getDialect()) {
case POSTGRES:
case HSQLDB:
case DERBY:
case MYSQL:
      context.sql("String_Node_Str");
    break;
}
context.sql("String_Node_Str");
context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
    if (context.declareTables() && aliasProvider instanceof ArrayTable) {
      ArrayTable<?> table=(ArrayTable<?>)aliasProvider;
      context.sql("String_Node_Str");
      table.getFields().toSQLNames(context);
      context.sql("String_Node_Str");
    }
    break;
  }
}
}
 else {
context.literal(alias);
}
}

Fixed version (ground truth):
@Override public final void toSQL(RenderContext context){
  if (context.declareFields() || context.declareTables()) {
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
    context.sql(aliasProvider);
    if (wrapInParentheses) {
      context.sql("String_Node_Str");
    }
switch (context.getDialect()) {
case POSTGRES:
case HSQLDB:
case DERBY:
case MYSQL:
      context.sql("String_Node_Str");
    break;
}
context.sql("String_Node_Str");
context.literal(alias);
switch (context.getDialect()) {
case HSQLDB:
case POSTGRES:
{
    if (context.declareTables() && aliasProvider instanceof ArrayTable) {
      Table<?> table=(Table<?>)aliasProvider;
      context.sql("String_Node_Str");
      JooqUtil.toSQLNames(context,table.getFields());
      context.sql("String_Node_Str");
    }
    break;
  }
}
}
 else {
context.literal(alias);
}
}
Program: 150545
Project: 150545
Buggy source:
private void toSQL0(RenderContext context){
  if (usingSyntax) {
    context.sql("String_Node_Str");
    using.toSQLNames(context);
    context.sql("String_Node_Str");
  }
 else {
    context.sql("String_Node_Str").sql(getCondition());
  }
}

Fixed version (ground truth):
private void toSQL0(RenderContext context){
  if (usingSyntax) {
    context.sql("String_Node_Str");
    JooqUtil.toSQLNames(context,using);
    context.sql("String_Node_Str");
  }
 else {
    context.sql("String_Node_Str").sql(getCondition());
  }
}
Program: 150546
Project: 150546
Buggy source:
/** 
 * Whether this data type is any binary type. This applies to any of these types. <ul> <li>   {@link SQLDataType#BINARY}</li> <li>   {@link SQLDataType#BLOB}</li> <li>   {@link SQLDataType#LONGVARBINARY}</li> <li>   {@link SQLDataType#VARBINARY}</li> </ul>
 * @return
 */
boolean isBinary();

Fixed version (ground truth):
/** 
 * Whether this data type is any binary type. This applies to any of these types. <ul> <li>   {@link SQLDataType#BINARY}</li> <li>   {@link SQLDataType#BLOB}</li> <li>   {@link SQLDataType#LONGVARBINARY}</li> <li>   {@link SQLDataType#VARBINARY}</li> </ul>
 */
boolean isBinary();
Program: 150547
Project: 150547
Buggy source:
/** 
 * Whether this data type is any date or time type. This applies to any of these types. <ul> <li>   {@link SQLDataType#DATE}</li> <li>   {@link SQLDataType#TIME}</li> <li>   {@link SQLDataType#TIMESTAMP}</li> </ul>
 * @return
 */
boolean isTemporal();

Fixed version (ground truth):
/** 
 * Whether this data type is any date or time type. This applies to any of these types. <ul> <li>   {@link SQLDataType#DATE}</li> <li>   {@link SQLDataType#TIME}</li> <li>   {@link SQLDataType#TIMESTAMP}</li> </ul>
 */
boolean isTemporal();
Program: 150548
Project: 150548
Buggy source:
/** 
 * Whether this data type is any character data type. This applies to any of these types: <ul> <li>   {@link SQLDataType#CHAR}</li> <li>   {@link SQLDataType#CLOB}</li> <li>   {@link SQLDataType#LONGNVARCHAR}</li> <li>   {@link SQLDataType#LONGVARCHAR}</li> <li>   {@link SQLDataType#NCHAR}</li> <li>   {@link SQLDataType#NCLOB}</li> <li>   {@link SQLDataType#NVARCHAR}</li> <li>   {@link SQLDataType#VARCHAR}</li> </ul>
 * @return
 */
boolean isString();

Fixed version (ground truth):
/** 
 * Whether this data type is any character data type. This applies to any of these types: <ul> <li>   {@link SQLDataType#CHAR}</li> <li>   {@link SQLDataType#CLOB}</li> <li>   {@link SQLDataType#LONGNVARCHAR}</li> <li>   {@link SQLDataType#LONGVARCHAR}</li> <li>   {@link SQLDataType#NCHAR}</li> <li>   {@link SQLDataType#NCLOB}</li> <li>   {@link SQLDataType#NVARCHAR}</li> <li>   {@link SQLDataType#VARCHAR}</li> </ul>
 */
boolean isString();
Program: 150550
Project: 150550
Buggy source:
/** 
 * Opens a window showing the found point cloud. Points are colorized using the pixel value inside one of the input images
 */
private void visualizeResults(BundleAdjustmentSceneStructure structure,CameraPinholeRadial intrinsic,List<BufferedImage> colorImages){
  PointCloudViewer gui=new PointCloudViewer(intrinsic,1);
  Point3D_F64 world=new Point3D_F64();
  Point3D_F64 camera=new Point3D_F64();
  Point2D_F64 pixel=new Point2D_F64();
  for (int i=0; i < structure.points.length; i++) {
    BundleAdjustmentSceneStructure.Point p=structure.points[i];
    p.get(world);
    for (int j=0; j < p.views.size; j++) {
      int viewIdx=p.views.get(j);
      SePointOps_F64.transform(structure.views[viewIdx].worldToView,world,camera);
      int cameraIdx=structure.views[viewIdx].camera;
      structure.cameras[cameraIdx].model.project(camera.x,camera.y,camera.z,pixel);
      BufferedImage image=colorImages.get(viewIdx);
      int x=(int)pixel.x;
      int y=(int)pixel.y;
      if (x < 0 || y < 0 || x >= image.getWidth() || y >= image.getHeight())       continue;
      int rgb=image.getRGB((int)pixel.x,(int)pixel.y);
      gui.addPoint(world.x,world.y,world.z,rgb);
    }
  }
  gui.setPreferredSize(new Dimension(500,500));
  ShowImages.showWindow(gui,"String_Node_Str",true);
}

Fixed version (ground truth):
/** 
 * Opens a window showing the found point cloud. Points are colorized using the pixel value inside one of the input images
 */
private void visualizeResults(BundleAdjustmentSceneStructure structure,CameraPinholeRadial intrinsic,List<BufferedImage> colorImages){
  PointCloudViewer gui=new PointCloudViewer(intrinsic,1);
  Point3D_F64 world=new Point3D_F64();
  Point3D_F64 camera=new Point3D_F64();
  Point2D_F64 pixel=new Point2D_F64();
  for (int i=0; i < structure.points.length; i++) {
    BundleAdjustmentSceneStructure.Point p=structure.points[i];
    p.get(world);
    for (int j=0; j < p.views.size; j++) {
      int viewIdx=p.views.get(j);
      SePointOps_F64.transform(structure.views[viewIdx].worldToView,world,camera);
      int cameraIdx=structure.views[viewIdx].camera;
      structure.cameras[cameraIdx].model.project(camera.x,camera.y,camera.z,pixel);
      BufferedImage image=colorImages.get(viewIdx);
      int x=(int)pixel.x;
      int y=(int)pixel.y;
      if (x < 0 || y < 0 || x >= image.getWidth() || y >= image.getHeight())       continue;
      int rgb=image.getRGB((int)pixel.x,(int)pixel.y);
      gui.addPoint(world.x,world.y,world.z,rgb);
      break;
    }
  }
  gui.setPreferredSize(new Dimension(500,500));
  ShowImages.showWindow(gui,"String_Node_Str",true);
}
Program: 150551
Project: 150551
Buggy source:
public static void main(String[] args){
  String directory=UtilIO.pathExample("String_Node_Str");
  CameraPinholeRadial intrinsic=CalibrationIO.load(new File(directory,"String_Node_Str"));
  List<BufferedImage> images=UtilImageIO.loadImages(directory,"String_Node_Str");
  int N=2;
  while (images.size() > N) {
    images.remove(N);
  }
  ExampleMultiviewSceneReconstruction example=new ExampleMultiviewSceneReconstruction();
  long before=System.currentTimeMillis();
  example.process(intrinsic,images);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) / 1000.0 + "String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args){
  String directory=UtilIO.pathExample("String_Node_Str");
  CameraPinholeRadial intrinsic=CalibrationIO.load(new File(directory,"String_Node_Str"));
  List<BufferedImage> images=UtilImageIO.loadImages(directory,"String_Node_Str");
  int N=5;
  while (images.size() > N) {
    images.remove(N);
  }
  ExampleMultiviewSceneReconstruction example=new ExampleMultiviewSceneReconstruction();
  long before=System.currentTimeMillis();
  example.process(intrinsic,images);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) / 1000.0 + "String_Node_Str");
}
Program: 150554
Project: 150554
Buggy source:
@Override public void addCamera(String cameraName,LensDistortionNarrowFOV intrinsic,int width,int height){
  if (camerasPixelToNorm.isEmpty())   calibrated=true;
 else   if (!calibrated)   throw new IllegalArgumentException("String_Node_Str");
  Point2Transform2_F64 pixelToNorm=intrinsic.undistort_F64(true,false);
  camerasPixelToNorm.put(cameraName,pixelToNorm);
  camerasIntrinsc.put(cameraName,PerspectiveOps.estimatePinhole(pixelToNorm,width,height));
}

Fixed version (ground truth):
@Override public void addCamera(String cameraName,LensDistortionNarrowFOV intrinsic,int width,int height){
  if (camerasPixelToNorm.isEmpty())   calibrated=true;
 else   if (!calibrated)   throw new IllegalArgumentException("String_Node_Str");
  Point2Transform2_F64 pixelToNorm=intrinsic.undistort_F64(true,false);
  camerasPixelToNorm.put(cameraName,pixelToNorm);
  camerasIntrinsc.put(cameraName,PerspectiveOps.estimatePinhole(pixelToNorm,width,height));
  cameraToIndex.put(cameraName,cameraToIndex.size());
}
Program: 150555
Project: 150555
Buggy source:
@Override public boolean estimate(){
  if (calibrated) {
    ransacEssential=FactoryMultiViewRobust.essentialRansac(configEssential,configRansac);
    ransacHomography=FactoryMultiViewRobust.homographyCalibratedRansac(configRansac);
    ransacPnP=FactoryMultiViewRobust.pnpRansac(null,configRansac);
  }
 else {
    ransacFundamental=FactoryMultiViewRobust.fundamentalRansac(configFundamental,configRansac);
  }
  if (graphNodes.size() < 2)   return false;
  for (int i=0; i < graphNodes.size(); i++) {
    for (int j=i + 1; j < graphNodes.size(); j++) {
      connectViews(graphNodes.get(i),graphNodes.get(j));
      if (stopRequested)       return false;
    }
  }
  if (graphEdges.size() < 1)   return false;
  CameraView origin=selectOriginNode();
  CameraMotion baseMotion=selectCoordinateBase(origin);
  defineCoordinateSystem(origin,baseMotion);
  if (stopRequested)   return false;
  triangulateInitialSeed(origin,baseMotion);
  estimateAllFeatures(origin,baseMotion.destination(origin));
  if (stopRequested)   return false;
  convertToOutput(origin);
  return viewsAdded.size() >= 2;
}

Fixed version (ground truth):
@Override public boolean estimate(){
  if (graphNodes.size() < 2)   return false;
  declareModelFitting();
  for (int i=0; i < graphNodes.size(); i++) {
    for (int j=i + 1; j < graphNodes.size(); j++) {
      connectViews(graphNodes.get(i),graphNodes.get(j));
      if (stopRequested)       return false;
    }
  }
  if (graphEdges.size() < 1)   return false;
  CameraView origin=selectOriginNode();
  CameraMotion baseMotion=selectCoordinateBase(origin);
  defineCoordinateSystem(origin,baseMotion);
  if (stopRequested)   return false;
  triangulateInitialSeed(origin,baseMotion);
  estimateAllFeatures(origin,baseMotion.destination(origin));
  if (stopRequested)   return false;
  convertToOutput(origin);
  return viewsAdded.size() >= 2;
}
Program: 150557
Project: 150557
Buggy source:
/** 
 * Detect features inside the image and save the results
 * @param image
 */
@Override public void add(T image,String cameraName){
  if (cameraName == null || !camerasPixelToNorm.containsKey(cameraName))   throw new IllegalArgumentException("String_Node_Str");
  CameraView view=new CameraView(graphNodes.size(),new FastQueue<TupleDesc>(TupleDesc.class,true){
    @Override protected TupleDesc createInstance(){
      return detDesc.createDescription();
    }
  }
);
  view.camera=cameraName;
  graphNodes.add(view);
  detDesc.detect(image);
  view.descriptions.growArray(detDesc.getNumberOfFeatures());
  view.featurePixels.growArray(detDesc.getNumberOfFeatures());
  view.features3D=new Feature3D[detDesc.getNumberOfFeatures()];
  for (int i=0; i < detDesc.getNumberOfFeatures(); i++) {
    Point2D_F64 p=detDesc.getLocation(i);
    view.descriptions.grow().setTo(detDesc.getDescription(i));
    view.featurePixels.grow().set(p);
  }
  Point2Transform2_F64 pixelToNorm=camerasPixelToNorm.get(cameraName);
  if (pixelToNorm == null) {
    return;
  }
  view.featureNorm.growArray(detDesc.getNumberOfFeatures());
  for (int i=0; i < view.featurePixels.size; i++) {
    Point2D_F64 p=view.featurePixels.get(i);
    pixelToNorm.compute(p.x,p.y,view.featureNorm.grow());
  }
}

Fixed version (ground truth):
/** 
 * Detect features inside the image and save the results
 * @param image
 */
@Override public void add(T image,String cameraName){
  if (cameraName == null || !camerasPixelToNorm.containsKey(cameraName))   throw new IllegalArgumentException("String_Node_Str");
  CameraView view=new CameraView(graphNodes.size(),new FastQueue<TupleDesc>(TupleDesc.class,true){
    @Override protected TupleDesc createInstance(){
      return detDesc.createDescription();
    }
  }
);
  view.camera=cameraName;
  graphNodes.add(view);
  detDesc.detect(image);
  view.descriptions.growArray(detDesc.getNumberOfFeatures());
  view.observationPixels.growArray(detDesc.getNumberOfFeatures());
  view.features3D=new Feature3D[detDesc.getNumberOfFeatures()];
  for (int i=0; i < detDesc.getNumberOfFeatures(); i++) {
    Point2D_F64 p=detDesc.getLocation(i);
    view.descriptions.grow().setTo(detDesc.getDescription(i));
    view.observationPixels.grow().set(p);
  }
  Point2Transform2_F64 pixelToNorm=camerasPixelToNorm.get(cameraName);
  if (pixelToNorm == null) {
    return;
  }
  view.observationNorm.growArray(detDesc.getNumberOfFeatures());
  for (int i=0; i < view.observationPixels.size; i++) {
    Point2D_F64 p=view.observationPixels.get(i);
    pixelToNorm.compute(p.x,p.y,view.observationNorm.grow());
  }
}
Program: 150558
Project: 150558
Buggy source:
boolean fitEpipolar(FastQueue<AssociatedIndex> matches,FastQueue<Point2D_F64> pointsA,FastQueue<Point2D_F64> PointsB,Ransac<?,AssociatedPair> ransac,CameraMotion edge){
  pairs.resize(matches.size);
  for (int i=0; i < matches.size; i++) {
    AssociatedIndex a=matches.get(i);
    pairs.get(i).p1.set(pointsA.get(a.src));
    pairs.get(i).p2.set(PointsB.get(a.dst));
  }
  if (!ransac.process(pairs.toList()))   return false;
  int N=ransac.getMatchSet().size();
  for (int i=0; i < N; i++) {
    AssociatedIndex a=matches.get(ransac.getInputIndex(i));
    edge.features.add(a.copy());
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Uses ransac to fit an epipolar model to the associated features. Adds list of matched features to the edge.
 * @param matches List of matched features by index
 * @param pointsA Set of observations from image A
 * @param pointsB Set of observations from image B
 * @param ransac Model fitter
 * @param edge Edge which will contain a description of found motion
 * @return true if no error
 */
boolean fitEpipolar(FastQueue<AssociatedIndex> matches,List<Point2D_F64> pointsA,List<Point2D_F64> pointsB,Ransac<?,AssociatedPair> ransac,CameraMotion edge){
  pairs.resize(matches.size);
  for (int i=0; i < matches.size; i++) {
    AssociatedIndex a=matches.get(i);
    pairs.get(i).p1.set(pointsA.get(a.src));
    pairs.get(i).p2.set(pointsB.get(a.dst));
  }
  if (!ransac.process(pairs.toList()))   return false;
  int N=ransac.getMatchSet().size();
  for (int i=0; i < N; i++) {
    AssociatedIndex a=matches.get(ransac.getInputIndex(i));
    edge.features.add(a.copy());
  }
  return true;
}
Program: 150560
Project: 150560
Buggy source:
public EstimateSceneUnordered(DetectDescribePoint<T,TupleDesc> detDesc){
  this.detDesc=detDesc;
  scorer=FactoryAssociation.defaultScore(detDesc.getDescriptionType());
  associate=FactoryAssociation.greedy(scorer,Double.MAX_VALUE,true);
  configRansac.inlierThreshold=3.0;
  configRansac.maxIterations=2000;
}

Fixed version (ground truth):
/** 
 * Constructor for unit tests
 */
EstimateSceneUnordered(){
  configRansac.inlierThreshold=3.0;
  configRansac.maxIterations=2000;
}
Program: 150561
Project: 150561
Buggy source:
private void convertToOutput(CameraView origin){
  structure=new BundleAdjustmentSceneStructure(false);
  observations=new BundleAdjustmentObservations(graphNodes.size());
  structure.initialize(camerasPixelToNorm.size(),graphNodes.size(),features3D.size());
  for (int i=0; i < graphNodes.size(); i++) {
    CameraView v=graphNodes.get(i);
    structure.setView(i,v == origin,v.viewToWorld.invert(null));
    structure.connectViewToCamera(i,0);
  }
  for (int indexPoint=0; indexPoint < features3D.size(); indexPoint++) {
    Feature3D f=features3D.get(indexPoint);
    structure.setPoint(indexPoint,f.worldPt.x,f.worldPt.y,f.worldPt.z);
    if (f.views.size() != f.feature.size)     throw new RuntimeException("String_Node_Str");
    for (int j=0; j < f.views.size(); j++) {
      CameraView view=f.views.get(j);
      structure.connectPointToView(indexPoint,view.index);
      Point2D_F64 pixel=graphNodes.get(view.index).featurePixels.get(f.feature.get(j));
      observations.getView(view.index).add(indexPoint,(float)(pixel.x),(float)(pixel.y));
    }
  }
}

Fixed version (ground truth):
/** 
 * Converts the internal data structures into the output format for bundle adjustment. Camera models are omitted since they are not available
 * @param origin The origin of the coordinate system
 */
private void convertToOutput(CameraView origin){
  structure=new BundleAdjustmentSceneStructure(false);
  observations=new BundleAdjustmentObservations(graphNodes.size());
  structure.initialize(cameraToIndex.size(),graphNodes.size(),features3D.size());
  for (int i=0; i < viewsAdded.size(); i++) {
    CameraView v=viewsAdded.get(i);
    int cameraIndex=cameraToIndex.get(v.camera);
    structure.setView(i,v == origin,v.viewToWorld.invert(null));
    structure.connectViewToCamera(i,cameraIndex);
  }
  for (int indexPoint=0; indexPoint < features3D.size(); indexPoint++) {
    Feature3D f=features3D.get(indexPoint);
    structure.setPoint(indexPoint,f.worldPt.x,f.worldPt.y,f.worldPt.z);
    if (f.views.size() != f.obsIdx.size)     throw new RuntimeException("String_Node_Str");
    for (int j=0; j < f.views.size(); j++) {
      CameraView view=f.views.get(j);
      structure.connectPointToView(indexPoint,view.index);
      Point2D_F64 pixel=graphNodes.get(view.index).observationPixels.get(f.obsIdx.get(j));
      observations.getView(view.index).add(indexPoint,(float)(pixel.x),(float)(pixel.y));
    }
  }
}
Program: 150562
Project: 150562
Buggy source:
/** 
 * Process the images and reconstructor the scene as a point cloud using matching interest points between images.
 */
public void process(CameraPinholeRadial intrinsic,List<BufferedImage> colorImages){
  pixelToNorm=LensDistortionOps.narrow(intrinsic).undistort_F64(true,false);
  estimateEssential=FactoryMultiViewRobust.essentialRansac(new ConfigEssential(intrinsic),new ConfigRansac(4000,inlierTol));
  estimatePnP=FactoryMultiViewRobust.pnpRansac(new ConfigPnP(intrinsic),new ConfigRansac(4000,inlierTol));
  detectImageFeatures(colorImages);
  computeConnections();
  printConnectionMatrix();
  System.out.println("String_Node_Str");
  CameraView seed=selectMostConnectFrame();
  CameraView seedNext=estimateFeatureLocations(seed);
  estimateAllFeatures(seed,seedNext);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  pruneFeatures();
  System.out.println("String_Node_Str" + featuresAll.size() + "String_Node_Str"+ featuresPruned.size());
  System.out.println("String_Node_Str");
  long before=System.currentTimeMillis();
  performBundleAdjustment(seed,intrinsic);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) + "String_Node_Str");
  visualizeResults(intrinsic);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Process the images and reconstructor the scene as a point cloud using matching interest points between images.
 */
public void process(CameraPinholeRadial intrinsic,List<BufferedImage> colorImages){
  this.intrinsic=intrinsic;
  pixelToNorm=LensDistortionOps.narrow(intrinsic).undistort_F64(true,false);
  estimateEssential=FactoryMultiViewRobust.essentialRansac(new ConfigEssential(intrinsic),new ConfigRansac(4000,inlierTol));
  estimatePnP=FactoryMultiViewRobust.pnpRansac(new ConfigPnP(intrinsic),new ConfigRansac(4000,inlierTol));
  detectImageFeatures(colorImages);
  computeConnections();
  printConnectionMatrix();
  System.out.println("String_Node_Str");
  CameraView seed=selectMostConnectFrame();
  CameraView seedNext=estimateFeatureLocations(seed);
  estimateAllFeatures(seed,seedNext);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  featuresPruned.addAll(featuresAll);
  System.out.println("String_Node_Str" + featuresAll.size() + "String_Node_Str"+ featuresPruned.size());
  System.out.println("String_Node_Str");
  long before=System.currentTimeMillis();
  performBundleAdjustment(seed,intrinsic);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) + "String_Node_Str");
  visualizeResults(intrinsic);
  System.out.println("String_Node_Str");
}
Program: 150564
Project: 150564
Buggy source:
public static void main(String[] args){
  String directory=UtilIO.pathExample("String_Node_Str");
  CameraPinholeRadial intrinsic=CalibrationIO.load(new File(directory,"String_Node_Str"));
  List<BufferedImage> images=UtilImageIO.loadImages(directory,"String_Node_Str");
  while (images.size() > 8) {
    images.remove(8);
  }
  ExampleMultiviewSceneReconstruction example=new ExampleMultiviewSceneReconstruction();
  long before=System.currentTimeMillis();
  example.process(intrinsic,images);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) / 1000.0 + "String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args){
  String directory=UtilIO.pathExample("String_Node_Str");
  CameraPinholeRadial intrinsic=CalibrationIO.load(new File(directory,"String_Node_Str"));
  List<BufferedImage> images=UtilImageIO.loadImages(directory,"String_Node_Str");
  while (images.size() > 12) {
    images.remove(12);
  }
  ExampleMultiviewSceneReconstruction example=new ExampleMultiviewSceneReconstruction();
  long before=System.currentTimeMillis();
  example.process(intrinsic,images);
  long after=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (after - before) / 1000.0 + "String_Node_Str");
}
Program: 150565
Project: 150565
Buggy source:
/** 
 * Bundle adjustment can run very slow if there are too many features. This uses a heuristic explained in the code to reduce the number of 3D features by removing redundant ones. Could improve this approach by applying stricture geometric constraints that should improve the feature quality, in theory.
 */
private void pruneFeatures(){
  List<Feature3D> candidates=new ArrayList<>();
  for (  CameraMotion m : graphEdges) {
    candidates.clear();
    for (int i=0; i < m.features.size(); i++) {
      AssociatedIndex a=m.features.get(i);
      Feature3D f=m.viewSrc.features3D[a.src];
      if (f != null && !f.included && f.views.size >= 3) {
        candidates.add(f);
      }
    }
    int totalSave=Math.min(TARGET_FEATURE_EDGE,candidates.size());
    Collections.shuffle(candidates);
    for (int i=0; i < totalSave; i++) {
      candidates.get(i).included=true;
    }
  }
  for (  Feature3D f : featuresAll) {
    if (f.included) {
      featuresPruned.add(f);
    }
  }
}

Fixed version (ground truth):
/** 
 * Bundle adjustment can run very slow if there are too many features. This uses a heuristic explained in the code to reduce the number of 3D features by removing redundant ones. Could improve this approach by applying stricture geometric constraints that should improve the feature quality, in theory.
 */
private void pruneFeatures(){
  List<Feature3D> candidates=new ArrayList<>();
  for (  CameraMotion m : graphEdges) {
    candidates.clear();
    for (int i=0; i < m.features.size(); i++) {
      AssociatedIndex a=m.features.get(i);
      Feature3D f=m.viewSrc.features3D[a.src];
      if (f != null && !f.included && f.views.size() >= 3) {
        candidates.add(f);
      }
    }
    int totalSave=Math.min(TARGET_FEATURE_EDGE,candidates.size());
    Collections.shuffle(candidates);
    for (int i=0; i < totalSave; i++) {
      candidates.get(i).included=true;
    }
  }
  for (  Feature3D f : featuresAll) {
    if (f.included) {
      featuresPruned.add(f);
    }
  }
}
Program: 150566
Project: 150566
Buggy source:
private CameraView estimateFeatureLocations(CameraView viewRoot){
  CameraMotion best=null;
  double bestScore=0;
  Rodrigues_F64 rod=new Rodrigues_F64();
  for (  CameraMotion e : viewRoot.connections) {
    ConvertRotation3D_F64.matrixToRodrigues(e.a_to_b.R,rod);
    double score=e.features.size() * rod.theta;
    System.out.println("String_Node_Str" + score + "String_Node_Str"+ e.features.size()+ "String_Node_Str"+ rod.theta);
    if (score > bestScore) {
      bestScore=score;
      best=e;
    }
  }
  if (best == null)   throw new RuntimeException("String_Node_Str");
  viewRoot.viewToWorld.reset();
  viewRoot.distanceFromRoot=0;
  best.a_to_b.T.normalize();
  CameraView viewB=best.destination(viewRoot);
  viewB.viewToWorld.set(best.motionSrcToDst(viewB));
  viewB.distanceFromRoot=1;
  triangulateMatchedFeatures(best);
  return viewB;
}

Fixed version (ground truth):
private CameraView estimateFeatureLocations(CameraView viewRoot){
  CameraMotion best=null;
  double bestScore=0;
  Rodrigues_F64 rod=new Rodrigues_F64();
  for (  CameraMotion e : viewRoot.connections) {
    ConvertRotation3D_F64.matrixToRodrigues(e.a_to_b.R,rod);
    double score=e.features.size() * rod.theta;
    System.out.println("String_Node_Str" + score + "String_Node_Str"+ e.features.size()+ "String_Node_Str"+ rod.theta);
    if (score > bestScore) {
      bestScore=score;
      best=e;
    }
  }
  if (best == null)   throw new RuntimeException("String_Node_Str");
  viewRoot.viewToWorld.reset();
  viewRoot.distanceFromRoot=0;
  best.a_to_b.T.normalize();
  CameraView viewB=best.destination(viewRoot);
  viewB.viewToWorld.set(best.motionSrcToDst(viewB));
  viewB.distanceFromRoot=1;
  triangulateInitialSeed(viewRoot,best);
  viewsAdded.add(viewRoot);
  viewsAdded.add(viewB);
  refineScene(viewRoot,featuresAll);
  return viewB;
}
Program: 150568
Project: 150568
Buggy source:
private void retriangulateFeatures(CameraPinholeRadial intrinsic){
  TriangulateLinearDLT triangulate=new TriangulateLinearDLT();
  List<Point2D_F64> observations=new ArrayList<>();
  List<Se3_F64> worldToView=new ArrayList<>();
  WorldToCameraToPixel wcp=new WorldToCameraToPixel();
  Point2D_F64 pixel=new Point2D_F64();
  int removedCount=0;
  for (int i=featuresAll.size() - 1; i >= 0; i--) {
    Feature3D f=featuresAll.get(i);
    if (f.views.size < 3)     continue;
    observations.clear();
    worldToView.clear();
    for (int j=0; j < f.views.size; j++) {
      CameraView v=graphNodes.get(f.views.get(j));
      worldToView.add(v.viewToWorld.invert(null));
      observations.add(v.featureNorm.get(f.feature.get(j)));
    }
    triangulate.triangulate(observations,worldToView,f.worldPt);
    for (int j=0; j < f.views.size; j++) {
      CameraView v=graphNodes.get(f.views.get(j));
      wcp.configure(intrinsic,worldToView.get(j));
      wcp.transform(f.worldPt,pixel);
      Point2D_F64 observed=v.featurePixels.get(f.feature.get(j));
      if (observed.distance(pixel) > 20) {
        removedCount++;
        featuresAll.remove(i);
        break;
      }
    }
  }
  System.out.println("String_Node_Str" + removedCount);
}

Fixed version (ground truth):
private void retriangulateFeatures(CameraPinholeRadial intrinsic){
  TriangulateLinearDLT triangulate=new TriangulateLinearDLT();
  List<Point2D_F64> observations=new ArrayList<>();
  List<Se3_F64> worldToView=new ArrayList<>();
  WorldToCameraToPixel wcp=new WorldToCameraToPixel();
  Point2D_F64 pixel=new Point2D_F64();
  int removedCount=0;
  for (int i=featuresAll.size() - 1; i >= 0; i--) {
    Feature3D f=featuresAll.get(i);
    if (f.views.size() < 3)     continue;
    observations.clear();
    worldToView.clear();
    for (int j=0; j < f.views.size(); j++) {
      CameraView v=f.views.get(j);
      worldToView.add(v.viewToWorld.invert(null));
      observations.add(v.featureNorm.get(f.feature.get(j)));
    }
    triangulate.triangulate(observations,worldToView,f.worldPt);
    for (int j=0; j < f.views.size(); j++) {
      CameraView v=f.views.get(j);
      wcp.configure(intrinsic,worldToView.get(j));
      wcp.transform(f.worldPt,pixel);
      Point2D_F64 observed=v.featurePixels.get(f.feature.get(j));
      if (observed.distance(pixel) > 20) {
        removedCount++;
        featuresAll.remove(i);
        break;
      }
    }
  }
  System.out.println("String_Node_Str" + removedCount);
}
Program: 150569
Project: 150569
Buggy source:
/** 
 * Perform a breath first search to find the structure of all the remaining camrea views
 */
private void estimateAllFeatures(CameraView seedA,CameraView seedB){
  List<CameraView> open=new ArrayList<>();
  addUnvistedToStack(seedA,open);
  addUnvistedToStack(seedB,open);
  while (!open.isEmpty()) {
    System.out.println("String_Node_Str" + open.size());
    CameraView v=open.remove(0);
    System.out.println("String_Node_Str" + v.index);
    int bestDistance=Integer.MAX_VALUE;
    CameraMotion best=null;
    for (    CameraMotion m : v.connections) {
      CameraView o=m.destination(v);
      if (o.distanceFromRoot >= 0 && o.distanceFromRoot < bestDistance) {
        best=m;
        bestDistance=o.distanceFromRoot;
      }
    }
    if (best == null)     throw new RuntimeException("String_Node_Str");
    v.distanceFromRoot=best.destination(v).distanceFromRoot + 1;
    if (!determinePose(v)) {
      System.out.println("String_Node_Str");
      best.destination(v).connections.remove(best);
      v.connections.remove(best);
      graphEdges.remove(best);
    }
 else {
      triangulateNoLocation(v);
    }
    addUnvistedToStack(v,open);
  }
}

Fixed version (ground truth):
/** 
 * Perform a breath first search to find the structure of all the remaining camrea views
 */
private void estimateAllFeatures(CameraView seedA,CameraView seedB){
  List<CameraView> open=new ArrayList<>();
  addUnvistedToStack(seedA,open);
  addUnvistedToStack(seedB,open);
  while (!open.isEmpty()) {
    System.out.println("String_Node_Str" + open.size());
    CameraView v=open.remove(0);
    System.out.println("String_Node_Str" + v.index);
    if (!determinePose(v)) {
      System.out.println("String_Node_Str");
      for (      CameraMotion m : v.connections) {
        CameraView a=m.destination(v);
        a.connections.remove(m);
        graphEdges.remove(m);
      }
      graphNodes.remove(v);
      for (int i=0; i < graphNodes.size(); i++) {
        graphNodes.get(i).index=i;
      }
    }
 else {
      triangulateNoLocation(v);
      viewsAdded.add(v);
    }
    addUnvistedToStack(v,open);
  }
}
Program: 150571
Project: 150571
Buggy source:
/** 
 * J[rows,col:(col+3)] =  [a;b]*R
 */
private void addToJacobian(DMatrixSparseTriplet tripplet,int col,double a[],double b[],DMatrixRMaj R){
  tripplet.addItem(jacRowX,col + 0,a[0] * R.data[0] + a[1] * R.data[3] + a[2] * R.data[6]);
  tripplet.addItem(jacRowX,col + 1,a[0] * R.data[1] + a[1] * R.data[4] + a[2] * R.data[7]);
  tripplet.addItem(jacRowX,col + 2,a[0] * R.data[2] + a[1] * R.data[5] + a[2] * R.data[8]);
  tripplet.addItem(jacRowY,col + 0,b[0] * R.data[0] + b[1] * R.data[3] + b[2] * R.data[6]);
  tripplet.addItem(jacRowY,col + 1,b[0] * R.data[1] + b[1] * R.data[4] + b[2] * R.data[7]);
  tripplet.addItem(jacRowY,col + 2,b[0] * R.data[2] + b[1] * R.data[5] + b[2] * R.data[8]);
}

Fixed version (ground truth):
private void addToJacobian(DMatrixSparseTriplet tripplet,int col,double a[],double b[],DMatrixRMaj R,Point3D_F64 X){
  double x=R.data[0] * X.x + R.data[1] * X.y + R.data[2] * X.z;
  double y=R.data[3] * X.x + R.data[4] * X.y + R.data[5] * X.z;
  double z=R.data[6] * X.x + R.data[7] * X.y + R.data[8] * X.z;
  tripplet.addItem(jacRowX,col,a[0] * x + a[1] * y + a[2] * z);
  tripplet.addItem(jacRowY,col,b[0] * x + b[1] * y + b[2] * z);
}
Program: 150573
Project: 150573
Buggy source:
public void configure(BundleAdjustmentSceneStructure structure,BundleAdjustmentObservations observations){
  this.structure=structure;
  this.observations=observations;
  numViewsUnknown=structure.getUnknownViewCount();
  int numCameraParameters=structure.getUnknownCameraParameterCount();
  indexFirstPoint=numViewsUnknown * 6;
  numParameters=indexFirstPoint + structure.points.length * 3 + numCameraParameters;
  cameraParameterIndexes=new int[structure.cameras.length];
  int index=numParameters - numCameraParameters;
  int largestcameraSize=0;
  for (int i=0; i < structure.cameras.length; i++) {
    if (!structure.cameras[i].known) {
      cameraParameterIndexes[i]=index;
      int count=structure.cameras[i].model.getParameterCount();
      largestcameraSize=Math.max(largestcameraSize,count);
      index+=count;
    }
  }
  calibGradX=new double[largestcameraSize];
  calibGradY=new double[largestcameraSize];
}

Fixed version (ground truth):
public void configure(BundleAdjustmentSceneStructure structure,BundleAdjustmentObservations observations){
  this.structure=structure;
  this.observations=observations;
  numViewsUnknown=structure.getUnknownViewCount();
  int numCameraParameters=structure.getUnknownCameraParameterCount();
  indexFirstPoint=numViewsUnknown * 6;
  indexLastPoint=indexFirstPoint + structure.points.length * 3;
  numParameters=indexLastPoint + numCameraParameters;
  viewParameterIndexes=new int[structure.views.length];
  int index=0;
  for (int i=0; i < structure.views.length; i++) {
    viewParameterIndexes[i]=index;
    if (!structure.views[i].known) {
      index+=6;
    }
  }
  cameraParameterIndexes=new int[structure.cameras.length];
  index=0;
  int largestCameraSize=0;
  for (int i=0; i < structure.cameras.length; i++) {
    if (!structure.cameras[i].known) {
      cameraParameterIndexes[i]=index;
      int count=structure.cameras[i].model.getParameterCount();
      largestCameraSize=Math.max(largestCameraSize,count);
      index+=count;
    }
  }
  calibGradX=new double[largestCameraSize];
  calibGradY=new double[largestCameraSize];
}
Program: 150574
Project: 150574
Buggy source:
/** 
 * Check the jacobians numerically
 */
@Test public void jacobians(){
  double X[]=new double[]{0.2,0.6,2};
  for (  double p[] : parameters) {
    DerivativeChecker.jacobian(new FunctionOfPoint(p),new JacobianOfPoint(p),X,1e-4);
    DerivativeChecker.jacobian(new FunctionOfParameters(X),new JacobianOfParameters(X),p,1e-4);
  }
}

Fixed version (ground truth):
/** 
 * Check the jacobians numerically
 */
@Test public void jacobians(){
  double X[]=new double[]{0.2,0.6,2};
  for (  double p[] : parameters) {
    assertTrue(DerivativeChecker.jacobian(new FunctionOfPoint(p),new JacobianOfPoint(p),X,1e-4));
    assertTrue(DerivativeChecker.jacobian(new FunctionOfParameters(X),new JacobianOfParameters(X),p,1e-4));
  }
}
Program: 150575
Project: 150575
Buggy source:
/** 
 * Change each parameter and see if it changes the output
 */
@Test public void changeInParamChangesOutput(){
  BundleAdjustmentSceneStructure structure=createScene(rand);
  double param[]=new double[structure.getParameterCount()];
  new CodecBundleAdjustmentSceneStructure().encode(structure,param);
  BundleAdjustmentObservations obs=createObservations(structure);
  BundleAdjustmentResidualFunction alg=new BundleAdjustmentResidualFunction();
  alg.configure(structure,obs);
  double[] original=new double[alg.getNumOfOutputsM()];
  double[] found=new double[alg.getNumOfOutputsM()];
  alg.process(param,original);
  for (int paramIndex=0; paramIndex < original.length; paramIndex++) {
    double v=param[paramIndex];
    param[paramIndex]+=0.001;
    alg.process(param,found);
    boolean identical=true;
    for (int i=0; i < found.length; i++) {
      if (Math.abs(original[i] - found[i]) > UtilEjml.TEST_F64) {
        identical=false;
        break;
      }
    }
    assertFalse(identical);
    param[paramIndex]=v;
  }
}

Fixed version (ground truth):
/** 
 * Change each parameter and see if it changes the output
 */
@Test public void changeInParamChangesOutput(){
  BundleAdjustmentSceneStructure structure=createScene(rand);
  double param[]=new double[structure.getParameterCount()];
  new CodecBundleAdjustmentSceneStructure().encode(structure,param);
  BundleAdjustmentObservations obs=createObservations(rand,structure);
  BundleAdjustmentResidualFunction alg=new BundleAdjustmentResidualFunction();
  alg.configure(structure,obs);
  double[] original=new double[alg.getNumOfOutputsM()];
  double[] found=new double[alg.getNumOfOutputsM()];
  alg.process(param,original);
  for (int paramIndex=0; paramIndex < original.length; paramIndex++) {
    double v=param[paramIndex];
    param[paramIndex]+=0.001;
    alg.process(param,found);
    boolean identical=true;
    for (int i=0; i < found.length; i++) {
      if (Math.abs(original[i] - found[i]) > UtilEjml.TEST_F64) {
        identical=false;
        break;
      }
    }
    assertFalse(identical);
    param[paramIndex]=v;
  }
}