dmlfw (Daniyal Machine Learning Framework)

Core singly linked list type for double precision data. More...

#include <dmlfw_vector.h>
Include dependency graph for dmlfw_list_double.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

typedef struct __dmlfw_forward_list_double dmlfw_forward_list_double
 Opaque structure representing a forward list of double values.
 
void dmlfw_forward_list_double_clear (dmlfw_forward_list_double *forward_list)
 Removes all elements from the list.
 
dmlfw_forward_list_doubledmlfw_forward_list_double_create_new (void)
 Creates a new empty forward list of doubles.
 
void dmlfw_forward_list_double_destroy (dmlfw_forward_list_double *forward_list)
 Destroys the forward list and frees all memory.
 
dmlfw_row_vec_doubledmlfw_forward_list_double_get_row_vector (dmlfw_forward_list_double *forward_list)
 Converts the forward list into a row vector of doubles.
 
dimension_t dmlfw_forward_list_double_get_size (dmlfw_forward_list_double *forward_list)
 Returns the number of elements in the list.
 
void dmlfw_forward_list_double_insert (dmlfw_forward_list_double *forward_list, double value)
 Inserts a double value at the front of the list.
 

Detailed Description

Core singly linked list type for double precision data.

Version
1.0
Date
2025-09-25

This module provides a singly linked list (forward list) implementation for double precision floating point data. It supports creating, destroying, inserting elements, converting the list to a row vector, querying size, and clearing elements.

Error Handling:

All functions report errors through a centralized error API. Use dmlfw_error() to check for errors after each call. dmlfw_get_error_string() and dmlfw_get_debug_string() provide diagnostic messages.

Ownership:

The list owns its nodes and their double values. The vector returned by conversion functions must be explicitly freed by callers.

Typedef Documentation

◆ dmlfw_forward_list_double

typedef struct __dmlfw_forward_list_double dmlfw_forward_list_double

Opaque structure representing a forward list of double values.

The internal details are hidden to enforce encapsulation. Use the provided API functions to create, manipulate, and destroy instances.

Function Documentation

◆ dmlfw_forward_list_double_clear()

void dmlfw_forward_list_double_clear ( dmlfw_forward_list_double forward_list)

Removes all elements from the list.

Parameters
forward_list[in,out] List to clear (non-NULL).

Usage example:

char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to clear list: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
void dmlfw_get_error_string(char *error_string, uint32_t size)
Copies the last error message into the provided character buffer.
uint8_t dmlfw_error(void)
Checks if the last framework call resulted in an error.
void dmlfw_get_debug_string(char *debug_string, uint32_t size)
Copies detailed debug information about the last error into the provided character buffer.
void dmlfw_forward_list_double_clear(dmlfw_forward_list_double *forward_list)
Removes all elements from the list.
Examples
example_dmlfw_list_double.c.

◆ dmlfw_forward_list_double_create_new()

dmlfw_forward_list_double * dmlfw_forward_list_double_create_new ( void  )

Creates a new empty forward list of doubles.

Returns
Pointer to newly allocated empty list or NULL on failure.

Usage example:

char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to create forward list: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
dmlfw_forward_list_double * dmlfw_forward_list_double_create_new(void)
Creates a new empty forward list of doubles.
struct __dmlfw_forward_list_double dmlfw_forward_list_double
Opaque structure representing a forward list of double values.
Definition dmlfw_list_double.h:86
Examples
example_dmlfw_list_double.c.

◆ dmlfw_forward_list_double_destroy()

void dmlfw_forward_list_double_destroy ( dmlfw_forward_list_double forward_list)

Destroys the forward list and frees all memory.

Parameters
forward_list[in] Pointer to the list to destroy, or NULL (no-op).

Usage example:

void dmlfw_forward_list_double_destroy(dmlfw_forward_list_double *forward_list)
Destroys the forward list and frees all memory.
Examples
example_dmlfw_list_double.c.

◆ dmlfw_forward_list_double_get_row_vector()

dmlfw_row_vec_double * dmlfw_forward_list_double_get_row_vector ( dmlfw_forward_list_double forward_list)

Converts the forward list into a row vector of doubles.

Parameters
forward_list[in] List to convert (non-NULL).
Returns
Pointer to newly allocated row vector or NULL on error. Caller is responsible for destroying the returned vector.

Usage example:

char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to convert list to vector: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
// use vec...
dmlfw_row_vec_double * dmlfw_forward_list_double_get_row_vector(dmlfw_forward_list_double *forward_list)
Converts the forward list into a row vector of doubles.
void dmlfw_row_vec_double_destroy(dmlfw_row_vec_double *vector)
Destroys a row vector and frees its memory.
struct __dmlfw_row_vec_double dmlfw_row_vec_double
Opaque structure representing a row vector of doubles.
Definition dmlfw_vec_double.h:92
Examples
example_dmlfw_list_double.c.

◆ dmlfw_forward_list_double_get_size()

dimension_t dmlfw_forward_list_double_get_size ( dmlfw_forward_list_double forward_list)

Returns the number of elements in the list.

Parameters
forward_list[in] List to query.
Returns
Number of elements or 0 if list is NULL.

Usage example:

char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to get list size: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
printf("List size: %u\n", size);
dimension_t dmlfw_forward_list_double_get_size(dmlfw_forward_list_double *forward_list)
Returns the number of elements in the list.
uint32_t dimension_t
Represents the size or dimension of a data structure (uint32_t).
Definition dmlfw_types.h:26
Examples
example_dmlfw_list_double.c.

◆ dmlfw_forward_list_double_insert()

void dmlfw_forward_list_double_insert ( dmlfw_forward_list_double forward_list,
double  value 
)

Inserts a double value at the front of the list.

Parameters
forward_list[in,out] List to insert into (non-NULL).
value[in] Value to insert.

Usage example:

char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to insert value: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
void dmlfw_forward_list_double_insert(dmlfw_forward_list_double *forward_list, double value)
Inserts a double value at the front of the list.
Examples
example_dmlfw_list_double.c.