{∅, {∅}, {∅, {∅}}} : Rage Against the Meat Grinder

General Category => Why Mathematics? => Topic started by: Nation of One on November 09, 2015, 07:16:50 pm

Title: Generic Programming
Post by: Nation of One on November 09, 2015, 07:16:50 pm
For the past four months I have been going through many mathematics textbooks, especially those that have incorporated the use of computer algebra systems.  I have now become curious about "algorithm-oriented" generic programming, mostly due to being inspired by Alexander Stepanov's passion for programming as a mathematical discipline. 

In the spirit of slowing down, while going through Stepanov's work (http://whybother.freeboards.org/math-diary/programming-as-mathematics/), I will leave a trail of links here that I can focus on.   I have a plan of sorts.

Making Sense of Iterators (http://www.informit.com/articles/article.aspx?p=25088&seqNum=3)

used book from 1999 (http://www.amazon.com/gp/offer-listing/0201309564/ref=sr_1_1_twi_pap_1_olp?ie=UTF8&qid=1447113334&sr=8-1&keywords=Generic+Programming+and+the+STL%3A+Using+and+Extending+the+C%2B%2B+Standard+Template+Library++++++By+Matthew+H.+Austern)

The C++ Standard Library: reference and tutorial (http://www.cppstdlib.com/code/)
(c.2012 updated 2nd edition implementing -std=c++11 ... nearly 1200 pages, a ponderous tome!)  - for  *h-a-r-d-c-o-r-e*  code junkie --- like a drug that keeps giving ... imagine sending this one to a jailbird ... no computer to get hands dirty ... but still could compute in one's head.  No, your honor, how 'bout I throw THIS big fat book at YOU!?   :P



Generic Programming: International Seminar on Generic Programming Dagstuhl Castle, Germany, April 27 - May 1, 1998, Selected Papers (http://www.amazon.com/gp/offer-listing/3540410902/ref=tmm_pap_used_olp_sr?ie=UTF8&condition=used&qid=&sr=)   ($4 in USA used ... $99 if imported)

(By 2017, ISO C will most likely at long last incorporate "concepts (https://en.wikipedia.org/wiki/Concept_%28generic_programming%29)" into the standard GNU GCC compiler)
Title: Generic Programming: Algebraic Concepts Library
Post by: Nation of One on November 20, 2015, 08:12:07 pm
While searching for more libraries for Abstract Algebra, I found a project here at Instigate Design (http://www.instigatedesign.com/html/open_source.html)

I noticed in this project's white papers (http://instigate.am/downloads/stl/white_paper.txt):

Quote
Stepanov's ideas had yet to evolve into the modern GP theory/methodology.  Currently there is no programming language truly supporting GP. In C++ the "generic algorithms" are defined as templates, and lacks argument checking (model compliance to concept  requirements). Concepts are defined only in documentation and models are defined by making proper interface, matching the documentation requirements. Industry and ISO/ANSI C++ team are working towards enhancement of C++ that would allow to fill this gap and provide necessary constructs for true GP in C++.

However in the meantime community has developed series of tricks for implementing all aspects of the GP without any enhancements to '98 ANSI C++ standard. Some of these tricks however require very deep understanding of Template syntax and much more complex notions than mentioned above, which complicates and slows down adoption of these methods in community and industry.

Instigate's GP technology is an attempt to summarise these tricks into a full-featured and yet simple enough set of techniques, that would allow to implement generic libraries.

After downloading the 6 gzippe  libraries to a temporary directory, I guess I will start here: Instigate Algebraic Concepts Library (http://instigate-acl.sourceforge.net/) since I am interested in the Abstract Algebra libraries.

This Instigate STL (http://instigate-stl.sourceforge.net/) page gives a little more information as far as default installation directory being /opt/instigate/stl which implies that I can experiment with the Algebraic Concepts Library by installing it at /opt/instigate/acl

This project is going on the back burner.  I do not have a firm grasp on templates and libraries yet.  I will continue to crawl.
Title: generic programming is implemented with templates
Post by: Nation of One on November 21, 2015, 05:35:56 pm
Rather than going crazy looking for libraries dealing with algebraic structures, the Boost libraries and other libraries, I will slow down so as to first get a better grasp on the standard C++ templates.

Most of what I am currently interested in is interconnected (abstract algebra, C++ templates and generic programming, and even assembly language).

I only recently even became interested in the C++ Standard Template Library, and this is because of my curiosity about what Stepanov calls Generic Programming. Now, I have acquired some heavy duty texts, and as I go through them, I have more and more questions.

I sharpen my pencil and do not hesitate to fill notebooks with notes from the Internet.  The information I am searching for will not be found on the shelves of the Barnes and Noble, so I pick up another couple blank sketch pads on sale for $9 each. 

The books I ordered and received can be referred to and read again and again, but they are often difficult, and I frequently want clarification.   

Within a few months a book will be released called Discovering Modern C++: An Intensive Course for Scientists, Engineers, and Programmers (http://www.amazon.com/Discovering-Modern-Scientists-Programmers--Depth/dp/0134383583/ref=sr_1_1?ie=UTF8&qid=1448144276&sr=8-1&keywords=gottschling+Modern+C%2B%2B) by Peter Gottschling.   

The better a foundation I build now, the more of a chance I have of being prepared for that book ... Again and again I will wonder why I bother.  If I am not trying to become a professional programmer, wouldn't I have to be madman to devote myself to learning this stuff?

I have to seriously consider that I very well may be a certain kind of madman, a mad animal surfing the learning curve of Sisyphus.  This is not a race or a game.

There doesn't have to be a purpose.

I can't be ashamed of my lack of knowledge, and I don't care if my studying and research doesn't lead anywhere.  That really doesn't matter to me.  I will look into things until I lose interest.

Now, something like the following would be a good place to take some notes from when I need a break from going through texts that may be over my head at the moment.


Here is a very clear and concise description :  We are familiar with passing value/variable into a function. Instead of passing a variable, we pass a type (such as int, double, and Point) into a template. Passing type is known as generic programming, as we can program in generic type and invoke the code using a specific type. (C++ Programming Language Template and Generic Programming (https://www3.ntu.edu.sg/home/ehchua/programming/cpp/cp8_Template.html).)

Forgive me for noting this.  Surprisingly, I never even heard the expression "generic programming" until I became interested in Stepanov after researching the mathematical roots of programming.  I'm such an outsider ...

I will not delude myself.  I experienced the university, and, other than the undergraduate foundation, I do not think that is the best atmosphere for honest learning.  I am much more comfortable studying out of genuine interest and with no ulterior motive having to do with finding gainful employment. 

It feels like insanity, but it's a harmless kind of insanity.
Title: Re: Generic Programming
Post by: Nation of One on January 02, 2016, 12:45:29 pm
I had linked to this paper in the thread on Linear Algebra (http://whybother.freeboards.org/math-diary/an-invitation-to-explore-linear-algebra/msg1630/?topicseen#msg1630), but will place it here as well since the Matrix Template Library implements the generic programming methodology.

The Matrix Template Library: A Generic Programming Approach to High Performance Numerical Linear Algebra (https://www.researchgate.net/profile/Jeremy_Siek/publication/2416540_The_Matrix_Template_Library_A_Generic_Programming_Approach_to_High_Performance_Numerical_Linear_Algebra/links/02bfe513df48b5edc9000000/The-Matrix-Template-Library-A-Generic-Programming-Approach-to-High-Performance-Numerical-Linear-Algebra.pdf?origin=publication_detailThe Matrix Template Library: A Generic Programming Approach to High Performance Numerical Linear Algebra)
Title: Re: Generic Programming
Post by: Nation of One on September 30, 2017, 01:52:35 pm
save it somewhere for later

new link (2021.12):  Stepanov:  From Mathematics to Generic Programming (http://bayanbox.ir/view/3002073151855816404/Alexander-A.-Stepanov-Daniel-E.-Rose-From-Mathematics-to-Generic-Programming-Addison-Wesley-Pearson-2015.pdf)

shared link with Concepts (http://whybother.freeboards.org/math-diary/conceptgcc-aka-gcc-6-0/) thread:  Templates and generic programming (http://whybother.freeboards.org/math-diary/programming-as-mathematics/msg7453/#msg7453)

Concrete Mathematics: A Foundation for Computer Science (https://www.csie.ntu.edu.tw/~r97002/temp/Concrete%20Mathematics%202e.pdf)

* considering a merge of these two threads in the future since the "experimental" is more and more likely leaning in the direction of some future incarnation of "The Standard."

Title: Re: Generic Programming
Post by: Nation of One on September 25, 2019, 10:19:38 pm
The ghost of Schopenhauer is laughing at us with affection.   Our message board is very much like his empty lecture halls.

The following I have only watched the first 10 minutes of, but I think the board has some memory of where I was at last so I can return when my brain is fried, when I can give some attention to those I refer to as "eggheads."   I do not mean it in a cruel way.   My paternal grandfather used the term as well.  That's where I learned the word.   

Karl Gauss, who wrote Arithmetical Investigations at age 24, would fall into this category.

Myself?  A mere mortal ... but, well, monkey see, monkey do.

Thank you, eggheads.   I will try to come up with a less "derogatory-sounding" term to describe those who I may be tempted to envy for their brains.   My grandfather set me straight a long time ago about where he felt he stood in comparison.    He could understand and apply what he was taught, but he made it clear to me that there were types of men (and women, too) who were remarkably gifted, and that he felt more comfortable working with those who were less "gifted."   

Myself, I'm not too comfortable working with anyone.   These guys below are in golden handcuffs, but at least they had been given creative freedom by their corporate masters, and it looks as though their breakthroughs belong to humanity even if they were created while a paid employee of such corporate entities.

I don't want to be a hater.   I'm leaving this here for reference should I be curious to watch the rest.

https://www.youtube.com/watch?v=iwJpxWHuZQY

Title: Re: Generic Programming
Post by: Nation of One on October 25, 2019, 04:37:00 pm
Here is a link to the code for my Generic Polynomial Calculator (https://github.com/Gorticide/Polynomial-Calculator.git)  implemented with C++ templates, featuring altered Polynomnom educational library.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *   Algebra++ :=   
 *            [abstract=="modern"]  A N A L Y S I S
 *            with  G E N E R I C  P R O G R A M M I N G 
 *            using Modern C++
 *
 *
 *   polycalc++:   polymath_generic_fields.cpp (https://github.com/Gorticide/Polynomial-Calculator/blob/master/polymath_generic_fields.cpp)
 *
 *   COMPILE:  g++ -g -Wall polymath_generic_fields.cpp -std=c++14 -o polycalc++
 *
 *   Format to Print:
 *
 *   enscript -1rG --line-numbers --portrait -p polymath_generic_fields.ps
 *            --highlight=cpp -c polymath_generic_fields.cpp
 *           
 *
 *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
 *   This version uses an obscure but novel Polynom-Nom polynomial library (https://github.com/whisperity/polynomnom)
 *  for its educational value.
 *   
 */

 :P
Title: Ch20:Ex05: Define input and output operators (<<, >>) for vector.
Post by: Nation of One on October 26, 2019, 03:48:59 am
My Weird yet Elegant Solution to a Stroustrup Exercise
Chapter 20: Exercise 5 on Acid

   Most of the work is in input operator (>>)
It's so subtle that it is elegant.   Compile, step through with debugger gdb to follow the logic.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *       G E N E R I C   P R O G R A M M I N G
 *
 *    Programming: Principles and Practice Using C++ by Bjarne Stroustrup
 *
 *    Chapter 20: Containers and Iterators
 *
 *    Exercise 5: Extra (my own original touch) === Fields Approach
 *                Algebra++ Generic Programming
 *                inspired by [Dolciani, 1964/1988] Introductory Analysis
 *               
 *      Define input and output operators (<<, >>) for vector.
 *
 *      g++ -g -Wall fraction.cpp (https://github.com/Gorticide/PPP_LAB/blob/master/ch20/fraction.cpp)  ex05_vector_io_fields.cpp (https://github.com/Gorticide/PPP_LAB/blob/master/ch20/ex05_vector_io_fields.cpp) -o ex5++
 */
Title: Re: Generic Programming
Post by: Holden on October 26, 2019, 07:13:15 am
For Dear Herr Kaspar:

 A small video I’d like to put here for you. It might amuse you or leave you cold, for I know not, how much you know and how very little I do.

https://youtu.be/y0qWHMmCY4E

In mathematical terms I might as well quote Yeats:
"But I, being poor, have only my dreams. I have spread my dreams under your feet; tread softly, because you tread on my dreams."(William Butler Yeats)

https://youtu.be/Vf7QRaoI9pE
Title: Re: Generic Programming
Post by: Nation of One on October 26, 2019, 03:48:32 pm
Thanks Holden.  That is quite mind expanding how, for the algorithmic process for digit by digit square root computation sets the number up in groups of 2, for the cube root, groups of 3 - maybe some kind of pattern is revealed for the general case.

That video is tempting.  It is good to detach from the miserable anxiety rooted in the internal demands of our stomach, our stomach = "the real world" of biological necessity, and allow the mind to experience the satisfaction of computing, focusing in on these abstact phenomena.

This baboonic machinery is skillful at bringing itself orgasmic relief, then neatly cleaning the remains of my enthusiasm with as much grace and self-acceptance as I can muster.   Orgasms may be a powerful release, revitalizing us with the delight of natural emissions, but, for the long haul, to get through the days and nights and decades, one may require far more cerebral interests.

Computing can be quite cerebrally gratifying; even though the majority find it tedious drudgery beyong the dignity of thinking human beings (our defiant troublemaker, Schopenhauer - he said that machines can be made to perform arithmetic, and so such mental tasks were considered beneath his dignity.  I find that a bit too aristocratic for my tastes; some of us find modern computing to be capable of representing and implementing some very complex and sophisticated, as well as simple, basic, and fundamental mathematical phenomena WITH COMPUTING MACHINES and the programming languages (SOFTWARE) driving the man-made intelligence in the circuitry.   

The fact that machines can be made to solve algebraic equations does not make solving such equations beneath the dignity of a thinking human being.  In fact, the "science and art" of numerics appears to be a challenging enough discipline to keep any man humble, especially when considering the architecture and the mass-scale manufacturing of such devices.

I will look into this process for finding the cube root of a decimal number by hand when I am in the appropriate state of mind or mood.  I'm in the middle of inspecting code with gdb debugger so as to demystify some of the "post C++11" coventions, such as the simple, elegant << operator for std::vector<T>, where T is the template parameter (for generic algorithm-oriented programming):

template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
{
    for (auto& a : v)
        os << a << "  ";
    return os;
}

What is the significance of the ampersand?  it's a reference to an address?  a pointer to some kind of iterator a.

In the debugger, setting a break point at line 111, I can inspect this "state" of the "computational phenomena" :

p a
means "print a" 
displays: (const int &) @0x42de70: 1

p &a
displays: (const int *) 0x42de70

p *(&a)
displays:  1

That makes sense.  print the result of "dereferencing" the address &a, that is, return the contents stored at memory address &a

When sending a itself to the output stream with os << a, it prints as 1.  Hence, when the debugger prints the value of a, it includes the address &a and the value *(&a).

on the user end, a is a, but underneath, I see that a is more technically *(&a).

This kind of reflection is how the brain goes about "getting a feel" for these semantics, which, for a life-long novice programmer take on deeper meaning the longer you stare at them, as though one may have to hypnotize oneself into detaching from the "Real World" matrix enough to focus on the methods and structures at hand.

Perhaps most of the population, not just the vulgar, but even the more refined, like the cultured, educated, artistically-and-musically inclined genius Arthur Schopenhauer, seriously underestimate the mental stimulation lurking somewhere in the midst of the tedium and everlasting attention to technical and syntactic detail.

May you stubbornly enjoy your own company, that is, be bold enough to demand the right to enjoy your own higher mental faculties.  Our most ruthless oppressor is our own stomach.  It will eat us alive if we do not tend to its demands.   Schopenhauer spelled out our existential predicament exhaustively yet simply:  the brain is an appendage to the stomach.  Our main core identity is this stomach, and its nature is "nasty" and even unpredictable, dangerous, etc.    One almost needs to consciously detach from awareness of this metaphysical snag we are in just to maintain some sanity as we lay as prey to our hungers which are the desperate and urgent state of all similar life forms.

I know it may seem insensitive to obsess about math and code while so many women, children, and men are emotional basket-cases, nervous wrecks, drinking themselves to death, in a panic/anxiety, perhaps even trapped in one of the planet's cities, all of which must be trying on the human nervous system.

We will prove not as adaptable as the machines and software we are so captivated by.

Hardware and programming languages are evolving faster than we poor hunks of meat who rely on fuucking to evolve.   :-\

I suppose we can try to grasp what we can and try to keep things in perspective.

I appreciate having been educated enough to read, write, and do a little math and programming.  The serfs from a thousand years ago were not so fortunate.    We sure are a highly educated mass of hungry mother fuuckers, no?
Title: Re: Generic Programming
Post by: Nation of One on October 27, 2019, 04:41:44 pm
Quote from: Holden
It might amuse you or leave you cold, for I know not, how much you know and how very little I do.

This aside of yours is eerily similar to a realization I had about my own growing bitterness, or, if not bitterness, at least the fertile soil for megalomaniacal seeds to take root.   Maybe I feel cursed to know how little I know.  This knowledge has completely squashed my ego.

The root of the resentment is that there seems to be some kind of cruel [yet hidden] joke being played on me.   Whereas I may, in comparison to the masses and hordes, have acquired a great deal of knowledge, in comparison to the professionals supported by corporate industry and military government, I am a mere hobbyist or enthusiast, continuing to attempt to learn simply as a strategy to avoid giving into the ambience of our world, and drinking myself to death as so many of our more sensitive "brothers and sisters" do every day, as a way of life.

Suicidal drinking as a way of life in many parts of the world.

For the moment I choose a whole lot of cheap pipe tobacco along with expensive coffee beans.   

To the point.  I can only approach this with a sense of humor, the way I expressed it to the mailman one morning:

"At least I know how little I know.  Some people are too stupid (or arrogant/egotistical) to even have an inkling of the enormity of their ignorance.   They literally could not even imagine it.

At least I can imagine how little I know in comparison to what I would like to better understand.    I am certainly no trained monkey or seal.  I do not perform tricks to amuse others.  I'm trying to learn, and this learning process feels exactly what we described as CONFUSION.

Programming languages evolve faster than human programmers.   If one wants to learn, one must be always looking things up and learning, putting what you learn into practice, even if it just a simple example.   

So, even a novice tinkerer such as myself, may come to resent the lack of understanding or respect to be found in the general population for such sublime and powerful ideas.   One becomes a freak, I suppose; and in the process, one might become more intimate with the poor monster demon that is this bundle of nerves and blood.

Maybe we may come to sympathize with our "state of being poor miserable monsters," and if this miserable monster takes delight in the struggle to learn difficult concepts, we will let him be.    In the meantime, there is still this subtle bitterness simmering beneath the surface, where those who are able to make a buck in this world may openly scorn the likes of me as a "loser" drain on social security, even though my mind is dwelling on a kind of higher ground than where their heads are at most of the time (up their as-ses).
Title: Re: Generic Programming
Post by: Holden on October 30, 2019, 08:47:52 am
Thanks Herr Kaspar for your kind post.I found this website today and will install https://www.python.org/
and will download Python 3.8 for my windows 7.

Thanks for everything. I got this link from the Book Python for Kids.

Take care.
Title: Re: Generic Programming
Post by: Nation of One on October 30, 2019, 06:40:45 pm
Please be aware that Python is written in C, and that I fully support the wise decision to start with Python.  Please do not be alarmed or put off by the quasi-religious feel of the Python community.  I had learned Python ecosystem years after learning C, and old C++098.  To be honest, Holden, I hadn't looked into Python until back in 2015 after I put the cork in the jug (my last release from the county lock-up).  I became enthusiastic about it only because of Sage (CAS) and SymPy (CAS), both built in the Pythonesque fashion.

I would only urge you to install the Anaconda Distribution as it is extremely well supported by a mysterious cult of scientists and mathematicians who maintain such computer algerba systems as SymPy.  The Anaconda installation will also give you easy access to thinks like Jupyter Notebooks should you live longer than you expect, and end up wanting a place to document your own private explorations in your own way and on your own terms.

https://www.anaconda.com/distribution/

It may help to inspire you if you approach programming-via-mathematics more akin to an illicit drug than as anything that might make you a more valued "employee."

However you are wired, I can almost promise that, if I know you even just a little, that when you write the few lines of Python code that would represent the Mathematical Concept of Summation (with a for loop), you will feel the intimate connection even as it is only on a human-level.

My recent reading of the Abram article on our varying moods has made me realize that all the math, programming, and even writing are a part of only the "human" side of "me," and that so much more of me is non-human.  I suppose that the alpha-numeric manipulating part likes to think itself the main central personality at the Control Panel of Consciousness; and while this may be in many cases true, there is the "Freudian-Jungian UNCONSCIOUS" = "Schopenhauerian WILL" = non-rational/non-human Elemental and even Inorganic aspects of "what we are."

I am sorry Holden (and others) that we may only communicate on this alpha-numeric or even sometimes algerbaic or philosophic levels - all Symbolic and therefore "human".

Maybe each of us here feels more akin to the aspects of ourselves byond the threshold of consciousness, the one Ibra refers to as Captain Howdy?   ;D

Seriously.  The Steppenwolf knows what it is, but even were I to desire to permit these non-human aspects of "me" to articulate, it would all be filtered through the particular language syntax/sematics of this human world, more accurately, this literate alphabetized segment of the greater human family of primates of which we all have been spawned.

Our attempts to cut close to the bone might be appreciated by "archeologists of our current communication medium" in the near future when we (consciousness) are no more than dust in the wind.

https://www.youtube.com/watch?v=zVokojoF_lY

I never claimed to be an academic nor a professional, and certainly never an expert; that is, I am only holding my own in these realms inside our human heads.    You will feel you are in an ocean of incomprehensible gibberish, perhaps; but your interest in horror might protect your mind from being overwhelmed or devoured by imagined incomprehensibility.

Do not fear madness.   I have lost my mind many times, and good riddens I say.

It's ok to allow a New Beginner's Mind to dwell in that tired carcass once in awhile.   Take it slow.
Title: Re: Generic Programming
Post by: Nation of One on October 30, 2019, 08:29:16 pm
Holden,
I was thinking while smoking, noting that you mentioned Windows 7, implying a 32-bit architecture.   If Anaconda does not make sense for your system, if it is anyway problematic as far as integrating web broswers and the like - along with the fact that your time to explore will be limited, so you don't want to deal with technical Microsoft-Windows-7 ISSUES when you are attempting to squeeze some mathematical elegance out of these contraptions.

So, I did a search for a guy, Farrell who wrote an interesting slim book called Hacking Math Class with Python.  It looks like you can practice right there "on-line" to get you started.

Note that I have been heavy into learning "modern" C++, and while it is elegant, is conceptually challenging.   What I mean to say that I also feel a little disoriented and must seek answers to questions at every turn.  It's just the nature of the "phenomena" I suppose.

Also, much has to do with mood.  Tonight I am wired from a day at the Food Bank where Maman experienced mixed emotions, from gratitude to shame, and I even experienced gratitude mixed with anger.   Part of me is curious about the workings of the social hierarchy on the psyches of individuals.

When gathering groceries in a food store, there is the dignity of hunting; but, at the hand out, one sits where one is told, and waits to be told what can be taken.  It's all understandable, the process.   One voluntarily seeks this out as a means to alleviate some kind of stress.

I roll with it and have fun seeing what I can make.   I have a great deal of Lentils and other beans.  You would be proud of me.   But Maman, goddamn sometimes I lose patience, she doesn't eat beans as she has "gastritus", whatever the fuuck that is.   [Forgive my tasteless and lame attempt at satire; I am aware of your stuggles in the past with the inner tubes, and I apologize if my attitude seems offensive.]   Often, especially when expressing myself here, I try to relax a little and say what I really think and feel, even if this is not agreeable to the persona we would have otherwise consciously projected.

Hence, the "relaxing of taboos" allows us to communicate more the way Merrin and All the Demons of Hell comminicated.   Now, kindly undo these straps.  [Your mother sows socks that smell!]

I better sign off before Captain Howdy goes into stand up comedian mode.   :P

My mom was crying tears of gratitude one moment, and then feeling sorry for herself later ... lots of bread, not any kind of "her style dinners."

It all helps.  I love bread.  I call it Jesus Bread.  I'm a good sport.   I try to keep things in perspective.   Mixed emotions, Holden.   That may be the trickiest part of studying anything technical such as programming.   You have to detach from the crying and psychological quagmires all around us.   Give yourself a break and block out this mad world, including the mad world where we are these stomaches always needing to eat food.   Our bodies become tired, our eyes tire.

Catch yourself in a rare mood, then pounce on it.  Seize the day, as Schopenhauer used to say.    Don't be too alarmed if you seem to shy away from others.   I really think that combining a little familiarity with programming will be invaluable to you throughout your life as you explore mathematical phenomena.   I have a feeling that many questions you have might be better expressed in mathematical terms, and translated into code ... then you observe the patterns of various inputs ... I think that you will develop your own personal relationship with programming, and you will note what kinds of things you wish to compute.    Once you know the basics, rather than becoming an expert, you can take those basics and use them for your own purposes in your own simple explorations.

I do understand how frustration "projects" can become when your animal body is being exhausted/exploited by an employer.    I can't fathom how people "volunteer" for work.   I find all kinds of committments oppressive.

Like Raul, I can honestly say that I have turned bad.    I can feel it.   I don't want to be drained.  I lose patience quickly even if it looks like I am very calm.   No.  It's just all too much.  I can't "act right."

Maybe I have gradually lost the desire to please others.   There is a certain feeling of liberation when one is resigned to just observe internal moods, taking mental snapshots of "the demon," or what just may be the most honest and authentic expression of the primal frustrations of the elemental will.

Our universe is so fragile, I mean, a few ruffians can beat my face into a pulp and break my rib cage without hardly scraping a finger, and then my entire "cosmos" is reduced to blurry vision and unbearably painful breathing.   Who am I?   What is my consciousness then but pure agony?

No wonder we are all nervous wrecks!   At any moment our skulls could be crushed.

You will each have to talk yourselves through the great darkness we are in.   You know we are each on our own in our own little heads, and our own little heads is the seat of "the world."

Profound thoughts?  or maybe just some kind of redundant mantra I made up to prpepare me for the psychological horrors in store for each and every sentient life form.  Even when we have shelter and enough food in our belly and our health, we are only as good as our last meal, and the bills/rent/etc must always be paid ... we are kept running, on and on, and we have no idea what it is that propels us.

The difference between a "housed, plugged in," psychologically stable version of "me" and the poor naked creature standing outdoors with no identity card nor access to funds nor legal residence, well, that poor devil of a stickman is the actual creature I am.

No amount of mathematical insight could spare me the shame and humiliation of being exposed naked before a crowd my animal body, or to be left without clothes out in the snow.

I am not sure how our vulnerability as individual animal creatures is handled by others.    Notice the armies and modern weaponry.  Each soldier is brainwashed to feel like a killing machine, yet underneath all the armor is one isolated psyche-as-naked-ape.

Other primates also experience social humiliation and outrage.     It's not just the human world that is "fuucked up."    I think it's all too fuucked up to think about for to long (as a whole).
Title: Re: Generic Programming
Post by: Ibra on April 19, 2020, 11:21:55 pm
Hentrich,
This is an interesting link  (https://www.reddit.com/r/cpp/comments/4ibauu/visual_studio_adding_telemetry_function_calls_to/). Micro$hit adding telemetry to the binaries. Windows 10 is basically a spying OS, but they stoop so low even to binary level.

on a different topic, what features of the "modern" C++ are you using. It looks chimera of a language since last time i tinkered with it.

Take care.
Title: Re: Generic Programming
Post by: Nation of One on April 20, 2020, 02:29:34 am
Hello Ibra!
I hope you are able to keep your head together and your wits about you.
By chimera, do you mean "an imaginary monster compounded of incongruous parts" or "an illusion or fabrication of the mind" or simply "an unrealizable dream"?

I've been using the iterators for traversing vectors, maps, lists, etc ... utilizing the begin() and end() member functions.  Most of the "fun" has been exploring tricky parts with gdb (with added Python interface .gdbinit with STL Views (http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF)).

It is within the gdb that I am able to make some sense of it.  The iterators are the new incarnation of "pointers" - a phenomenon which appeals to me for they answer the problem of traversing through a sequence.  Using gdb, you can get a little creative (and even go mad in a fun way), just satisfying your curisoity:

Iterators: how to display the item the iterator points at: print *(iter._M_current)
_______________________________________________________________________

Over the past week or so, I was using the <regex> library for text manipulation and am now going over "Numerics," a topic I am especially interested in.   I am trying to learn enough so as to rework exercises from old 1960's and 1980's texts with many novel exercises which I wish to rework using modern C++ (STL and generic programming) ... so I work in phases, a couple weeks concentrating on modern C++ and using the STL, and then a week or so on the Analysis project ...

With -std=c++17, you can access the elements in containers in a rather elegant manner using the STL containers, even when those containers hold elements that are your own homegrown types.

suppose you had a vector of pairs<int, string>:

std::vector<std::pair<int, std::string>> pairs;

After you fill the vector with pairs of {int, string}, you can access as follows:

int count = 0;
for (const auto& [i, s] : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << i << ", and the string is " << s << '\n';
}

Without that, you could just as easily write:

int count = 0;
for (const auto& p : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << p.first << ", and the string is " << p.second << '\n';
}

The vectors are very useful.  I'll be checking out a Matrix library, although I am not sure I will want to rework many of the Linear Algebra related programs I have already written unless there was a huge benefit, that is, as a learning experience ...  Actually, come to think of it, even though it was a few years ago, I did build a few programs for solving linear equations (Ax = b) using STL <vector> (https://github.com/Gorticide/Linear_Algebra/blob/master/solve/axb.cpp).  It builds the matrices from scratch as a vector<vector<Fraction> > so that the results (and the work) were printed in rational form, whcih was cool to work side by side with paper and pencil.

As for Micro$oft and Money-Oriented Programming (or even Spying-Oriented software), yes, I'm sure the merry men are continuing to do as their told to please thier masters. 

The Standard Template Library is worth tinkering with, at least with vectors.

I don't know what even motivates me to forge ahead.  What else to do but peck away ... I don't want to be entertained.  I find that sometimes I can catch these moods while working "in my own little world" where I actaully "lose myself," that is, I momentarily forget who I am ... and just become one with the task, the exploring ... the learning.

Title: Re: Generic Programming
Post by: Nation of One on April 20, 2020, 04:52:17 pm
On second thought, a resounding yes to whether it would be educationally beneficial to rework the Linear Algebra (solving Ax = b) code using the STL-oriented makeshift Matrix found in the Stroustrup text, and then the main code would become trivial, easy for a human being to follow if they are versed in the nomenclature of math textbooks.  All the details would be found in Matrix.h and MatrixIO.h, but they are worth studying since they show how the ostream<< operator is overloaded and what not.

This would replace the homegrown one I made myself, as I would wish to make it a little better as long as I would be going through the "trouble," that is, I would offer the menu to use "real" (floating point approximations) or rational (fractions).  The one I made uses my own Fraction class, the one I've been improving since 1999 after a special semester at the community college where the professor (Patricia Hines - I remember the name clearly) had us design a rather robust Fraction class (user-defined type of data structure).  I had no idea how precious that code would become to my sanity throughout my life, and it easily survived the transmutation into generic programming.  In fact, it has Pythagorean "quasi-religious" significance to me.  It has improved over the decades, but the core concepts of operations on and with fractions were there from the start. 

I agree with Pythagoras that rational numbers seem more beautiful.  Other times, maybe the decimal draction form is better.  It depends.  That machines are not capable of representing so-called "real" numbers may be a symptom of what certain radical mathematicians (Norman Wildberger |---> "Divine Proportions (https://www.researchgate.net/profile/Norman_Wildberger/publication/266738365_Divine_Proportions_Rational_Trigonometry_to_Universal_geometry/links/55b01f9308aeb92399171c29/Divine-Proportions-Rational-Trigonometry-to-Universal-geometry.pdf?origin=publication_detail)")  find to be rather fishy in Denmark.  (another can of worms)

The bottom line is that I do plan to eventually use a Matrix library rather than the vector<vector<Fraction>> approach.  I will give choice of double or Fraction, thereby utilizing the templates (the "modern" part of modern C++ is writing code using libraries that make use of the way containers and algorithms work together).  I am mostly concerned with beautifying the process, but I do not feel the code I have already created is inferior.  In fact, it will help me understand what parts are hidden in the libraries.  For instance, I will have to learn how to make use of scale() and slice(), not to mention apply().

I will have to revisit classic ideas of vectors and matrices.  So, whenever I take a break from "the math books" I can look forward to this "linear algebra project" as far as programming discipline goes.  In my own little world, this is really good news.  I mean, I appreciate that I have worked patiently through all previous 23 chapters exercises, even though I knew that chapter 24 (Numerics) was really mostly what I was interested in.  I wanted to carefully consider how the creator of C++ viewed certain mechanisms, and it has been worthwhile working through beyond chapter 17, or whatever chapter the universities are reaching in one semester.  They would have to skip huge chunks of the "graphics" chapters and jump right into the less error-prone, far more fundamental material.  I have been patiently resisting the dersire to jump directly to this chapter.

Thanks for asking.
Title: Re: Generic Programming
Post by: Holden on April 21, 2020, 01:54:34 pm
Hello Mr.Ibra,
Its nice to see you here.I hope you are safe.

Take care.
Title: Re: Generic Programming
Post by: Ibra on April 22, 2020, 01:23:24 am
Thanks Hentrich and Holden,

I am good so far. I hope you are safe too. 

I left my work on January. I worked at night shift for 8 years or more and that deteriorated my health considerably but I didn't mind that, on last December i was ordered by the masters to go into the day shift, I had argument every day with ass-kissing managers  and then i left . well "Hell is the other people" as Sartre? said.

I already missed the Syrian war train, I hope I can ride Corona train to the graveyard. I am already at my wit's end.

 I downloaded "C++ tour 2nd edition" book and I am fiddling with GCC compiler(MinGW-64) as time passing activity, at least we have some control about bits and bytes.

Quote from: Hentrich
After you fill the vector with pairs of {int, string}, you can access as follows:

int count = 0;
for (const auto& [i, s] : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << i << ", and the string is " << s << '\n';
}

Without that, you could just as easily write:

int count = 0;
for (const auto& p : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << p.first << ", and the string is " << p.second << '\n';
}

That is neat trick, reminds me of python unpacking techniques.

take care,