home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.ai.fuzzy      Fuzzy logic... all warm and fuzzy-like      1,275 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 678 of 1,275   
   Dmitry A. Kazakov to All   
   Re: Fuzzy Union in C++ (1/2)   
   25 Jan 07 17:37:52   
   
   From: mailbox@dmitry-kazakov.de   
      
   On Wed, 24 Jan 2007 15:27:13 +0100, Seweryn Habdank-Wojewódzki wrote:   
      
   >> No. Let I have two different fixed-point types. One represents length in   
   >> inches another does height feet. Fixed-point formally means:   
   >>   
   >>    +, -, * and truncating division operations are exact.   
   >>   
   >> Now what is the fixed-point type of the area inches*feet [accuracy,   
   >> ranges]? What is the fixed-point type of division of height to length   
   >> [accuracy ranges]? How these permanent changes of accuracy and ranges   
   >> propagate throughout a dimensioned expression?   
   >> [...]   
   >   
   > I told you. If you have a variable that is statically constructed as   
   > variable in inches than you can convert it to foot statically e.g. using   
   > templates.   
      
   This is what I meant, the problem is unsolved, because manual conversions   
   required.   
      
   >> Sorry, this is all C++ problematic, which is really irrelevant here. In a   
   >> language with properly designed numeric types (which C++ is not) you don't   
   >> care about the machine numbers. The numeric model there is simply to   
   >> specify the range and accuracy in terms of the application domain:   
   >>   
   >> type ADC_Input is delta 0.01 range -10.0..10.0;   
   >   
   > You are wrong. What is in Ada a range for floating point type?   
      
   1. ADC_Input is not a floating point type   
   2. The range of ADC_Input is -10.0..10.0;   
      
   [...]   
   > I do not know where is a problem :-).   
      
   Everything is possible to implement in Assembler, no problem.   
      
   >> Of course it does. In physics and engineering:   
   >>   
   >> (1.0m, 3.0m, 4.0m) = (1,0, 3.0, 4.0)m   
   >   
   > But all are other types. You are not thinking in the proper way.   
   >   
   > (1.0m, 3.0m, 4.0m) is a vector or tuple of value types.   
   > (1,0, 3.0, 4.0)m is a vector or tuple of value types multiplies by   
   > value.   
      
   In your design it is so. I.e. problem unsolved, because the requirement was   
   to make the above equivalent.   
      
   >>> Static error checking. Many many error you can check in compilation time.   
   >>> The first kind it is compatibility of the types.   
   >>   
   >> C++ and Ada are statically typed languages = you CANNOT get a type error   
   >> at run time unless you circumvent the type system.   
   >   
   > E.g.?   
      
   Example of what? Of a type error? There is no type errors.   
      
   >> Meta (generic) programming = programming in terms of sets of types. It is   
   >> achievable without templates, by using class-wide subprograms.   
   >   
   > No. Especially there are constructions, like function adapters for   
   > templates, that it is impossible to construct without compilation.   
      
   I don't know what you mean. Class-wide subprogram is neither macro nor   
   template. It is subprogram defined on all members of the class.   
      
   >>> Next is to check some representation of the type.   
   >>   
   >> I don't know what this means. Why should I check type representations?   
   >> There is the type system for this.   
   >   
   > The same as in example with floating point,   
      
   That was wrong.   
      
   > what is a range in floating   
   > point or of integers on 16-bit DSP, and on 64-bit server.   
      
   Why should I care of? In 90% cases it is not program business. Rest 10% is   
   dealing with hardware protocols. In that case you define endianness, bit   
   locations, hardware address (things which C++ handles very poorly.)   
      
   >>> Next you can check it the type is derived from the other type.   
   >>   
   >> That's the type system business.   
   >   
   > No quite. Even in Java you can say:   
   >   
   > class   
   >   
   > So sometimes there is a need to check if "?" is derived from List.   
      
   Do you refer to C++ or Java? Further, "sometimes" in your examples must be   
   outside templates to make a relevant argument. I am not using templates.   
   You wished to show that type representation is essential to some checks. So   
   which checks, why, etc...   
      
   >>> For me also important is shortening the code.   
   >>   
   >> What about zip? (:-)) I saw no studies comparing templated code with   
   >> normal one. But I would expect templated code potentially longer,   
   >> sufficiently less readable and almost unmaintainable.   
   >   
   > You are wrong. You completely do not try to analyse any piece of code that I   
   > have send here. Do you remember function below?   
   >   
   > template < typename T >   
   > std::auto_ptr function () {   
   >     return std::auto_ptr ( new T );   
   > }   
   >   
   > Write it for all types not only for foo1 and foo2, for every type which will   
   > derived form basic_foo. That are possible you will know What I mean   
   > shortening the code.   
      
   Why do I need that code? I propose to shorten it down to null. BTW, I don't   
   use pointers, almost. A need to resort to pointers is another language   
   deficiency.   
      
   >> That is supposed to solve some problem. Which one? And you didn't answered   
   >> the question why X of T need to be passed to an instance of the template   
   >> Bar(T X) rather than to Bar(T X). It looks like you are fighting with   
   >> some language limitations...?   
   >   
   > Hmm... Do you know C++? I think that you do not know it.   
   >   
   > This templete shows you how to automatically NOT use "->" instead of ".".   
      
   Is it an answer to my question? Let me repeat the question:   
      
   What is the requirement to design function Bar as a template   
      
      Bar(T X);   
      
   instead of   
      
      Bar (T X);   
      
   Again what was the problem? You keep on showing me some solutions of the   
   problems I either don't have, or at least, unaware of.   
      
   >> forall A:R->[0,1] exists ~A:R->[0,1] defined as:   
   >>   
   >>    forall x in R ~A(x) = 1-A(x)   
   >>   
   >> But if you wished a non-closed numeric operation, then there would be   
   >> nothing easier. Consider multiplication: x*y is not a triangle.   
   >   
   > So? I am still do not understand where is the problem.   
      
   The problem:   
      
   Given:   
      
   1. Set representation described by OP   
   2. The set A = { (1.0, 1.0) }   
      
   Required:   
      
   Compute the set B = ~A, where ~ is defined as above.   
      
   Let me know if you need further explanations.   
      
   >>> No, but you can define statically both models, and respectively to the   
   >>> situation you can switch models.   
   >>   
   >> No you cannot, templates don't allow that. Formally you could have:   
   >>   
   >>    * : T x T -> T   
   >>   
   >> But what is needed is   
   >>   
   >>    * : T1 x T1 -> T2   
   >   
   > And what is a problem? Why you can not define multiplication of the operator   
   > that works on type T1 and have a result in type T2?   
      
   Because for some T1 the result is T1, for others it is T2. Remember, we are   
   talking about switching models. T1 is the model 1. T2 is the model 2.   
      
   >> Adding to what? To the system (code) or to the inputs (data)?   
   >   
   > Anywhere. If the system can not handle second order fuzzy sets, than in data   
   > second order will be useless.   
      
   I.e. you confirm that new input data would require system redesign.   
      
   >> Easily. The types order is induced by inherited operations. The   
   >> corresponding notation of subtyping is <:. If int inherits double's +,   
   >> then   
   >>   
   >>   int <: double in +   
   >> =   
   >>   int is a subtype of double in +   
   >> =   
      
   [continued in next message]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca