From 167980ea437881ec56186332370afcc169f2e4dd Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 14 Jun 2022 09:26:07 +0200 Subject: Update to v1.5. The update to version 1.5 is rather substantial, and introduces some minor backward-incompatibilities: * The header "#!symbols" has been replaced by "#!virtual_fields" * Multiplying polynomials using the '*' symbol is no longer supported (or, rather, the symbolic capabilities of meankondo were enhanced, and the syntax has been changed). * 'meantools exp' has been removed (its functionality is now handled by other means) * 'meantoolds derive' has been replaced by 'meantools differentiate' * The symbolic capabilities were enhanced: polynomials can now be multiplied, added, exponentiated, and their logarithms can be taken directly in the configuration file. * The flow equation can now be processed after being computed using the various "#!postprocess_*" entries. * Deprecated kondo_preprocess. * Compute the mean using an LU decomposition if possible. * More detailed checks for syntax errors in configuration file. * Check that different '#!group' entries are indeed uncorrelated. * New flags in meankondo: '-p' and '-A'. * New tool: meantools expand. * Improve conversion to LaTeX using meantools-convert * Assign terms randomly to different threads. * Multiple bug fixes --- src/array.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 3 deletions(-) (limited to 'src/array.c') diff --git a/src/array.c b/src/array.c index 11d14f7..7fb6bd8 100644 --- a/src/array.c +++ b/src/array.c @@ -1,5 +1,5 @@ /* -Copyright 2015 Ian Jauslin +Copyright 2015-2022 Ian Jauslin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -72,6 +72,14 @@ int int_array_append(int val, Int_Array* output){ return(0); } +// add a value only if it is not already present +int int_array_append_unique(int val, Int_Array* output){ + if(int_array_find(val,*output)<0){ + int_array_append(val,output); + } + return(0); +} + // concatenate int int_array_concat(Int_Array input, Int_Array* output){ int i; @@ -87,6 +95,15 @@ int int_array_concat(Int_Array input, Int_Array* output){ return(0); } +// concat but only add values that are not already present in the array +int int_array_concat_unique(Int_Array input, Int_Array* output){ + int i; + for(i=0;i0){ + printf("%d)",array.values[array.length-1]); + } + else{ + printf(")"); + } return(0); } @@ -334,6 +356,19 @@ int char_array_concat(Char_Array input, Char_Array* output){ return(0); } +// substring +int char_array_substring(Char_Array str, int begin, int end, Char_Array* substr){ + int i; + if(begin>end || begin<0 || end>=str.length){ + fprintf(stderr,"error: cannot extract a substring [%d,%d] from a string of length %d\n", begin, end, str.length); + exit(-1); + } + init_Char_Array(substr,end-begin); + for(i=begin;i<=end;i++){ + char_array_append(str.str[i],substr); + } + return(0); +} // convert to char* @@ -343,7 +378,7 @@ int char_array_to_str(Char_Array input, char** output){ for(i=0;i