Function genann_copy

Synopsis

#include <genann.h>

genann * genann_copy(genann const *ann)

Description

Returns a new copy of ann.

Mentioned in

Source

Lines 179-192 in genann.c. Line 83 in genann.h.

genann *genann_copy(genann const *ann) {
    const int size = sizeof(genann) + sizeof(double) * (ann->total_weights + ann->total_neurons + (ann->total_neurons - ann->inputs));
    genann *ret = malloc(size);
    if (!ret) return 0;

    memcpy(ret, ann, size);

    /* Set pointers. */
    ret->weight = (double*)((char*)ret + sizeof(genann));
    ret->output = ret->weight + ret->total_weights;
    ret->delta = ret->output + ret->total_neurons;

    return ret;
}





Add Discussion as Guest

Log in