Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 36df0f8
  • /
  • src
  • /
  • etree.c
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:532450fa316158916d16c030e74135d55085293c
directory badge
swh:1:dir:fc46366647aa97bab54c0984791545d611abc4d0

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
etree.c
#include "types.h"
#include "global.h"
#include "constants.h"

ladel_int ladel_etree(ladel_sparse_matrix *M, ladel_symbolics *sym, ladel_work* work)
{
    if (!M || !sym || !work) return FAIL;

    ladel_int *etree = sym->etree;
    ladel_int index, row, col, next;
    ladel_int *ancestor = work->array_int_ncol1;

    for (col = 0; col < M->ncol; col++)
    {
        etree[col] = NONE;
        ancestor[col] = NONE;
        for (index = M->p[col]; index < M->p[col+1]; index++)
        {
            row = M->i[index];
            for (; row < col; row = next)
            {
                next = ancestor[row];
                ancestor[row] = col;
                if (next == NONE) 
                {
                    etree[row] = col;
                    break;
                }  
            }
        }
    }

    return SUCCESS;
}

#ifdef SIMPLE_COL_COUNTS
ladel_int ladel_etree_and_col_counts(ladel_sparse_matrix *M, ladel_symbolics *sym, ladel_work* work)
{
    if (!M || !sym || !work) return FAIL;

    ladel_int *etree = sym->etree, *col_counts = sym->col_counts;
    ladel_int index, row, col, next, ncol = M->ncol;
    ladel_int *touched = work->array_int_ncol1;
    
    for (col = 0; col < ncol; col++) col_counts[col] = 0;

    for (col = 0; col < ncol; col++)
    {
        etree[col] = NONE;
        touched[col] = col;
        for (index = M->p[col]; index < M->p[col+1]; index++)
        {
            row = M->i[index];
            if (row == col) col_counts[row]++;
            for (; row <= col && touched[row] != col; row = next)
            {
                col_counts[row]++;
                touched[row] = col;
                next = etree[row];
                if (next == NONE) 
                {
                    etree[row] = col;
                    break;
                }  
            }
        }
    }

    for (col = 1; col < ncol; col++) col_counts[col] += --col_counts[col-1];
    return --col_counts[ncol-1];
}
#endif

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API