Skip to content

Commit

Permalink
CAS Implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Repeerc committed Aug 10, 2022
1 parent b353566 commit 1d68690
Show file tree
Hide file tree
Showing 450 changed files with 119,511 additions and 410 deletions.
Binary file added Image/new2/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Image/new2/31.png
Binary file added Image/new2/32.png
Binary file added Image/new2/33.png
Binary file added Image/new2/34.png
Binary file added Image/new2/35.png
Binary file added Image/new2/36.png
Binary file added Image/new2/37.png
Binary file added Image/new2/38.png
Binary file added Image/new2/39.png
Binary file added Image/new2/4.png
Binary file added Image/new2/40.png
Binary file added Image/new2/5.png
Binary file added Image/new2/6.png
Binary file added Image/new2/7.png
Binary file added Image/new2/8.png
Binary file added Image/new2/9.png
Binary file added Libs/libcas.libcpp
Binary file not shown.
Binary file added Libs/libcas_full_stdout.libcpp
Binary file not shown.
Binary file added Libs/libkcasgui.libcpp
Binary file not shown.
Binary file modified Libs/libtommath.libcpp
Binary file not shown.
158 changes: 158 additions & 0 deletions Libs/src/khicas/Equation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// -*- mode:C++ ; compile-command: "g++ -I.. -g -c Equation.cc" -*-
#ifndef _EQUATION_H
#define _EQUATION_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "vector.h"
#include <string>
#ifndef IN_GIAC
#include <giac/giac.h>
#else
#include "giac.h"
#endif
#ifdef HAVE_LIBFLTK
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Scrollbar.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Help_Dialog.H>
#endif
#ifdef HAVE_LC_MESSAGES
#include <locale.h>
#endif
#ifndef IN_GIAC
#include <giac/giacintl.h>
#else
#include "giacintl.h"
#endif

