field element    
   sagemath code to find out the element is finite field element.
add a comment
code to find if element in finite field
def is_element_in_finite_field( something ):
    try:
        parent = something.parent()
        if parent.is_field() and parent.is_finite():
            return True
        return False
    except Exception:
        return False
test
sage: is_element_in_finite_field( 2018 )
False
sage: is_element_in_finite_field( GF(2017)(2018) )
True
sage: is_element_in_finite_field( QQ(2018) )
False
sage: is_element_in_finite_field( factorial(17) )
False
sage: F.<a> = GF(2048)
sage: is_element_in_finite_field( F.random_element() )
True
quapla
Asked: 2018-03-14 14:06:08 +0100
Seen: 165 times
Last updated: Mar 14 '18
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.