axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] hashing


From: Franz Lehner
Subject: [Axiom-developer] hashing
Date: Sat, 20 Oct 2007 18:43:00 +0200 (CEST)

Hello,

since hashing and remember tables came up recently,
I have a question how it works.
)set fun cache
apparently does not work on self compiled functions
and anyways it was remarked that the remember
table should be part of the function itself.
In fact it is easy to get such a function
by simply overloading 'apply' in Table
and make it update itself whenever a new
argument value is encountered.
This works quite well for recursive (noncommutative) cumulant
tables which I am currently computing,
however it is not clear to me how the Table domain works.
In
   src/algebra/table.spad.pamphlet
I see

Implementation ==> InnerTable(Key, Entry,
   if hashable(Key)$Lisp then HashTable(Key, Entry, "UEQUAL")
       else AssociationList(Key, Entry))

hashable()$Lisp is a rather mysterious function.
The only other place where it is mentioned its definition in
src/interp/spad.lisp.pamphlet:

(defun |knownEqualPred| (dom)
  (let ((fun (|compiledLookup| '= '((|Boolean|) $ $) dom)))
      (if fun (get (bpiname (car fun)) '|SPADreplace|)
          nil)))

(defun |hashable| (dom)
   (memq (|knownEqualPred| dom)
   #-Lucid '(EQ EQL EQUAL)
   #+Lucid '(EQ EQL EQUAL EQUALP)
   ))

Trying it out interactively gives no clue for me either,
apparently it is not a Boolean function.
My table now has 18000 entries and further calculations
are rather slow, therefore I suspect that my key
(which is a custom domain) is not "hashable"
and therefore an AssociationList is used instead of a HashTable.
This leads to my questions:
1. Which domains are hashable?
2. does the "hash" function have anything to do with this?
   However hash returns 0 anyways for most domains I tried.
3. How do I make my key domains hashable?

best regards,
Franz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]