#ifndef NO_NAMESPACE_XCAS
namespace xcas {
#endif // ndef NO_NAMESPACE_XCAS

#ifdef HAVE_LIBFLTK

Fl_Font cst_greek_translate(std::string & s);
// utility for gen embedded widget memory desallocation
void fltk_fl_widget_delete_function(void * ptr);

void Equation_cb_scroll(Fl_Widget*, void*);

// maximum "size" of symbolics displayed in an Equation (pretty print)
extern unsigned max_prettyprint_equation;
class Equation;

class Equation_Scrollbar : public Fl_Scrollbar {
public:
Equation * eqwptr;
bool vertical;
Equation_Scrollbar(int x,int y,int w,int h,Equation * ptr,bool is_vertical);
};

// Usage: in fluid, declare a Group, then make a Box with class Equation
// Make sure there is enough room in the group for the scrollbars
class Equation:public Fl_Group {
virtual FL_EXPORT void draw();
virtual FL_EXPORT int handle(int);
virtual FL_EXPORT int in_handle(int);
public:
giac::gen lastdata;
giac::gen data; // of type eqwdata or undef if empty
giac::attributs attr;
bool modifiable;
bool output_equation; // true for output equation, false for input eq
bool need_active_parse; // true if the active cell must be parsed
int xleft,ytop; // position in pixels of the origin (global shift of image)
int xsel,ysel; // begin mouse selection (PUSH event)
int xcur,ycur; // position of the cursor (RELEASE event)
int active_pos; // position of the cursor in string (active mode)
int begin_sel,end_sel; // -1 do not take care, >=0 position of sel
int clip_x,clip_y,clip_w,clip_h;
void (* cb_enter) (Fl_Widget *,void * ); // callback when enter pressed
void (* cb_escape) (Equation * ); // callback when escape pressed
void (* cb_backspace) (Equation * ); // callback when full level selected and backspace pressed
void (* cb_select) (const char * ); // callback when selection changed
Equation_Scrollbar * vscroll,* hscroll;
Fl_Menu_Bar * menubar;
Equation(int x, int y, int w, int h,const char * l=0);
Equation(int x, int y, int w, int h, const char* l,const giac::gen & g);
Equation(int x, int y, int w, int h, const char* l,const giac::gen & g,giac::attributs mya);
Equation(int x, int y, int w, int h, const char* l,const giac::gen & g,giac::attributs mya,const giac::context * contextptr);
~Equation();
void add_scroll_menu();
void deselect();
void select(); // Does not copy to clipboard
void fl_select(); // Copy selection to clipboard
void select_rectangle(int x,int y); // x,y are the end of the mouse selection
void select_up(int mode); // mode is 1 for shifted key
void select_down(int mode);
void select_right(int mode);
void select_left(int mode);
void adjust_widget_size(); // adjust widget size
void adjust_xy(); // recalculate xsel, ysel to begin top of selection
// and xcur, ycur to end bottom of selection
void adjust_xy_sel(); // same + recalc xleft
void eval_function(const giac::gen & f);
// active_search is 1 if replacing active cell, 0 for selected cell
// Active cell should always be an _EQW terminal data of type string
bool replace_selection(const giac::gen & f,bool active_search=false);
bool replace_selection_wo_save(const giac::gen & f,bool active_search=false);
void set_data(const giac::gen & g);
giac::gen get_selection();
giac::gen get_data() const;
std::string value() const;
void setscroll();
void deselect_and_activate();
void desactivate_and_select();
void insure_something_selected(bool selectall=false);
bool handle_key(unsigned char c,giac::gen * act);
bool handle_text(const std::string & s,giac::gen * act);
bool handle_text(const std::string & paste_s_orig);
void remove_selection();
giac::gen * set_active(int x,int y); // activate cell at position x,y
// return a pointer to the active cell giac::gen or 0
bool parse_desactivate(); // if false nothing was active, else select
void replace_down_left_activate(const giac::gen & g);
int undo_history_pos; // current position in eqw history
void save_data(); // save data to undo history
void rcl_data(int dpos); // move from dpos in history and rcl data
// keep undo operations max_history_size times in undo_history
giac::vecteur undo_history;
bool is_selected(bool inside=false,bool active_search=false);
void resize(int x, int y, int w, int h);
};

void Equation_eval_callback(const giac::gen & evaled_g,void * param);

// initialize to the inner form of a null active string
giac::gen Equation_nullstring();
giac::gen Equation_nullstring(const giac::attributs & a,int windowhsize,const giac::context * contextptr);
giac::gen Equation_nullhistlevel();
// function used internally
void Equation_select(giac::gen & g,bool select,bool active_search=false);
giac::gen Equation_compute_size(const giac::gen & g,const giac::attributs & a,int windowhsize,const giac::context * contextptr);
giac::eqwdata Equation_total_size(const giac::gen & g);
// Equation_translate(giac::gen & g,int deltax,int deltay);
void Equation_vertical_adjust(int hp,int yp,int & h,int & y);
bool Equation_find_vector_pos(giac::const_iterateur it,giac::const_iterateur itend,int & i,int &nrows);
// return -1 if not in a multistring, position otherwise
int in_multistring(const giac::gen & data,giac::vecteur * & vptr);
int in_multistring(const giac::gen & data);
void handle_newline(Equation * eqwptr);
// return a pointer to the selected object
// it will modify g if for example a subsum of a sum is selected
giac::gen * Equation_selected(giac::gen & g,giac::attributs & attr,int windowhsize,giac::vecteur & position,bool active_search,const giac::context *);

// return a variable from the list of vars
bool select_user_var(int dx,int dy,giac::gen & ans,const giac::context * contextptr);

#endif // HAVE_LIBFLTK

#ifndef NO_NAMESPACE_XCAS
} // namespace xcas
#endif // ndef NO_NAMESPACE_XCAS

