diff --git a/CImg.h b/CImg.h index 9d776d6a..17c7600d 100644 --- a/CImg.h +++ b/CImg.h @@ -54,7 +54,7 @@ // Set version number of the library. #ifndef cimg_version -#define cimg_version 335 +#define cimg_version 336 /*----------------------------------------------------------- # @@ -16981,7 +16981,7 @@ namespace cimg_library { unsigned int mempos, mem_img_median, mem_img_norm, mem_img_index, debug_indent, result_dim, result_end_dim, break_type, constcache_size; - bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, need_input_copy, return_new_comp; + bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, need_input_copy, return_comp; double *result, *result_end; cimg_uint64 rng; const char *const calling_function, *s_op, *ss_op; @@ -17093,9 +17093,9 @@ namespace cimg_library { mem[29] = DBL_EPSILON; // eps mem[_cimg_mp_slot_nan] = cimg::type::nan(); // nan - // Set value property : - // { -1 = reserved (e.g. variable) | 0 = computation value | - // 1 = compile-time constant | N>1 = constant ptr to vector[N-1] }. + // Type property for each value in memory : + // { -1 = reserved (e.g. variable) | 0 = computation scalar | + // 1 = compile-time constant | N>1 = start of a vector(#N-1) }. memtype.assign(mem._width,1,1,1,0); for (unsigned int i = 0; i<_cimg_mp_slot_x; ++i) memtype[i] = 1; memtype[_cimg_mp_slot_t] = memtype[_cimg_mp_slot_x] = memtype[_cimg_mp_slot_y] = @@ -17181,7 +17181,7 @@ namespace cimg_library { // Compilation procedure. unsigned int compile(char *ss, char *se, const unsigned int depth, unsigned int *const p_ref, - const unsigned char block_flags) { + unsigned char block_flags) { if (depth>256) { cimg::strellipsize(expr,64); throw CImgArgumentException("[" cimg_appname "_math_parser] " @@ -17232,16 +17232,18 @@ namespace cimg_library { *s, *ps, *ns, *s0, *s1, *s2, *s3, sep = 0, end = 0; double val = 0, val1, val2; mp_func op; - return_new_comp = false; + return_comp = false; // Bits of 'block_flags' tell about in which code block we currently are: - // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(). + // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(), 5: is_new_variable_assignment const bool is_inside_critical = (bool)(block_flags&1), is_inside_begin = (bool)(block_flags&2), is_inside_begin_t = (bool)(block_flags&4), is_inside_end = (bool)(block_flags&8), - is_inside_end_t = (bool)(block_flags&16); + is_inside_end_t = (bool)(block_flags&16), + is_new_variable_assignment = (bool)(block_flags&32); + block_flags&=31; // Deeper calls to 'compile()' won't automatically pass 'is_new_variable_assigment=true' // 'p_ref' is a 'unsigned int[7]' used to return a reference to an image or vector value // linked to the returned memory slot (reference that cannot be determined at compile time). @@ -17266,30 +17268,23 @@ namespace cimg_library { // Look for a single value or a pre-defined variable. int nb = 0; - s = ss + (*ss=='+' || *ss=='-'?1:0); + is_sth = *ss=='-'; + s = ss + (*ss=='+' || is_sth?1:0); if (*s=='i' || *s=='I' || *s=='n' || *s=='N') { // Particular cases : +/-NaN and +/-Inf - is_sth = *ss=='-'; if (!cimg::strcasecmp(s,"inf")) { val = cimg::type::inf(); nb = 1; } else if (!cimg::strcasecmp(s,"nan")) { val = cimg::type::nan(); nb = 1; } - if (nb==1 && is_sth) val = -val; - } else if (*s=='0' && (s[1]=='x' || s[1]=='X')) { // Hexadecimal litteral - is_sth = *ss=='-'; - if (cimg_sscanf(s + 2,"%x%c",&arg1,&sep)==1) { - nb = 1; - val = (double)arg1; - if (is_sth) val = -val; - } - } else if (*s=='0' && (s[1]=='b' || s[1]=='B')) { // Binary litteral - is_sth = *ss=='-'; + } else if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]!='-') { // Hexadecimal literal + cimg_uint64 num; + if ((nb = cimg_sscanf(s + 2,"%lx%c",&num,&sep))==1 || (nb==2 && sep=='%')) + val = (double)num; + } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && s[2]!='-') { // Binary literal variable_name.assign(65); - if (cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep)==1) { - nb = 1; - val = (double)std::strtol(variable_name,0,2); - } - if (is_sth) val = -val; + if ((nb = cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep))==1 || (nb==2 && sep=='%')) + val = (double)std::strtoll(variable_name,0,2); variable_name.assign(); } - if (!nb) nb = cimg_sscanf(ss,"%lf%c%c",&val,&(sep=0),&(end=0)); + if (is_sth && nb) val = -val; + else if (!nb) nb = cimg_sscanf(ss,"%lf%c%c",&val,&(sep=0),&(end=0)); if (nb==1) _cimg_mp_const_scalar(val); if (nb==2 && sep=='%') _cimg_mp_const_scalar(val/100); @@ -17334,7 +17329,7 @@ namespace cimg_library { need_input_copy = true; pos = vector(imgin._spectrum); CImg::vector((ulongT)mp_Joff,pos,0,0,imgin._spectrum).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); case 'R' : if (reserved_label[(int)'R']!=~0U) _cimg_mp_return(reserved_label[(int)'R']); @@ -17756,10 +17751,10 @@ namespace cimg_library { // Assign variable (direct). get_variable_pos(variable_name,arg1,arg2); - arg3 = compile(s + 1,se,depth1,0,block_flags); - is_sth = return_new_comp; // is arg3 a new blank object? - if (is_const) _cimg_mp_check_const_scalar(arg3,2,0); arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; + arg3 = compile(s + 1,se,depth1,0,block_flags|(arg1==~0U?32:0)); + is_sth = return_comp; // is arg3 a new blank object? + if (is_const) _cimg_mp_check_const_scalar(arg3,2,0); if (arg1==~0U) { // Create new variable if (is_vector(arg3)) { // Vector variable @@ -17804,7 +17799,7 @@ namespace cimg_library { } else // Scalar CImg::vector((ulongT)mp_copy,arg1,arg3).move_to(code); } - return_new_comp = false; + return_comp = false; _cimg_mp_return(arg1); } @@ -18203,7 +18198,7 @@ namespace cimg_library { if (arg4) pos = vector(arg4); else pos = scalar(); CImg::vector((ulongT)mp_if,pos,arg1,arg2,arg3, p3 - p2,code._width - p3,arg4).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18221,7 +18216,7 @@ namespace cimg_library { if (!arg1) _cimg_mp_scalar1(mp_bool,arg2); pos = scalar(); CImg::vector((ulongT)mp_logical_or,pos,arg1,arg2,code._width - p2).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18240,7 +18235,7 @@ namespace cimg_library { pos = scalar(); CImg::vector((ulongT)mp_logical_and,pos,arg1,arg2,code._width - p2). move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18293,7 +18288,7 @@ namespace cimg_library { if (p1 && p2 && p1!=p2) _cimg_mp_return(1); pos = scalar(); CImg::vector((ulongT)mp_vector_neq,pos,arg1,p1,arg2,p2,11,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18313,7 +18308,7 @@ namespace cimg_library { if (p1 && p2 && p1!=p2) _cimg_mp_return(0); pos = scalar(); CImg::vector((ulongT)mp_vector_eq,pos,arg1,p1,arg2,p2,11,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18504,7 +18499,7 @@ namespace cimg_library { if (is_vector(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_mul,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_vector(arg1) && is_scalar(arg2)) _cimg_mp_vector2_vs(mp_mul,arg1,arg2); @@ -18526,14 +18521,14 @@ namespace cimg_library { if (is_vector(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_div_vv,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_vector(arg1) && is_scalar(arg2)) _cimg_mp_vector2_vs(mp_div,arg1,arg2); if (is_scalar(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_div_sv,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18550,7 +18545,7 @@ namespace cimg_library { if (p2>0 && (ulongT)size(arg1)==(ulongT)p2*p2) { // Particular case of matrix multiplication pos = vector(p2); CImg::vector((ulongT)mp_matrix_mul,pos,arg1,arg2,p2,p2,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } _cimg_mp_check_type(arg2,2,3,size(arg1)); @@ -18666,7 +18661,7 @@ namespace cimg_library { else CImg::vector((ulongT)mp_complex_pow_ss,pos,arg1,arg2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18900,7 +18895,7 @@ namespace cimg_library { CImg::vector((ulongT)(is_relative?mp_Joff:mp_Ioff), pos,arg1,arg2==~0U?_cimg_mp_boundary:arg2,p2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18960,7 +18955,7 @@ namespace cimg_library { arg3 = (unsigned int)mem[arg3]; pos = vector(arg3); CImg::vector((ulongT)mp_vector_crop,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19073,7 +19068,7 @@ namespace cimg_library { arg4==~0U?_cimg_mp_interpolation:arg4, arg5==~0U?_cimg_mp_boundary:arg5,p2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19251,13 +19246,13 @@ namespace cimg_library { if (p2) { pos = vector(p2); std::memset(&mem[pos] + 1,0,p2*sizeof(double)); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } else _cimg_mp_return(0); } pos = opcode[1] = p2?vector(p2):scalar(); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19410,7 +19405,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_conj,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_conj,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19429,7 +19424,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_exp,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_exp,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19440,7 +19435,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_log,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_log,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19451,7 +19446,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_cos,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_cos,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19462,7 +19457,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sin,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sin,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19473,7 +19468,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sqr,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sqr,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19484,7 +19479,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sqrt,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sqrt,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19495,7 +19490,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_tan,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_tan,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19506,7 +19501,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_cosh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_cosh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19517,7 +19512,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sinh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sinh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19528,7 +19523,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_tanh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_tanh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19832,7 +19827,7 @@ namespace cimg_library { opcode[9],opcode[10],opcode[11],opcode[12], // 11-14: dx,dy,dz,dc opcode[13]).move_to(code); // 15: boundary conditions } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19845,7 +19840,7 @@ namespace cimg_library { _cimg_mp_check_type(arg2,2,2,3); pos = vector(3); CImg::vector((ulongT)mp_cross,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19908,7 +19903,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_cumulate,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20040,7 +20035,7 @@ namespace cimg_library { opcode[22] = (ulongT)yend; opcode[23] = (ulongT)zend; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -20075,7 +20070,7 @@ namespace cimg_library { p2 = imglist[p3]._spectrum; if (p2>1) pos = vector(p2); else pos = scalar(); // Return vector or scalar result CImg::vector((ulongT)mp_da_back_or_pop,pos,p2,p1,is_pop_heap?2:is_pop?1:0).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20181,7 +20176,7 @@ namespace cimg_library { CImg::vector((ulongT)mp_date,pos,size(pos), arg1,arg1==~0U?~0U:size(arg1), arg2,arg2==~0U?~0U:size(arg2)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20292,7 +20287,7 @@ namespace cimg_library { opcode[1] = pos; opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20579,7 +20574,7 @@ namespace cimg_library { p1 = (unsigned int)cimg::round(std::sqrt((float)size(arg1))); pos = vector((p1 + 1)*p1); CImg::vector((ulongT)mp_matrix_eig,pos,arg1,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20631,7 +20626,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; pos = vector(p1); CImg::vector((ulongT)mp_vector_equalize,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20693,7 +20688,7 @@ namespace cimg_library { p2 = arg2*arg3*arg4*arg5; if (p2) pos = vector(p2); else pos = scalar(); CImg::vector((ulongT)mp_expr,pos,arg1,p1,arg2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20704,7 +20699,7 @@ namespace cimg_library { p1 = (unsigned int)mem[arg1]; pos = vector(p1*p1); CImg::vector((ulongT)mp_eye,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20925,7 +20920,7 @@ namespace cimg_library { _cimg_mp_check_type(arg1,1,2,0); pos = scalar(); CImg::vector((ulongT)mp_fsize,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -20989,7 +20984,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; if (arg2) pos = vector(arg2); else pos = scalar(); CImg::vector((ulongT)mp_get,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -21027,7 +21022,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; pos = vector(arg2); CImg::vector((ulongT)mp_vector_histogram,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -21042,7 +21037,7 @@ namespace cimg_library { } else { if (ss3!=se1) break; p1 = ~0U; } pos = scalar(); CImg::vector((ulongT)mp_image_median,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21055,7 +21050,7 @@ namespace cimg_library { } else { if (ss3!=se1) break; p1 = ~0U; } pos = scalar(); CImg::vector((ulongT)mp_image_norm,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21079,7 +21074,7 @@ namespace cimg_library { if (arg4) pos = vector(arg4); else pos = scalar(); CImg::vector((ulongT)mp_if,pos,arg1,arg2,arg3, p3 - p2,code._width - p3,arg4).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21121,7 +21116,7 @@ namespace cimg_library { std::max(p1,1U),arg3); pos = vector(arg5?p1:p1/arg3); CImg::vector((ulongT)mp_vector_index,pos,arg1,p1,arg2,p2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21165,7 +21160,7 @@ namespace cimg_library { } pos = arg6?vector(arg6):scalar(); CImg::vector((ulongT)mp_inrange,pos,arg6,arg1,p1,arg2,p2,arg3,p3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21220,7 +21215,7 @@ namespace cimg_library { } pos = vector(p1); CImg::vector((ulongT)mp_matrix_invert,pos,arg1,p2,p3,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1)) _cimg_mp_const_scalar(1/mem[arg1]); @@ -21253,7 +21248,7 @@ namespace cimg_library { arg1 = compile(ss6,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isdir,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21262,7 +21257,7 @@ namespace cimg_library { arg1 = compile(ss7,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isfile,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21281,7 +21276,7 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21356,7 +21351,7 @@ namespace cimg_library { arg1 = compile(ss + 10,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isvarname,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } } @@ -21393,7 +21388,7 @@ namespace cimg_library { _cimg_mp_check_type(arg2,2,2,p1); pos = vector(p1); CImg::vector((ulongT)mp_vector_lerp,pos,p1,arg1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21476,7 +21471,7 @@ namespace cimg_library { } pos = vector(p1*arg4); CImg::vector((ulongT)mp_map,pos,arg1,arg2,p1,p2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21506,7 +21501,7 @@ namespace cimg_library { } pos = vector(arg4*p3); CImg::vector((ulongT)mp_matrix_mul,pos,arg1,arg2,arg4,arg5,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21542,7 +21537,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_mirror,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21610,7 +21605,7 @@ namespace cimg_library { } pos = vector(wS*wD); CImg::vector((ulongT)mp_mproj,pos,arg1,wS,hS,arg3,wD,arg5,arg6,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21701,7 +21696,7 @@ namespace cimg_library { } else arg1 = 1024; pos = vector(arg1); CImg::vector((ulongT)mp_name,pos,p1,arg1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -21731,7 +21726,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_noise,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21759,7 +21754,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_normalize,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21787,7 +21782,7 @@ namespace cimg_library { _cimg_mp_check_type(arg1,1,1,0); pos = vector(4); CImg::vector((ulongT)mp_o2c,pos,p1,arg1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -21841,7 +21836,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_permute,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21976,7 +21971,7 @@ namespace cimg_library { if (arg5!=~0U) _cimg_mp_check_type(arg5,p3 + 4,1,0); pos = vector(arg1); CImg::vector((ulongT)mp_vector_rand,pos,arg1,arg2,arg3,arg4,p2,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22129,7 +22124,7 @@ namespace cimg_library { opcode[2] = (ulongT)p1; opcode.move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } else { // Image @@ -22169,7 +22164,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_reverse,pos,arg1,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22220,7 +22215,7 @@ namespace cimg_library { pos = vector(4); CImg::vector((ulongT)mp_rot2d,pos,arg1).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22261,7 +22256,7 @@ namespace cimg_library { opcode[1] = pos; opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -22327,7 +22322,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_shift,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22403,7 +22398,7 @@ namespace cimg_library { } pos = vector(arg6*p3); CImg::vector((ulongT)mp_solve,pos,arg1,arg2,arg6,arg5,p3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22428,7 +22423,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22464,7 +22459,7 @@ namespace cimg_library { } else { if (ss6!=se1) break; p1 = ~0U; } pos = vector(14); CImg::vector((ulongT)mp_image_stats,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22526,7 +22521,7 @@ namespace cimg_library { p1 = size(arg1); pos = scalar(); CImg::vector((ulongT)mp_s2v,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22563,7 +22558,7 @@ namespace cimg_library { opcode[2] = arg1; opcode[3] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22588,7 +22583,7 @@ namespace cimg_library { } pos = vector(p1 + p2 + p2*p2); CImg::vector((ulongT)mp_matrix_svd,pos,arg1,p2,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22767,7 +22762,7 @@ namespace cimg_library { } pos = vector(p3*p2); CImg::vector((ulongT)mp_transpose,pos,arg1,p2,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -22790,7 +22785,7 @@ namespace cimg_library { arg2 = s10) pos = is_comp_vector(arg1)?arg1:((return_new_comp = true), vector(p1)); + if (p1>0) pos = is_comp_vector(arg1)?arg1:((return_comp = true), vector(p1)); else { pos = scalar(); if (is_const_scalar(arg1) && is_const_scalar(arg2)) { @@ -22873,7 +22868,7 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22933,7 +22928,7 @@ namespace cimg_library { opcode[2] = p1; opcode[3] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22957,7 +22952,7 @@ namespace cimg_library { } pos = vector(p1); CImg::vector((ulongT)mp_v2s,pos,p1,arg1,size(arg1),arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -23055,7 +23050,7 @@ namespace cimg_library { opcode[0] = (ulongT)mp_vector_warp; opcode[1] = (ulongT)pos; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23127,7 +23122,7 @@ namespace cimg_library { } opcode[1] = pos = scalar(); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23228,7 +23223,7 @@ namespace cimg_library { opcode[2] = opcode._height; if (is_sth) _cimg_mp_const_scalar(op(*this)); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23363,8 +23358,9 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(code); - return_new_comp = true; + (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); + return_comp = is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization _cimg_mp_return(pos); } @@ -23385,13 +23381,17 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(code); - } else { // Vector values provided as list of items + (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); + return_comp = is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization + } else { // Vector values provided as a list of items + is_sth = true; // Can vector be defined once in 'begin()'? arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s::sequence(arg3,arg2 + 1,arg2 + arg3).move_to(l_opcode); @@ -23404,9 +23404,10 @@ namespace cimg_library { l_opcode.insert(CImg::vector((ulongT)mp_vector_init,pos,0,arg1),0); (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; - opcode.move_to(code); + opcode.move_to(!is_sth || is_inside_begin || is_new_variable_assignment?code:code_begin); + return_comp = !is_sth && is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization } - return_new_comp = true; _cimg_mp_return(pos); } @@ -23446,7 +23447,7 @@ namespace cimg_library { if (!p2) _cimg_mp_return(0); pos = vector(p2); CImg::vector((ulongT)mp_list_Joff,pos,p1,0,0,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); case 'R' : // R#ind if (!imglist) _cimg_mp_return(0); @@ -24198,7 +24199,7 @@ namespace cimg_library { // (this forces a copy to be made. Use 'same()' for cases where you may want to return 'arg'). unsigned int copy(const unsigned int arg) { const unsigned int siz = size(arg); - return_new_comp = true; + return_comp = true; if (siz) { // Vector const unsigned int pos = vector(siz); CImg::vector((ulongT)mp_vector_copy,pos,arg,siz).move_to(code); @@ -24211,15 +24212,15 @@ namespace cimg_library { // (this avoids a copy to be made when possible. Use 'copy()' to force the copy of a value). unsigned int same(const unsigned int arg) { if (is_const_scalar(arg)) return arg; - if (is_comp_scalar(arg)) { return_new_comp = true; return arg; } + if (is_comp_scalar(arg)) { return_comp = true; return arg; } const unsigned int siz = size(arg); if (siz) { // Vector - if (is_comp_vector(arg)) { return_new_comp = true; return arg; } + if (is_comp_vector(arg)) { return_comp = true; return arg; } const unsigned int pos = vector(siz); CImg::vector((ulongT)mp_vector_copy,pos,arg,siz).move_to(code); return pos; } - return_new_comp = true; + return_comp = true; return scalar1(mp_copy,arg); // Scalar } @@ -24233,14 +24234,14 @@ namespace cimg_library { unsigned int scalar0(const mp_func op) { const unsigned int pos = scalar(); CImg::vector((ulongT)op,pos).move_to(code); - return_new_comp = true; + return_comp = true; return pos; } unsigned int scalar1(const mp_func op, const unsigned int arg1) { const unsigned int pos = arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1) && op!=mp_copy?arg1: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1).move_to(code); return pos; } @@ -24249,7 +24250,7 @@ namespace cimg_library { const unsigned int pos = arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1)?arg1: arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2).move_to(code); return pos; } @@ -24260,7 +24261,7 @@ namespace cimg_library { arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1)?arg1: arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3).move_to(code); return pos; } @@ -24273,7 +24274,7 @@ namespace cimg_library { arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4).move_to(code); return pos; } @@ -24287,7 +24288,7 @@ namespace cimg_library { arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5).move_to(code); return pos; } @@ -24302,7 +24303,7 @@ namespace cimg_library { arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: arg6!=~0U && arg6>_cimg_mp_slot_c && is_comp_scalar(arg6)?arg6: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5,arg6).move_to(code); return pos; } @@ -24319,7 +24320,7 @@ namespace cimg_library { arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: arg6!=~0U && arg6>_cimg_mp_slot_c && is_comp_scalar(arg6)?arg6: arg7!=~0U && arg7>_cimg_mp_slot_c && is_comp_scalar(arg7)?arg7: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5,arg6,arg7).move_to(code); return pos; } @@ -24348,7 +24349,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,1,siz,(ulongT)op,arg1).move_to(code); else { code.insert(siz); @@ -24362,7 +24363,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1:is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_vv,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24376,7 +24377,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24390,7 +24391,7 @@ namespace cimg_library { const unsigned int siz = size(arg2), pos = is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_sv,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24405,7 +24406,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,3,siz,(ulongT)op,arg1,arg2,arg3).move_to(code); else { code.insert(siz); @@ -24420,7 +24421,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1:is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_vv,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { @@ -24437,7 +24438,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { @@ -24454,7 +24455,7 @@ namespace cimg_library { const unsigned int siz = size(arg2), pos = is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_sv,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { @@ -28395,11 +28396,13 @@ namespace cimg_library { if (is_negative || *s=='+') ++s; int err = 0; char sep; - - if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]>32) { // Hexadecimal number - unsigned int ival; - err = cimg_sscanf(s + 2,"%x%c",&ival,&sep); - if (err>0) val = (double)ival; + if (*s=='0' && (s[1]=='x' || s[1]=='X') && + ((s[2]>='0' && s[2]<='9') || (s[2]>='a' && s[2]<='f') || (s[2]>='a' && s[2]<='f'))) { // Hexadecimal number + val = (double)std::strtoll(s + 2,0,16); + err = 1; + } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && (s[2]=='0' || s[2]=='1')) { // Binary number + val = (double)std::strtoll(s + 2,0,2); + err = 1; } else if (*s>32) { // Decimal number err = cimg_sscanf(s,"%lf%c",&val,&sep); #if cimg_OS==2 diff --git a/html/header.html b/html/header.html index ecc1a89c..e5a601c5 100644 --- a/html/header.html +++ b/html/header.html @@ -23,7 +23,7 @@
Logo

- Latest stable version: 3.3.4        Current pre-release: 3.3.5 (2024/03/04) + Latest stable version: 3.3.5


diff --git a/html/header_doxygen.html b/html/header_doxygen.html index 0fc62a88..381cff27 100644 --- a/html/header_doxygen.html +++ b/html/header_doxygen.html @@ -26,7 +26,7 @@
Logo

- Latest stable version: 3.3.4        Current pre-release: 3.3.5 (2024/03/04) + Latest stable version: 3.3.5