#endif // _EQUATION_H
106 changes: 106 additions & 0 deletions Libs/src/khicas/alg_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// -*- mode:C++ ; compile-command: "g++ -I.. -g -c alg_ext.cc" -*-
/*
* Copyright (C) 2001,2014 B. Parisse, Institut Fourier, 38402 St Martin d'Heres
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GIAC_ALG_EXT_H
#define _GIAC_ALG_EXT_H
#include "first.h"

#include <string>
#include <map>
#include "global.h"

#ifndef NO_NAMESPACE_GIAC
namespace giac {
#endif // ndef NO_NAMESPACE_GIAC
class gen;
struct unary_function_ptr;
struct symbolic;

gen makeline(const gen & a,const gen &b);

bool proot_cached(const vecteur & v,double eps,vecteur & res);
bool proot_cache(const vecteur & v,double eps,const vecteur & res);

bool galoisconj_cached(const vecteur & v,vecteur & res);
bool galoisconj_cache(const vecteur & v,const vecteur & res);
vecteur galoisconj(const vecteur & v,GIAC_CONTEXT);
bool conj_in_nf(const vecteur & w,gen & g,GIAC_CONTEXT);

bool islesscomplex(const gen & a,const gen & b);
bool is_sqrt(const gen & a,gen & arg);
gen select_root(const vecteur & v,GIAC_CONTEXT);
gen in_select_root(const vecteur & a,bool reel,GIAC_CONTEXT,double eps=1e-14);
bool is_known_rootof(const vecteur & v,gen & symroot,GIAC_CONTEXT);
gen horner_rootof(const vecteur & p,const gen & g,GIAC_CONTEXT);
bool has_rootof_value(const gen & Pmin,gen & value,GIAC_CONTEXT);

gen alg_evalf(const gen & a,const gen &b,GIAC_CONTEXT);
gen approx_rootof(const gen & e,GIAC_CONTEXT);
gen common_EXT(gen & a,gen & b,const vecteur * l,GIAC_CONTEXT);
gen common_minimal_POLY(const gen & ga,const gen & gb, gen & a,gen & b,int &k,GIAC_CONTEXT);
gen algebraic_EXTension(const gen & a,const gen & v);
gen ext_reduce(const gen & a, const gen & v);
gen ext_reduce(const gen & e);
void clean_ext_reduce(vecteur & v);
void clean_ext_reduce(gen & g);
gen ext_add(const gen & a,const gen & b,GIAC_CONTEXT);
gen ext_sub(const gen & a,const gen & b,GIAC_CONTEXT);
gen ext_mul(const gen & a,const gen & b,GIAC_CONTEXT);
gen inv_EXT(const gen & a);
gen symb_rootof(const gen & p,const gen &pmin,GIAC_CONTEXT);
gen rootof(const gen & e,GIAC_CONTEXT);
extern const unary_function_ptr * const at_rootof ;
vecteur min_pol(gen & a);

// Return the signed subresultant Sturm sequence for a rational
// fraction g with respect to x
// A squarefree factorization is performed first
// Factors of even mult are discarded
// Factors of odd multiplicities generate one vecteur of dense
// polynomials (also coded as vecteur)
// The content of the numerator and denominator are returned as well
vecteur sturm(const gen &g,const gen & x,GIAC_CONTEXT);
extern const unary_function_ptr * const at_sturm ;
// Number of sign changes of g when x is inside the ]a,b[ interval
// Zeros of g of even multiplicities are not counted
// Zeros of g of odd multiplicites are counted once
// g must be a rational fraction with respect to x
// a should be < b
// If sturmab returns 0, then the sign is constant positive
// If sturmab returns -1, the sign is constant negative
int sturmab(const gen & g,const gen &x,const gen & a,const gen & b,GIAC_CONTEXT);
gen _sturmab(const gen & g_orig,GIAC_CONTEXT);
gen _sturm(const gen & g,GIAC_CONTEXT);
gen _sturmseq(const gen & g,GIAC_CONTEXT);

extern const unary_function_ptr * const at_sturmab ;
int sturmsign(const gen & a,bool strict,GIAC_CONTEXT);
// find extremals values of g, return type of g (0 nothing assumed, 1 real, 2 integer)
int find_range(const gen & g,vecteur & a,GIAC_CONTEXT);
// minmax=-1 min 0 both 1 max
gen fminmax(const gen & g,int minmax,GIAC_CONTEXT);
bool find_good_eval(const polynome & F,polynome & Fb,vecteur & b);
typedef std::map<gen,gen,comparegen > rootmap;
rootmap & symbolic_rootof_list();
rootmap & proot_list();
rootmap & galoisconj_list();

#ifndef NO_NAMESPACE_GIAC
} // namespace giac
#endif // ndef NO_NAMESPACE_GIAC

#endif // _GIAC_ALG_EXT_H
Loading

0 comments on commit 1d68690

Please sign in to comment.