Compare commits

...

2097 Commits

Author SHA1 Message Date
3a9dcf1fea Sculpt Branch:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r25245:25315
2009-12-11 14:38:02 +00:00
912877f290 UV Editor: added proportional edit buttons to the header. 2009-12-11 14:34:21 +00:00
b056f8eeba Fix small mem leak in wm_window_get_size_ghost 2009-12-11 14:25:37 +00:00
fb28896cf7 * added an armature submenu where python defined armatures can go.
* bpy.utils.display_name(), which makes filenames and module names look nicer in menus eg... /home/me/foo_bar.py  --> "Foo Bar"
* missing rna_path --> data_path renaming
2009-12-11 14:16:59 +00:00
c6ffe23762 Sculpt Branch:
* Added detection if VBO extension is supported.
* Redraw other 3d views after sculpting.
* Fix brush sometimes punching through mesh with very small polygons,
  added an extra epsilon to the ray-triangle intersection.
2009-12-11 14:16:17 +00:00
fba99b627b Timeline Drawing Tweaks:
* Made the TimeLine current frame indicator get drawn using the standard frame-indicator code. Also, it is now possible to show the frame indicator box beside the line as in the other animation editors, although this is disabled in the timeline due to the closeness of the frame number field.

* Removed some old (unnecessary) code
-> "Continue Physics" option in TimeLine, which is now obsolete with the current physics options. Feel free to restore if this is not the case.
-> Already commented out hacks to create "speed ipo" for curves. There are easy alternatives that are better integrated.
-> Unused init/exit callbacks for scrubbing time, since those were only used to set an obsolete flag for timeline drawing that is now used for the indicator.

* Switched long-keyframe optimisation code to use constants instead of some magic numbers + fancy trickery...
2009-12-11 11:18:55 +00:00
89b6d94e38 Sculpt Branch: multires conversion from 2.4 working again. 2009-12-11 10:56:20 +00:00
7e7e1018ac Added back rendered animation playback (in a sense), with a
customisable player.

You can choose a player in User Preferences -> File Paths. You can 
choose a plan custom command line, otherwise there are presets available
for the Blender 2.4 player or DJV (where it will give it the correct filename, 
fps, etc on the command line). So for example if you have a Blender 2.4 
version installed, you can enter the path to the blender 2.4 executable, 
and the playback will work just like before.

Any info on other frame players (FrameCycler? pdplayer?) and their 
command line settings could be useful for adding some more presets too, 
if anyone knows of them.

It's available in Render->Play Rendered Animation (Ctrl F11)
2009-12-11 08:05:05 +00:00
877c47fe35 Fix for [#20331] adding and removing render layers in specific sequence creates layers with the same name
Render layers now use the same consistent 'unique name' function as other parts of Blender (i.e. RenderLayer.001). Updated the defaults for consistency.
2009-12-11 05:23:00 +00:00
34ec7474fd Tweak to make temp 'fullscreen' screens be alphabetically similar to the previous ones that spawned them, so you can switch screens (ctrl left and right arrow) more smoothly ( [#20301] Screens and Fullscreen still doesn't work ) 2009-12-11 04:03:55 +00:00
d6bee7da75 use rna buttons for color ramps colors so keyframes can be added/deleted. 2009-12-11 02:14:10 +00:00
5244b7c21b Various UV editor / notifier related fixes:
[#20336] Missing notifier - properties view does not update on UV unwrap
[#20337] Shift select is not working in UV-editor island mode
[#20338] Update automatically menu item has strange icon behavior
[#20339] Select all will quit working in UV editor
2009-12-11 01:12:22 +00:00
cff8de339d [#20288] FBX exporter fails
* disallow registering operators that have properties starting with an underscore which caused this problem.
2009-12-11 00:51:14 +00:00
98dff9b1c7 For for [#20330] Can't open a file made in 2.49
Hair clothsim internal_friction wasn't being initialised correctly.
2009-12-11 00:09:58 +00:00
8b32402f38 * root bone override fixed
* delta was disabled
* simple copy metarig type
* proper exception when a type isnt found
2009-12-10 23:24:31 +00:00
5a0436b8ea Double Click plays nicer with Click.
1) Double Click takes priority over a second Click (Click will still be send if not handled)
2) The first Click being handled doesn't stop the following Double Click
2009-12-10 23:24:29 +00:00
ab7e9da342 wm_menu_invoke calls exec automatically if property is already set.
This way you can set the param in the keymap and it won't always show the menu for nothing.
2009-12-10 23:22:43 +00:00
97abf6ad96 * rename 'rna_path' --> 'data_path', rna and dna are for internal use and are not descriptive.
* armature.pose_position: POSE_POSITION, REST_POSITION --> POSE, REST
* rigify now forces rest pose mode
* updated neck_flex to keep original bones unchanged
2009-12-10 22:23:09 +00:00
2a785e8fae Snap options were reset too often, discarding all user options. 2009-12-10 22:07:33 +00:00
8f2db59253 Netrender: categories and balancing by categories based on usage. Enables grouping of jobs in a single priority group. Jobs in the same category are still ordered by cluster usage. 2009-12-10 18:56:21 +00:00
2576268fb8 missed a header last commit, added custom exceptions to rigify so they can be caught and converted into reports and have normal errors display the stack trace as useual. 2009-12-10 18:28:22 +00:00
0779f2c425 Double Click event value.
Timeout between both clicks is user configurable, should be taken from the OS when possible.
2009-12-10 17:41:03 +00:00
e7bd63c128 Sculpt Branch:
* Multires 2.50 -> Branch compatibility code converting to the new
  displacement format. 2.49 -> 2.50 is not functional yet.
2009-12-10 17:37:04 +00:00
0cc5d50d91 operator report function so python operators can report errors
TODO - reports are currently shown upside down.
2009-12-10 16:52:44 +00:00
959ac68914 align option for split 2009-12-10 14:47:07 +00:00
5c5ec6f0a7 fix for some errors and local root bone override 2009-12-10 14:32:37 +00:00
acadb8c39f Sculpt Branch:
Revised external multires file saving. Now it is more manual in that you
have to specify where to save it, like an image file, but still saved at
the same time as the .blend. It would ideally be automatic, but this is
difficult to implement, so for now this should at least be more reliable.
2009-12-10 14:26:06 +00:00
aaa181818e missed editing the sample rigs, Cessen likes palm_curl.py better 2009-12-10 13:45:16 +00:00
e93c0e4ecf renaming metarig types since we may well have multiple arm/finger/leg types 2009-12-10 13:34:21 +00:00
b259efe2d7 UI limits for the envalope frame were too small 2009-12-10 13:20:31 +00:00
6e6e675191 move generic functions out of rigify's __init__.py into rigify_utils.py since rigify its self does not use them, only some of the metarig types. 2009-12-10 12:58:03 +00:00
f26e188a7c - rigify context changes & example for delta
- sequencer transform had 0.0 for rotation minimum
- missed icon rename in last commit
2009-12-10 11:56:31 +00:00
901962c621 return value was included in the list of optional args for function-rna error message 2009-12-10 11:20:43 +00:00
11ca70b42d Update Handling: moved wm_data_handle_update from windowmanager to
scene_update_tagged in blenkernel, code fits better there.
2009-12-10 11:08:38 +00:00
6b7544bfda Durian Request: Default F-Curve Auto-Colour Modes
Added option to KeyingSets+Keyframing Functions which makes newly added F-Curves for Transforms + Colours to use the colour mode which uses the array index to determine the colour of the F-Curve. 

The main implication of this is that when this option is enabled for a KeyingSet, all sets of XYZ F-Curves (i.e. location, rotation, scale) for transforms will be shown in Red/Green/Blue instead of some automatically determined "rainbow" colour. Useful for animators far too used to Maya's Graph Editor :P

This setting is named, "XYZ to RGB", though that doesn't make its purpose entirely clear.
2009-12-10 10:40:28 +00:00
9358af05d0 rename operators TFM_OT_* --> TRANSFORM_OT_* 2009-12-10 10:36:32 +00:00
b5740b0e77 remove ICON prefix from the enum, for python this is redundant eg.
layout.prop("setting", icon='ICON_BLAH_BLAH')

Also reverted previous commit, the cursor subtype just needed to be added to the switch statement.
2009-12-10 10:23:53 +00:00
9c5019a9a9 Notifier related fixes:
[#20319] 3D View - need 3D cursor notifier
[#20321] Views not receiving the NC_ID notifier
2009-12-10 09:58:10 +00:00
7fcb5d33ff values that had units set would not be coerced into Mathutils types by the python api.
eg. scene.cursor_location wasnt a vector
2009-12-10 09:38:58 +00:00
24be31bda0 Fix for [#19776] Header bar problem in 2.5
Prevents dragging region edges outside area boundaries or into other regions.
2009-12-10 09:25:30 +00:00
900165bc72 raise an error when adding/removing editbones when the armature is not in editmode (without this blender crashes) 2009-12-10 08:54:16 +00:00
4bcb759c94 Attempted fix for [#19810] Crash when flipping header with F5 2009-12-10 05:05:04 +00:00
64c29743c3 Fix for [#20153] Scale region size from search crashes Blender 2.5 24999 2009-12-10 03:07:04 +00:00
a4e4d0f658 Fix for [#20140] Double Properties Panel on 3dview from 2.4x fles 2009-12-10 02:43:55 +00:00
985c24b0f1 Fix for 'Copy materials to selected' button freezing when using linked geometry 2009-12-10 01:30:47 +00:00
653593b574 Fix for [#20216] Search List is unordered
This sorts RNA collection (bones, vgroups, etc) search lists alphabetically like ID data search lists are already.
2009-12-10 01:29:43 +00:00
Nathan Letwory
ef8706c4ea wrong code order made linux+scons barf. 2009-12-10 01:11:04 +00:00
Nathan Letwory
11af0ff270 * WITH_BF_RAYOPTIMIZATION cleanup and flag separation by matd.
This adds BF_RAYOPTIMIZATION_SSE_FLAGS through which one can manage
  what SSE flags are best for the platform built for.

  Note that the ray optimizations coded by jaguarandi are SSE-intrinsics only.
2009-12-10 00:51:13 +00:00
ee12451463 Revert bunch of changes I should have committed before. 2009-12-10 00:41:03 +00:00
456c11c822 textedit string needs to be one byte longer than maxlen, for terminator. 2009-12-10 00:28:18 +00:00
ce65569708 MSVC 9 projectfiles
* added missing header BKE_sequence.h
* moved source folder back to correct place (was inside headers folder)
2009-12-10 00:20:19 +00:00
3e43a3f727 Fix notifiers for object active material selection 2009-12-09 22:58:08 +00:00
22643b12e8 show_handles property didn't flip bool properly.
Patch by DustyDingo on irc.
2009-12-09 22:54:25 +00:00
3535be3f6f patch from Cessen, tweaks and fixes to metarig elements 2009-12-09 22:44:26 +00:00
30fd13387d give IDPropertyGroups's an identifier so they can display text in the listview, hardcoded to "name" 2009-12-09 22:37:02 +00:00
80bd73639f Patch [#20290] by Bjørnar Hansen for bug [#20270] 2.5a0, Select Random says percent but is really 0-1 2009-12-09 21:42:21 +00:00
c16acaff8b Sequencer fix: Transform Strip wouldn't work with default_fader
* added default_fader to transform strip, since it used the old fac too.
* removed ANIMATEABLE attribute from the settings in the transform strip, since they are animated via the effect_fader and not directly for now. (too confusing)
* UI: only show default_fader for the effect strips that support it

Sequencer Durian feature: uniform scale for Sequence transform strip.
* for now re-using variable for x-axis scaling.

Note: This brings back functionality as close to 2.49 as possible. The Start and End values in the current design are not meant to be animated directly, but via the effect_fader.
2009-12-09 20:03:08 +00:00
664f2d834a Fix #20305: overlay blending mode for specular intensity does not work. 2009-12-09 19:41:27 +00:00
1d9eb1e0a0 Invalid return type 2009-12-09 18:47:52 +00:00
177e27ea4b MSVC 9 projectfiles
* quick updates for bpy_driver.c
2009-12-09 18:38:55 +00:00
1d53b78036 Fix compile problem (warnings are important) 2009-12-09 18:08:14 +00:00
1601f297c9 Fix #20245: datablock names allowed entering 22 characters but can
only accept 21.
2009-12-09 18:03:44 +00:00
e68dff3e76 Move libpython.a to COMLIB (before was PULIB). 2009-12-09 17:53:52 +00:00
b4d8d51a26 Fix for bug #20307: snapping in uv editor is related to objects origin.
Also updated image window header to use snap element property.
2009-12-09 17:32:54 +00:00
9e7bb2de8f Fix bug #20299: bilateral blur node crashes when the number of
iterations is rapidly changed.
2009-12-09 17:18:39 +00:00
00b8e65f0a very very bad hack to have sequencer strips fcurve data transform with them.
ifdef'd so its not kept in by accident.
Committing because without this animating with the sequencer isnt really usable and am not interensted in having many patches applied on artists systems.
2009-12-09 16:46:41 +00:00
2cc8ef127e added collection sequences_all so strips within meta's can be animated 2009-12-09 16:00:53 +00:00
6639ba6b86 Sculpt Branch:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r25180:25245
2009-12-09 15:24:55 +00:00
8df3e7b54c Sculpt Branch:
* Fallback code in case VBO allocation fails.
2009-12-09 15:20:47 +00:00
daf043b3fe if bone type root is defined, all new parentless bones become children of it 2009-12-09 15:13:03 +00:00
f54776b1a6 VBO:
* Fix #19785: curves not drawing with VBO enabled
* Fix #19553: duplicate Window crashes with VBO's

The convention in Blender was to have GL_VERTEX_ARRAY and GL_NORMAL_ARRAY
enabled by default, and other arrays disabled. The VBO drawing code did
not take this into account. I've made these now disabled by default, since
that makes the code clearer in other places too.
2009-12-09 14:37:26 +00:00
5dd68e8cb6 some more rig options, fix typo 2009-12-09 14:29:55 +00:00
a41131db24 - added editbone.matrix, readonly, utility property that calculates the matrix from the bone roll
- spine fixes
- arm now uses the average Z axis to place the poll target
2009-12-09 14:25:56 +00:00
9ea765e5d3 Sculpt Branch:
* Smooth brush works again for multires.
* Optimal Display option for multires modifier, same as subsurf.
2009-12-09 13:37:19 +00:00
d6c583cc54 - use the bone that the type was set for automatic assigned blending property (when blending 2 chains)
- delete the type property from the generated rig so running again wont confuse things
2009-12-09 12:36:13 +00:00
0e713ba1d0 - rewrote arm rig so it creates 2 chains and blend them automatically (like the leg)
- use reverse order for palm fingers (pointer first)
- allow copying bone class instances to exclude some bones
- doc generation had a python error (incedently updated online docs linked from the splash)
2009-12-09 12:00:28 +00:00
9bc23bd616 Whoops, silly typo 2009-12-09 11:38:32 +00:00
abae1e2ccf Sculpt Branch: sculpting with modifiers and shape keys working again. 2009-12-09 11:09:56 +00:00
3712e78d52 RNA: fix for yesterday's commit, browsing screens and scenes was
not working anymore, relies on special notifiers.
2009-12-09 10:55:28 +00:00
9b6b74f292 Various more screen-related fixes including:
[#20271] File Browser - Wont show when area is fullscreen
2009-12-09 06:55:16 +00:00
bc79569419 grabcursor attribute stores full grab mode so we can better differentiate when it needs to wrap around cursor draw.
Also add cocoa exception to wm_get_cursor_position (this should be fixed at the ghost level)
2009-12-09 04:51:35 +00:00
1c47b3acb6 Fix for [#20197] dof node bugs
This is still a bit dodgy, the issue of accessing scene data from nodes needs to be solved better, but this at least fixes it up to previous capabilities, and prevents writing any data to scene/objects either.
2009-12-09 02:55:19 +00:00
f626b2c4dd Minor fix for missing menu 2009-12-09 01:53:51 +00:00
2ef0ee76a0 Fix for [#20249] duplicating a mesh in edit mode with a lattice modifier
Removed lattice and curve modifiers from being correctable for crazy space - it didn't work and was giving weird results.
2009-12-09 01:53:04 +00:00
e9b417c1bf auto-dist working again, renamed obofs --> dyn_ofs, use_sel --> use_dyn_ofs, since its used by Auto-Depth too. 2009-12-09 00:45:50 +00:00
fabdde675a reference to INDIVIDUAL_CENTERS causing error 2009-12-09 00:03:18 +00:00
bee5775702 split out driver functions into its own file 2009-12-08 22:35:03 +00:00
96a5db9a4c setting and editbone parent to NULL wasnt working 2009-12-08 20:58:23 +00:00
47b4c8357c Attempted Bugfix: opengl preview render artifacts, was using wmPush/PopMatrix,
but this does not have an actual stack, so using glPush/PopMatrix instead now.
2009-12-08 19:27:30 +00:00
7f580d0734 transforming metastrips didnt move effects within them & remove warning 2009-12-08 19:27:19 +00:00
1c9da5fe2c 2.5 User Preferences:
* Massive Code Cleanup, still not "Layout Code Guidelines" conform, but much better.

* Commented out buttons that don't work yet, like translation buttons.
* Some minor shuffling around of buttons in "System" Tab. William: Feel free to modify that, still some room for improvements. :)
2009-12-08 19:08:35 +00:00
7e333010f3 Animation System: Handling Updates
* Added ANIM_list_elem_update and ANIM_id_update functions to call when
  changing animation curves, which will then call the RNA property update
  functions for those curves.

  This is to replace just calling DAG_id_flush_update, that may not always
  be the right thing to do, and doesn't send proper notifiers for redraw.

  Still only used/usable when transforming in the graph editor, not sure
  how this do this with NLA for example, .. needs to be improved.

* Added function wm_data_handle_update function to contain the object
  update function, and also added scene animation update there. Actually
  it should be doing all datablocks, this makes it work for sequencer.


Joshua, do you agree this is the right direction to go in? I can revert or
change the code if you think it should be done differently. Mainly wanted
to get this working well for sequencer now.
2009-12-08 18:28:09 +00:00
445e4c9a8c Sequencer: comment out unimplemented operator to avoid error print. 2009-12-08 18:09:08 +00:00
1b3a295e4f RNA functions to find keymaps in a keyconfig (from the usual idname + space or modal keymaps from operator id) 2009-12-08 18:02:50 +00:00
278fc187cf Image Paint keymap in image editor wasn't looked up with the space type. 2009-12-08 17:37:31 +00:00
07904712e8 RNA:
* Property update functions no longer get context, instead they get only
  Main and Scene. The RNA api was intended to be as context-less as
  possible, since it doesn't really matter who is changing the property,
  everything that uses the property should be updated.
* There's still one exception case that use it now, screen operations
  still depend on context too much. It also revealed a few places using
  context where they shouldn't.
* Ideally Scene shouldn't be passed, but much of Blender still depends on
  it, should be dropped when we try to support multiple scene editing.

Change was planned for a while, but need this now to be able to call
update without a context pointer.
2009-12-08 17:23:48 +00:00
ee74e720a8 - modify for Cessens updated spine
- Neck example didnt account for some possible problems when linking to the body
- foot IK were referencing the wrong bones
- updated some example rigs
- graph constraint arrow direction was incorrect
2009-12-08 17:00:53 +00:00
7235e681b9 slow print, only debug mode 2009-12-08 16:39:00 +00:00
45509f129d unwrap was unwrapping all faces rather then just the selected ones 2009-12-08 15:20:57 +00:00
fb7fed6706 minor fixes 2009-12-08 14:02:06 +00:00
f2452c1fd6 Sequencer:
* Sound strips now respect metastrips for muting. That means they
  are muted if the metastrip is muted, and don't play when located
  outside of the current metastrip.
* Operators now use notifiers instead of redraw tagging, added a
  separate notifier for selection as well, but that is not used to
  do less redraws yet.
2009-12-08 13:57:51 +00:00
0151be0210 UI: fix trailing tooltips when deactivating window, and when opening
right click menu. Added window deactivate event for this.
2009-12-08 13:02:03 +00:00
0304b623f5 RNA: added common sequencer properties notifiers/updates. Still some
updates missing.
2009-12-08 12:59:21 +00:00
88b0e1c52a OSX: print warning if Blender application is located in a path Python lib can't handle (bug # 20258)
OSX allow file/directory names to contain ':' (displayed as '/' in Finder), and current Python lib (3.1.1) has trouble with those when importing modules.

Added warning message to help user understand why Blender start fails in this case.
2009-12-08 12:16:34 +00:00
0391b1ab78 compile python driver expressions for faster re-evaluation.
approx 15-25x speedup
2009-12-08 10:36:46 +00:00
445d077cf4 BGE: Add plot method to VideoTexture.ImageBuff class.
Synopsis: plot(brush,width,height,x,y,mode)
          plot(imgbuff,x,y,mode)

The first form uses a byte array containing the brush shape.
The second form uses another ImageBuff object as a brush.
The ImageBuff object must be initialized before you can call
these methods. Use load(rgb_buffer,sizex,sizey) method to create
an image buffer of given size (with alpha channel set to 255).
The brush is plotted directly in the image buffer. The texture
is updated only when the VideoTexture.Texture parent object is
refreshed: this will download the image buffer to the GPU.

brush:  Byte array containing RGBA data to be plotted in image buffer.
        The data must be continuous in memory, organized row by row
        starting from lower left corner of the image. Each pixel is
        4 bytes representing RGBA data in that order.
width:  Horizontal size in pixels of image in brush.
height: Vertical size in pixels of the image in brush.
imgbuff:Another ImageBuff object that is used as a brush. The object
        must have been initialized first with load().
x:      Horizontal position in pixel from left side of the image buffer
        where the brush will be plotted. The brush is plotted on pixels
        positions x->x+width-1. Clipping is performed if the brush falls
        partially outside the image buffer.
y:      Vertical position in pixel from bottom side of the image buffer
        where the brush will be plotted.
mode:   Mode of drawing. Use one of the following value:
        0 : MIX
        1 : ADD
	2 : SUB
        3 : MUL
        4 : LIGHTEN
        5 : DARKEN
        6 : ERASE ALPHA
        7 : ADD ALPHA
        1000 : COPY RGBA (default)
        1001 : COPY RGB
        1002 : COPY ALPHA

        Modes 0 to 7 are 'blend' modes: the brush pixels are combined
        with the image pixel in various ways. Refer to Blender documentation
        to learn more about these modes.
2009-12-08 10:02:22 +00:00
5132b6a173 OSX: Disable parallel openMP for elbeem library until a proper fix is found (currently makes fluid sim crash) (Bug# 20043)
Thx Jens Verwiebe for the investigation!
2009-12-08 09:58:42 +00:00
fccceaa87f - pyrna support for (value in array), currently only 1 dimensional arrays.
- use python malloc's in bpy_array.c
- automatically blending bone locations is disabled if the target bone has locked location
- neck had incorrect roll
2009-12-08 09:40:30 +00:00
c146ce977c Quick ShapeKey Editor fix (i.e. submode of DopeSheet):
Switching to ShapeKey Editor mode now shows the sliders again
2009-12-08 09:07:20 +00:00
d765068fca BGE: add hitUV property to mouse focus sensor to return UV coordinates under mouse pointer. Useful for texture painting. More details in PyDoc. 2009-12-08 08:58:24 +00:00
2318886f70 BGE: fix bug in mouse button release detection 2009-12-08 08:46:07 +00:00
915f352400 ImBuf: Fix bug in clipping 2009-12-08 08:44:18 +00:00
81a69bb00f Various changes to screen-related code, aiming to fix a few problems and usability issues with 'temp' screen layouts.
Now, temp screens are hidden from being accessed directly, with a new 'Back to Previous' button appearing in place of the screen menu when (for example) fullscreen render image areas are present. Window type menus also get disabled here too, to prevent things from getting too mixed up.
2009-12-08 07:12:06 +00:00
f4fa39a551 white space commit (spaces -> tabs and clearing whitespace) 2009-12-08 07:11:43 +00:00
53f94f92a1 Animation Editors: Fixes for RNA/Python Bastardisation
Still not happy about the tight/regular-spacing imposed by the layout engine automation, but will tweak later.
2009-12-08 06:32:30 +00:00
4ea3e14ebf Wrong argument type for zoom operator. 2009-12-08 01:56:01 +00:00
d653b0c961 Few small things:
1. MSVC 9 projectfiles update (graph_header.c, action_header.c and nla_header.c removed)

2. Fix for opening the filebrowser when saving file for the first time (untitled.blend) from file menu

3. Add CROSS effect sequence type back to menu. (Durian fix)
Note: Removed SEQ_EFFECT from rna, since this no actual sequence type, but rather used to check for the effect bit.
2009-12-08 00:57:14 +00:00
742a09858b FIX for #20256 New folder doesn't rename
Note: did some refactoring and renaming of files to make code a bit clearer there too.

Also applies solution provided by Aurel W in patch #20264, thanks for submitting the patch.
2009-12-07 23:47:37 +00:00
3a954970f7 Remove 'temp' screens hanging around in files from older 2.5 versions 2009-12-07 22:29:35 +00:00
495cbc1a6f Forgot to remove these. 2009-12-07 21:56:25 +00:00
b71749305a Pythonazed DopeSheet and NLA editors headers UI. 2009-12-07 21:51:44 +00:00
ce49719a0c use the SUM driver type to avoid adding all values on each bone.
also avoids hitting the 255 string limit if you want to add 100's of values. eg.
>>> b05/max(0.001, [globals().update({"LOCALS":locals(), "ADD":float.__add__, "reduce":__import__("functools").reduce}), 0.0][1], max((, [LOCALS["b%.2d" % (i+1)] for i in range(5)])))

Since this more simple expression reaches the limit fairly quick...
>>> b05/max(0.001,b01+b02+b03+b04+b05)
2009-12-07 20:49:12 +00:00
f350cde18c -noaudio option to force the sound system to None.
Useful when openAL is not setup properly (*cough* pulseaudio *cough) and prevents startup.

This doesn't actually affect the userpref option, so you can set it to whatever you want, save userprefs and restart.
2009-12-07 20:39:57 +00:00
16ec4cc186 Sound system should only default to OpenAL if it is built (SDL if built otherwise). 2009-12-07 20:38:09 +00:00
21f41e1bce Text and Console operators don't need to register themselves. (this cleans the reports quite a bit) 2009-12-07 20:03:49 +00:00
47416c725c driver type 'Sum' 2009-12-07 19:59:04 +00:00
a321e2b139 Sculpt Branch:
Subdivision set with Ctrl+1-5 now works for multires as well.
2009-12-07 19:56:59 +00:00
987e9bc172 missing null check from recent changes 2009-12-07 19:49:14 +00:00
82ddfbf99f Sculpt Branch:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24889:25180
2009-12-07 19:22:48 +00:00
4ca2581b77 Sculpt Branch:
* Don't allow adding/removing multires levels in editmode.
* Customdata code for swapping mdisps restored.
* Fix inflate brush crashing with multires.
* Smooth and layer brush don't work yet with multires, but at
  least avoids crashing now.
* Fix threading issue with flatten brush.
2009-12-07 19:11:37 +00:00
fc69c54c4c Particles: bugfixes
* Don't show Apply as Shape for particle modifiers.
* Fix particles disappearing after exiting particle mode.
* Fix free edit not redrawing the 3d view.
* Fix use of uninitialized variable in layers template.
2009-12-07 18:17:39 +00:00
1962afa2a6 Use custom cursor draw in transform to draw the new arrow cursors (to indicate direction of motion for a particular transformations). This insures that it's drawn under the cursor and not far away when cursor is warped (rubber band still points to event location, this helps visualize too). 2009-12-07 18:10:11 +00:00
19aab8edb0 Custom cursor draw function uses the real cursor position when cursor is grabbed (and not the coordinates from the event). Drawing a custom cursor anywhere but on the real cursor is no good.
Also permit NULL poll function (equal to a function that always returns 1)
2009-12-07 18:08:19 +00:00
78f87c8bdf Function to access the real cursor position from Ghost (useful when cursor is grabbed and warped) 2009-12-07 18:06:37 +00:00
149b3bc7f2 Flag down a window when cursor is grabbed. 2009-12-07 18:05:51 +00:00
4a23c3f9e1 Particles: child editing bugfixes
* Make partial update work again for faster editing.
* Draw parents over children again, nicer for editing.
* Fix crash with remove tools & showing child particles.
* Fix children not disappearing always when setting to None.
* Fix wrong normal for last point in child path.
* Fix a python error in the hair dynamics panel.
2009-12-07 17:55:58 +00:00
f8f7f57557 - bone.basename now only gets the name before the first '.', since names like finger.01.L are common
- updated delta not to remove a bone
- spine and neck rigs interpolation bones are now axis aligned to the control bone
- palm tag is expected on the pointer finger rather then the wrist
- operate on bone children first working up the chain (not essential but more pradictable)
2009-12-07 17:21:30 +00:00
161871316e Bugfix: WM could access freed memory when testing for click event after
opening a new file (and freeing the window and its event queue).
2009-12-07 16:59:10 +00:00
74b80f8c3d crashfix, duplicating armatures with ID-Props assigned to the bones didnt copy the bone. 2009-12-07 15:54:27 +00:00
926201acf8 - string copy without .py wasnt terminating the string
- console import autocomplete wasnt including modules defined in C like BGL, Mathutils
2009-12-07 14:09:53 +00:00
73fbc0f02d pep8 compliance cleanups. 2009-12-07 12:11:28 +00:00
c1c5acae14 Porting of Graph Editor's UI to python, just header done for now.
Brecht, I added a Layout template function, template_dopesheet_filter -> uiTemplateDopeSheetFilter, this creates the group of buttons for filtering ID type (and some other options) for animation editors (Graph, NLA and Dopesheet). I hope this is all right, if not, we can move this maybe to a .py file as a function for reuse.
2009-12-07 11:50:05 +00:00
cc166a8b50 Talked with Aligorith and made changes as follows to DopeSheet struct:
* Removed only_drivers, this is an internal flag
* Corrected notifiers
2009-12-07 11:02:59 +00:00
63fbd76548 [#20021] Non-ASCII characters on blender 2.5 alpha 0
could not redo the bug on my system, fix suggested by Yomgui on blendercoders.
2009-12-07 10:41:16 +00:00
f888903eaf Fix for [#20159] Orthographic camera + viewport
Patch provided by Aurel W. Thanks!
2009-12-07 10:40:55 +00:00
a94a2c8c72 Fix for [#20286] New objects have no Display Type
Removed a few more references to shaded mode
2009-12-07 10:28:36 +00:00
b672e9f9c0 Fix for [#19541] Buttons etc that are too close to the window edge don't react to input 2009-12-07 10:22:58 +00:00
91102d96fc Fix for [#20057] Shift F for setting brush strenght can never get to 1 2009-12-07 03:37:43 +00:00
764c4c94fa use sets rather then tuples for enum/flags so you can use bitfield operators 2009-12-07 02:20:55 +00:00
7f590d3a46 Added icons to a few RNA properties. 2009-12-07 01:26:34 +00:00
17d7b7220f Tweaks to the fading behaviour of 3d view grid subdivs, somewhat fix for
[#20246] grid subdivisionns doesn't works
2009-12-07 00:50:40 +00:00
750764f411 rna flag PROP_ENUM_FLAG which makes rna props a tuple of enums when converted into a PyObject
only used by wm.invoke_props_popup() currently
2009-12-07 00:16:57 +00:00
85773c7230 Fixed operator name typo. 2009-12-07 00:11:17 +00:00
c5a614f2db Finished wrapping SpaceGraph in RNA and also wrapped bDopeSheet in the process. Some descriptions might be slightly off, feel free to check. 2009-12-06 22:28:59 +00:00
450d33cc9a Loop cut and edge ring select only have an invoke and require view3d, so change poll function to reflect that (and not, you know, crash...). 2009-12-06 17:38:39 +00:00
4b2163c1cc Text change: Loopcut -> Loop Cut 2009-12-06 17:36:27 +00:00
ba0981031a Assorted warning and comment fixes 2009-12-06 09:37:31 +00:00
f08e8af0b9 wm.invoke_popup(op, width, height) similar to wm.invoke_props_popup(op, event) except it doesnt use undo/redo (UI's need to execute operators themselves) 2009-12-06 04:35:00 +00:00
062cf438ce remove nasty hack which made StructRNA class instaces have no __dict__,
use __slots__, it seems all the parent classes need to have slots as well for this to work.
all python defined srna classes are checked for this too
2009-12-05 23:41:45 +00:00
5ebe54f470 pep8 edits and fix some warnings 2009-12-05 22:03:07 +00:00
8821f7d7ea 2.5 Nodes:
* Node listener missed "ND_SHADING_DRAW".
2009-12-05 21:54:46 +00:00
9d2293c464 2.5 Nodes:
* Wrapped Texture Nodes: "Blend", "Marble", "Wood", "Clouds", and "Distorted Noise", to use Texture RNA properties.
* Texture RNA properties used in these Nodes, now send an ND_NODE notifier, in addition to the general NC_TEXTURE.
2009-12-05 21:14:31 +00:00
651336d5df fixes for automatic tests and some errors in last commit 2009-12-05 20:45:51 +00:00
bca53f0906 [#20266] Blender starting without X11 segfaults
Abort when ghost x11 cannot initialize a display.

It would just crash later anyway, better to abort with a reasonable error message.
2009-12-05 20:06:19 +00:00
bcd1ab54cd Support for the C Macro system in Python.
Basic definition works like a python operator but you derive from "bpy.types.Macro" instead.
Operators are added to the macro after it has been added with "bpy.ops.add_macro" through the class method "define" which takes an operator id and returns an OperatorMacroType (new RNA type) for which properties can then be defined to be passed to the operator when run.

Example: http://blenderartists.org/~theeth/bf/macro.py

Using this system, it should be easy to add an operator to the console that converts selected lines into a macro or even a more generic record macro system.
2009-12-05 19:27:26 +00:00
65edb7341f split up metarig hierarchy evaluation and modifying the metarig into 2 steps,
original bone names cant be changed anymore but this means the bones can be re-parented without confusing scripts that run after the rig is modified.
support for defining a bone to have multiple types and  automatically blending between 2 generated rigs
2009-12-05 19:26:28 +00:00
f287762678 Macros in macro didn't work correctly. 2009-12-05 19:05:21 +00:00
d98cbf7727 simple fix [#20218] Object.is_visible() don't reflect visibility 2009-12-05 14:12:06 +00:00
Dalai Felinto
b7e0d5ac34 BGE fix for GameLogic["post_draw"] not working with 2DFilters
(reported by Mike Pan(mpan3), it's not in the tracker)
2009-12-05 02:30:20 +00:00
Nathan Letwory
5438440483 * enabled COLLADA for mingw. (Compiles at least with MingW GCC 3.4.2). 2009-12-05 01:24:45 +00:00
Nathan Letwory
f539604094 * proper SSE setting for mingw.
* some cleanup of render module SConscript
2009-12-05 01:07:42 +00:00
Nathan Letwory
c2b71607d2 * provide SCons support to enabling jaguarandi SIMD raytracer optimizations for real :)
Until now only SSE switches were defined, but to really enjoy the SIMD structures, the
  __SSE__ define needs to be given. This can now be done with setting in your user-config.py

          WITH_BF_RAYOPTIMIZATION=True

  (or WITH_BF_RAYOPTIMIZATION=1 on command-line)
2009-12-05 00:26:20 +00:00
c7c1fda642 Changes to netrender baking operator.
Force step of 1 for full baking.
2009-12-04 19:13:22 +00:00
56b0880d2f Null check for baking progressend function
Simplify end of line for console progress.
2009-12-04 19:08:07 +00:00
e9b7482b6a Save_Mainfile operator only needs window for invoke. Removed poll function and replace by a check in invoke that cancels if no window is present.
Makes it possible to be called in background mode.
2009-12-04 19:07:25 +00:00
f21ec89081 Fix for [#20144] Game physics panel - softbody allows other collision bounds. 2009-12-04 19:06:17 +00:00
648122b1a2 String fix and a bunch of PEP8 issues I had collected in the meanwhile. 2009-12-04 17:54:48 +00:00
19c0a169b8 touches for demo'ing 2009-12-04 16:35:31 +00:00
f3201f0853 UI: curve widget tweaks
* Make snap ctrl instead of shift
* Only enable snapping after moving a few pixels,
  otherwise too easy to do enable this by accident.
* Deselecting points with shift did not work.
2009-12-04 15:32:26 +00:00
0b6873a776 BGE: Add option to return UV coordinates aofthe hit point to KX_GameObject::rayCast(). Details in PyDoc. 2009-12-04 11:27:40 +00:00
1dcca75e04 Update MSVC9 project files 2009-12-04 10:45:23 +00:00
6bfb3cf6ef Update MSVC9 project files 2009-12-04 10:37:24 +00:00
d1563601f4 This commit deletes temporary "temp" screen layouts when the windows using them get closed. 2009-12-04 09:58:00 +00:00
e299798bbf Fix for [#20203] Linked objects - A few bugs
Did a lot of cleaning Object operator poll functions to check if the object's linked 
or not. For this, added the function ED_operator_object_active_editable() as 
opposed to ED_operator_object_active()
2009-12-04 06:33:01 +00:00
d828062f1b Fix for [#20157] 2.5 Can`t remove a linked objects from the 3D view by pressing X 2009-12-04 05:05:50 +00:00
e31f3e63cd Fix for [#19958] Changes in UV/Image editor doesn't refresh mapping on mesh in 3dview immediately
Enabled 'update automatically' (lock) in image editors by default
Also enabled transform manipulators by default, unfortunately missed for alpha 0 release.
2009-12-04 04:56:42 +00:00
cbfb8fbd7f Fix for [#19921] pressing NumpadDot on isolated mode centers the 3D cursor 2009-12-04 04:41:32 +00:00
a358b6386d * Fix for incorrect disabling after baking cloth sim
* Fix for time cursor getting 'stuck' after baking point caches
2009-12-04 04:28:50 +00:00
45955fef18 Bugfixes: Deleting Keyframes + F-Curves
This commit fixes #19908 and #20239. Deleting keyframes will now delete the F-Curves they came from too, if the F-Curves don't have any more keyframes and/or F-Modifiers providing any further motion info.
2009-12-04 03:51:52 +00:00
a9b9993414 rna function
editbone.align(vector), to align the bones z axis to a localspace direction.

finished leg rig pose mode data
2009-12-04 02:32:34 +00:00
30d752502b Fix for [#19884] Curve resolution slider not affecting anything 2009-12-04 01:38:36 +00:00
d3d11ede44 Fix for cache path.
Operator for background baking (no support in netrender itself yet).
2009-12-04 01:28:00 +00:00
77aacc6ce4 Print baking progress to console when window is not available. 2009-12-04 01:26:42 +00:00
b1a1a0f135 Cleaning: update a couple of functions to use scene from context instead of from screen. 2009-12-04 01:25:43 +00:00
ae7cf1df8f Partial fix for [#19874]
can use RMB to cancel joining areas, same as splitting
2009-12-04 01:21:55 +00:00
a657920fba Fix for [#20229] Booleans crash on edge case. 2009-12-04 00:54:40 +00:00
688c4aa1de Fix for [#19478] Shortkeys for switch to Quad view mode is not working
changed default quad view shortcut to Ctrl Alt Q
2009-12-04 00:49:02 +00:00
1757b06e88 Only set baking progress function to cursor when a window is present.
This enables baking in background mode (instead of just crashing).
2009-12-03 22:48:00 +00:00
ab1290d62e leg rig type & metarig example, still need to add IK's
fixed some small bugs too.
2009-12-03 22:44:11 +00:00
18b465b749 Finish renaming job in Set Center operator to use Origin instead of Center.
Also replace ObData by Geometry and Object Geometry after talk with Matt.
2009-12-03 21:56:04 +00:00
3b0e182f71 - property decorators for setting attributes didnt work, hack to prevent every instance of an BPyStructRNA to have its own dictionary, set the tp_dictoffset to 0. attempted to use __slots__ but this doesnt work for some reason.
- made bone.length writable
2009-12-03 21:53:01 +00:00
a4d8c4a745 Fix for [#20240] Image inputs to the compositor are white when using color management
was missing include
2009-12-03 21:49:29 +00:00
e4a97d67b6 Make toggle and hold snap method cohabit nicely.
Shift-Tab toggles the global toolsetting snap settings (both in and out of transform).
Holding down Ctrl inverts the snap setting in transform (turns it on when global snap is off and vice versa).
Ctrl-Shift-Tab to select snap mode (only outside of transform for now).

For old (pre 2.5) behavior, just keep global snap off and use Ctrl.

NOTE: transform modal events for snap have change a bit, saved keymap might not work anymore.
2009-12-03 19:18:00 +00:00
010c99deb2 Sculpt Branch:
* Multithread parts of multires and subsurf. Only loops working on
  face grid data and do no memory allocation have been multithreaded,
  others would be more complicated.
* Force some CCGSubsurf functions to be inlined, gives a small overall
  speedup in subsurf code.

* Fix sculpting not working correct with transformed objects.
* Fix a few cases of "spikes" on lower level multires levels. There's
  still cases where it happens, usually on boundary cornders. The
  problem is that in such cases the limit surfaces can be very different
  from the low res surface, so the tangent space is very different too..
* Fix crash deleting multires higher levels with level set to 0.
* Fix crashes that happened sometimes when adding faces in editmode.
2009-12-03 18:35:37 +00:00
e10ae8a1a2 Sculpt Branch:
* Fix some svn merge errors.
2009-12-03 18:28:04 +00:00
18fb6d5e43 Added Toggle Full Screen and Duplicate Area to the menus of all the main spaces in Blender 2009-12-03 16:28:50 +00:00
685d418f3a - curve geometry curve panel wasnt displaying with no active spline
- graph export didnt work for constraints with no subtarget
- utility functions for duplicating a set of bones and blending between 2 sets
2009-12-03 14:20:35 +00:00
3b1c6d6065 Quicktime Carbon: Fix memory leak when build with cocoa 2009-12-03 12:16:00 +00:00
1fd581ad77 Bugfix: Toggle animation channel visibility (shift-v) was not flushing the new values correctly
- Modifying groups did not flush status to channels below
- Objects were always toggled. Still need to figure out why this didn't work right...
2009-12-03 10:27:22 +00:00
b440fe1611 Fix for one of the issues in #20230: Comp Nodes animations not saving to .blend
AnimData was not getting written to files for Node Trees.
2009-12-03 10:23:38 +00:00
42970d81fc Bugfix #20190: Scaling Bone Joints in envelope drawmode
Made scaling selected joints using SKEY work in the same way as in 2.4x 

However, it'd probably be nice to be able to have separate hotkeys for this at a later stage.
2009-12-03 10:18:47 +00:00
cbab6e57dc QTkit : update build checks to allow only 10.5+/64bit builds
Other SDK versions do not handle correctly QTKit movie creation in a background thread.
Carbon quicktime should be used for the 32bit builds (USE_QTKIT = 0)
2009-12-03 09:59:52 +00:00
f146d96c3b Bugfix #20219: Timeline navigation
Added missing "View All" (HomeKey) operator for TimeLine
2009-12-03 09:56:31 +00:00
8c313fa931 Fix for color management not working with AVI output, patch by Damien Plisson, thanks! 2009-12-03 09:51:02 +00:00
bd8e929044 Fix for [#20226] 3DView header: hiding menu texts and layer button's issue.
Also: big purge of old 3d view header menus and old unused code
2009-12-03 09:49:21 +00:00
22290fbbbb Fix for [#20168] Particle velocity display toggle issue
Thanks Alan Taylor for the initial patch
2009-12-03 00:42:02 +00:00
5e5d05b8dd Fix for [#20180] Wrong multiplicator in Random Selection
Also:
Added extend select option to select random (off by default)
Tweaked 'Select Axis' to use an enum for axes
2009-12-03 00:17:34 +00:00
ae91675312 Fix for [#20154] Shaded draw mode needs to be removed when loading files 2009-12-02 23:14:58 +00:00
47b457f19e Bug fix: Verlet integration didn't work properly with moving particle emitters.
Thanks for mcreamsurfer for reporting and Farsthary for the patch!
2009-12-02 20:53:28 +00:00
63fc267929 [#20213] Align to Transform Orientation crashes Blender
Align needs to be call with region context.

Also added checks to prevent this from crashing if not called properly.
2009-12-02 19:59:57 +00:00
bce687ef36 Menu handlers need to return OUT when clicking outside, not OK
Caused crashes with window type selector and a slew of other unwanted behaviors.
2009-12-02 19:32:21 +00:00
7706261e79 change bone storage class so __slots__ can be used for looping over attributes without getting functions 2009-12-02 19:13:54 +00:00
2a6d535d23 Fixed a part of [#20197] dof node bugs.
* False greying out.
2009-12-02 18:35:44 +00:00
59ae9d855d Mac: Following 10.4 ppc libs availability, update cmake & scons default settings 2009-12-02 18:06:39 +00:00
e2450e4dd9 multiple script paths broke text template menu 2009-12-02 16:11:10 +00:00
ce36cdac04 - bpy.data.add_armature()
- rigify testnig function, creates all example metarigs, processes and generates graphs for before and after.
2009-12-02 15:37:07 +00:00
863668a145 Cocoa: suppress unwanted beep when pressing Cmd + key on 10.4 2009-12-02 15:02:29 +00:00
a219c93cb0 Quicktime(Carbon/win32) : add operator to raise the "compression settings" quicktime standard dialog 2009-12-02 14:39:49 +00:00
d56324b254 UI: remove unnecessary colon on toggle array buttons. 2009-12-02 13:21:22 +00:00
dd90ffd47b Cocoa: remove errors for all supported SDK/CPU configs 2009-12-02 13:05:31 +00:00
2bf618368a - include example input rigs for each autorig type, running metarig_template() in each submodule generates the armature and pose bone ID properties.
- rigify.write_meta_rig() exports rigs as python scripts
2009-12-02 11:55:47 +00:00
927b976a88 AAO Indirect Diffuse
Don't use passes anymore for indirect lighting, people were using this
probably thinking it would do bounces, but that's not the intention of
this feature, it is to reduce problems with light bleeding. I want to
remove this option for AO as well, but will leave it in for now until
there is a better alternative.

Added bounces option for indirect, could be implemented much better,
but perhaps useful for testing now. Existing files need to set this to
1 to get the same results again.
2009-12-02 11:54:48 +00:00
03a9740c16 Quicktime : make dna codecType data store the quicktime codecType value instead of a proxy value
Quicktime codecType data is a 32 bit value (4 chars coded).

Implemented RNA set/get functions for codecType enum to cope with RNA enum values 24bit precision limitation
Implemented dynamic codecType enum list creation

Carbon quicktime now stores codec settings in "clear" in the QuicktimeCodecSettings dna struct (in addition to the closed atom container in QuicktimeCodecData) to be compatible with the QTKit version

+fixed some warnings
2009-12-02 11:23:11 +00:00
8c5d021d19 rename armature RNA props
armature_matrix --> matrix_local
armature_head --> head_local
armature_tail --> tail_local
2009-12-02 10:32:39 +00:00
39f42df424 CMake: remove new GHOST_DropTargetWin32.cpp file from non-win32 platforms builds 2009-12-02 10:21:10 +00:00
0efaf10b7a Cocoa: fix delaying issue for events that were fired outside the processEvents function
An example of a visible issue was a delayed wm resize when switching to/from fullscreen mode
2009-12-02 10:10:20 +00:00
b89138564e Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color 
management works internally. While the previous method worked well for 
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult 
for other areas such as compositing.

This implementation now considers all color data (with only a couple of 
exceptions such as brush colors) to be stored in linear RGB color space, 
rather than sRGB as previously. This brings it in line with Nuke, which also 
operates this way, quite successfully. Color swatches, pickers, color ramp 
display are now gamma corrected to display gamma so you can see what 
you're doing, but the numbers themselves are considered linear. This 
makes understanding blending modes more clear (a 0.5 value on overlay 
will not change the result now) as well as making color swatches act more 
predictably in the compositor, however bringing over color values from 
applications like photoshop or gimp, that operate in a gamma space, 
will give identical results.

This commit will convert over existing files saved by earlier 2.5 versions to 
work generally the same, though there may be some slight differences with 
things like textures. Now that we're set on changing other areas of shading, 
this won't be too disruptive overall.

I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png

and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
c758f6589e Reset operator properties for keymap items when operator idname is changed.
This means added operators in the keymap editor will now show options correctly (maybe not for old .B25.blend)
2009-12-02 04:12:16 +00:00
fa2ec6af38 Restore new snap align icon that was lost in previous changes. 2009-12-02 04:07:40 +00:00
50c8c28c60 - finished spine rig generator, (drivers, constraints)
- bug with args passed for class slots being modified in place.
- sort graphviz bones & drivers (useful for diffing 2 armatures)
2009-12-02 02:56:22 +00:00
fd69360fd2 remove icon_only option for snap target option in header to make the button wider. Now it's a bit too wide, but at least it can be read. 2009-12-02 01:38:54 +00:00
4913f415cc SVN maintenance. 2009-12-02 01:23:29 +00:00
Nathan Letwory
372bfeb0c5 * make sure we don't choke on what we don't have :° 2009-12-02 01:12:22 +00:00
Nathan Letwory
8847615116 * make sure drop target files are filtered too. 2009-12-02 01:05:37 +00:00
Nathan Letwory
5a3791ab5b Apply patch [#20145] Ghost Win32 roundup patch: Minimum Window Size, Continuous Grab and Drag And Drop
This nice patch by Matt D. (matd in #blendercoders) adds three nice features that can be seen already in the other supported OSes:

* minimum window size: to prevent some bugs with the window manager of Blender, system windows cannot be resized smaller than the minimum size.

* Continuous Grab is finally in Windows! Default settings since alpha 0 already have the feature enabled by default, so grab a new build and enjoy :)

* GHOST support for drag and drop added. This prepares Blender for drag and drop from OS -> Blender. Currently not very useful, since wm needs to be readied for that. But it does work (do BF_GHOST_DEBUG=1 build and drag a file onto a Blender window).

Thanks Matt D.!
2009-12-02 00:57:12 +00:00
d86a27f7b6 Bugfix: crash when no active object
Misc fixes.
2009-12-02 00:53:33 +00:00
5d4b45e2d9 * Fix for earlier fix, only check for basis metaball if the object's actually a metaball 2009-12-01 23:55:33 +00:00
c27f3adadc - rig spine type WIP, editmode done, still needs pose constraints and drivers.
- bone.translate(vec) utility function
2009-12-01 22:45:56 +00:00
ce13cded15 fix for [#19990] file browser crash
needed to fix jpg error handling to not return control to the library from jpg_error used as error exit. Needed to add structured exception handling (setjmp/longjmp) - not very nice but needed in this case. (Also recommended in example.c from libjpg and used in gimp ;) )
2009-12-01 20:37:26 +00:00
9bf3845539 circle select modal operator wasnt returning FINISHED so it wasnt getting an undo push 2009-12-01 19:43:09 +00:00
9f251ce301 Additive snap for Transform. Easy snapping between two vertices, in the middle of three faces, ...
A to add the current snapping point to the list
Alt-A to remove the last one

The resulting snapping point is the average of all snap points in the list (and the one under the mouse pointer, if valid).

Snapping between two verts is a matter of moving over the first, pressing A, moving over the other, confirming transform.
2009-12-01 18:26:18 +00:00
d7877d360a Cocoa: proper implementation of the modifiers key wrong value when application becomes active again
Note: this works fine when running under 10.6, even if compiled with an older sdk
Under 10.4/10.5, workaround remains to assume no modifier key is pressed when the user restores the focus to the application
2009-12-01 15:46:37 +00:00
6372c63ae9 select pattern for bones 2009-12-01 14:48:36 +00:00
48398c978e more small fixes 2009-12-01 12:43:06 +00:00
2afc967a2f small fixes, also option for fake parent so hierarchy is always from the parent down 2009-12-01 12:25:59 +00:00
0391000c4e export an armature to graphviz showing hierarchy, constraint and driver relationships, useful for understanding other peoples complicated rigs.
can be extended for 2.4x oops like graph too/

Example of Cessens spine rig
http://www.pasteall.org/pic/show.php?id=378
2009-12-01 12:02:23 +00:00
bd8f50234f Mac scons config: enable cross-compile, set 10.4 as default for ppc (using darwin-8.0.0-powerpc libs), set opencollada not to be built by default 2009-12-01 11:19:18 +00:00
370fe43b2b Eigen: fix 10.5 ppc compile error 2009-12-01 10:25:21 +00:00
eb24e788b8 Cocoa: implement Cmd+W to close window, workaround for wrong modifiers key status upon focus retrieval
The carbon GetModifierFlag function (to get the current modifier keys status) is reimplemented in cocoa only from 10.6.
So we need to use a workaround to get the correct modifiers when blender application gets focus back. Current one is to assume no modifiers.
This at least fixes the issue when blender has been hidden using Cmd+H. The Cmd modifier was still seen as ON until the user pressed again on it.
2009-12-01 10:23:27 +00:00
99e765ee00 added autorig neck type
new bone properties
- bone.basename (name without the extension), "Some.Bone.001" --> "Some.Bone"
- bone.children_recursive_basename, gives a chain of children that have the same basename
2009-12-01 00:44:53 +00:00
33c444f965 User Script support added back.
- the scripts path set in the user preferences or ~/.blender/scripts/ui (io, op, io etc..) will be used to load scripts.
- the default home dir part probably only works in *nix os's

- Added a missing sync callback to vector.toTuple()
2009-11-30 22:32:04 +00:00
168fe0b4b5 Transform Modal Map:
Adding events for X/Y/Z axis and planar constraints (always use the user orientation, not global first) and for turning constraints off.

Built-in keys (toggle between global, user and off) are not in the map but can be overridden (any events handled by the modal keymap will not enter the built-in map).
2009-11-30 20:20:00 +00:00
29f6357ddc Bugfix: PET circle not drawn correctly in edit mode. 2009-11-30 19:43:59 +00:00
9d8b94ecee surfaces were displaying the Geometry panel that only curves need 2009-11-30 19:24:13 +00:00
afe475b55b Approximate AO: Diffuse Bounce Hack
This brings back the single bounce indirect diffuse lighting for AAO,
it's not integrated well but that will be tackled later as part of
shading system refactor and subdivision changes. The caveats are the
same as AAO, with one extra thing, the diffuse lighting is sampled once
per face, so it will not be accurate unless faces are subdivided.

I'm committing this now so we can start testing it for Durian, and
since changes need to make it work properly are planned.
2009-11-30 18:42:13 +00:00
4a4fff5b21 Cleanup:
* Deleted "Add" Prefix for mesh.duplicate_move in Toolbar.
* Renamed "duplicate_ipo" property to "duplicate_fcurve"
2009-11-30 18:26:53 +00:00
e318109714 * Disabled "Shaded View" again, not working in 2.5 (yet). 2009-11-30 18:06:45 +00:00
e7beae5670 Rename Centroid to Origin, following discussions on mailing list. 2009-11-30 14:40:45 +00:00
b911d83091 better not process events early, could cause troubles later.
added a function - wm_window_get_size_ghost(), which looks into the ghost window directly so events dont need processing first.
2009-11-30 14:10:46 +00:00
ab4a141560 bugfix [#20083] Wrong position of splash screen on dualhead 2009-11-30 13:58:27 +00:00
0f24af7506 curve select toggle was broken from recent select operator update 2009-11-30 12:50:22 +00:00
a2140192fe convert rigify into a package. advantage is new types can be added into the package without modifying any existing files, the bone 'type' property will find the matching submodule 2009-11-30 12:31:11 +00:00
679da5eb50 Durian Graph Editor Request: Only show handles of selected keyframes
This option for the Graph Editor means that only the handles for selected keyframes get shown in the view, eliminating clutter. 

Currently, the selection code isn't aware of this option, so clicking anywhere near where a handle might be may often trigger it to show up. This may/may not be desireable, but we'll see how Lee goes with this first :)
2009-11-30 11:37:27 +00:00
e1ba5517e6 better remove doubles for retopo, use 15th the of the average of both splines lengths (less scale dependant) 2009-11-30 11:18:46 +00:00
a2d757dc7d Durian Requests for Graph Editor Visibility Toggles (2):
Improved the hotkeys for toggling the visibility of channels in the keys area for the Graph Editor. 

* VKEY - this is now used for making only the selected channels visible, hiding everything else
* Shift-VKEY - the old toggling behaviour

In addition to this, I've made these toggling operators flush the visibility flags up/down the hierarchy, just like clicking on the channels manually do. There are still a few minor oddities to iron out, but it should be better than before.

Also, fixed a bug with these toggling operators introduced during my earlier commit to make filtering work ok. It's always tricky getting these layers of checks just right, so hopefully nothing breaks now again...
2009-11-30 11:10:03 +00:00
e526047061 retopo: use a smaller scale for faces that are modeled where 1.0==1m, will eventually try to use a method that doesnt depend on scale like this
grease pencil point.co wasnt a vector when it should be
2009-11-30 10:21:42 +00:00
7fd2a2da6f * Grease Pencil drawing now works with Repeat Last operator. Stroke info is now saved when drawing strokes, but unfortunately, the post-draw settings tweaking doesn't work from the toolbar still (due to missing region context info)
* Added some update callbacks/flags for F-Curve properties, so changing the colour of an F-Curve updates in realtime.
2009-11-30 03:10:46 +00:00
caa11aae04 Assorted tweaks for subdivide operator ranges - soft/hard ranges were swapped. 2009-11-30 02:42:10 +00:00
9b0a3ee9ce previous commit for retopo converted the strokes into a curve first, better to use the grease pencil data directly. renamed coordinates --> co, matching mesh verts 2009-11-30 02:34:49 +00:00
3f37f32e17 scons + gcc linking fix for bullet softbodies:
Upped the priority for the softbody module so that gcc linkers (mingw, linux-gcc) would be able to resolve the dependencies. MSVC still worked though.
2009-11-30 02:28:50 +00:00
dc1af66d8a - grease pencil drawing on the surface of objects (only when enable face snap & projection, a bit hidden I know)
- retopo operator to convert grease pencil drawn topology into geometry, not in the convert menu yet since its not quite finished, use the operator search menu for retopo. will test this week and see what needs fixing.
2009-11-30 01:13:46 +00:00
3d1f297489 Added temporary compiling fix for MSVC after Campbell's rounding commit.
Copied (in if-defs - for msvc win32/64) the python math functions used for dealing with the lack of a 'round()' function.
2009-11-30 00:18:36 +00:00
a96f6f2e15 * Moved rotation initialisation code for new objects to 'the other' add object function that campbell fixed earlier. This should mean that the py-api does everything in the right way now.
* Tried adding 'Load Factory Settings' to File menu, but I seem to be running up against some RNA bugs. Can be removed if is too problematic.
2009-11-29 23:54:41 +00:00
2bef608fb3 - new objects added from the rna api defaulted to quat rotation, not even using an identity quat.
- making meshes in python isnt nice at the moment, added a helper function.
    mesh.from_pydata(verts, edges, faces)
2009-11-29 23:14:41 +00:00
d98093a91a - added a new math function double_round, useful for rounding a number to a number of decimal places.
- added Mathutils vector method, vec.asTuple(round), since this is tedious in python and fairly common task.
2009-11-29 22:42:33 +00:00
cd154da973 1. Extend option for 3d view border select now does something (default True to keep same behavior)
2. Add action parameter to Select_All_Toggle operators, rename to Select_All.
Options are Toggle (default), Select, Deselect, Invert (same as select swap). This makes it possible to map separate hotkeys for select all and deselect all.

NOTE for Aligorith: I didn't change animation operators for select_all which already had an Invert operator. These should be fixed eventually.
2009-11-29 22:16:29 +00:00
92b4316708 Merge from COLLADA branch into trunk of -c 24572 (cmake and scons for OpenCollada @ 675, Linux) and 25001 (bone animation import). See corresponding log entries for more detail. 2009-11-29 19:16:52 +00:00
edf32a6fb0 Gimbal orientation defaults to Normal instead of Global when bone or object is not using euler orientation (Normal is bone axis for pose and Local axis for object, so this is more useful than defaulting to Global). 2009-11-29 18:20:26 +00:00
a22cfe99db == Sequencer ==
Brought back default effect fading: (adding a wipe effect makes it
wipe by default for the length of the strip)

First round in upgrading IPOs from older versions. (works for non-IPO
case now and sets at least the new "default effect fade"-flag)

Still non-working for old IPOs, since Sequence-Strips aren't real IDs!

And: non-frame-lock case should stretch the FCurve to the right length!
2009-11-29 18:14:16 +00:00
ae16f46573 Fix CLICK event for modal operators.
modal operators should return RUNNING_MODAL|PASSTHROUGH for unhandled events to be able to receive clicks correctly (this needs to be fixed for other modal operators).

Maybe it's time to have "handled" flag in event instead.
2009-11-29 16:49:26 +00:00
3b72584b7d - access to a nurbs points was broken - sizeof(BPoint) vs sizeof(BPoint *)
- renamed CurvePoint --> SplinePoint
- renamed point.point --> point.co (less stupid, matches vertex.co)
- access point.co was a 3D vector rather then a 4D vector with the Nurbs weight included.
- rename point.weight --> point.weight_softbody, move point.point[3] --> point.weight
- sorted RNA structs (for pedaticness only)
2009-11-29 16:42:51 +00:00
e08b6b8376 UI:
* Removed hardcoded shortcut keys in 3dview header tooltips
* Removed an unused function
2009-11-29 06:10:26 +00:00
46e1abeda7 UI:
* Finished fixing the layer UI template. It's now used in the 3dview header rather than the custom layer grid.
2009-11-29 06:04:39 +00:00
7c21fa3b72 Armature Bugfixes:
* Bugfix #20136: unclear tool tip for inherit rotation toggle
* Bugfix for Apply Pose as Restpose (Ctrl A in Pose Mode): missing call to free edit-data was causing drawing code to only draw editbones until editmode was entered + toggled
* Added missing notifier for deleting F-Modifiers, so deleting F-Modifiers now updates the view correctly afterwards
2009-11-29 05:56:39 +00:00
625a360b4b Animation Editor (mostly Graph Editor) bugfixes:
* Durian Report / Own Todo: Action Groups with no F-Curves in them visible were still shown in the animation editors. After several failed attempts in the past, finally got this working by making a little shuffling + a simpler solution.

* Bugfix #20134: Graph Editor Keys -> Transform Menu was using the wrong operators. C+P error from copying menus over from Dopesheet

* Muting Action Groups didn't draw all F-Curves contained in group as being muted too.
2009-11-29 04:52:01 +00:00
65edb6e55f UI:
* Moved more of 3dview header to python
* Fixed the layout of the ui layers template to show the correct number of buttons
* Added support for layer icons (active layer, used layers)
2009-11-29 02:42:47 +00:00
16efe1ac46 UI Scripts Bugfixes:
* Toolbar shows "Loopcut and Slide" instead of "Loopcut" now
* Follow Path "Offset" option was broken by one of the "use_*" prefix commits
2009-11-29 02:14:34 +00:00
36cbf42e5d Draw function for operators (just like panels), used for the redo popup, file selector and redo tool panel.
Used for ply export & select pattern.
2009-11-29 01:49:22 +00:00
03c897da1b [#20103] Shortcut (Ctrl Space) not working for to show 3d transform manipulator 2009-11-29 00:13:34 +00:00
8b897879cd pep8 cleanup in ui and op dirs, added popup to select pattern 2009-11-28 23:37:56 +00:00
98a7a11e55 bugfix [#20091] Crash when starting render on meta-edit mode
note: EM_DO_UNDO wasnt used because EM_FREEDATA wasnt set
2009-11-28 22:45:47 +00:00
2b9cdd5ebd UI:
* Started moving buttons out of the C 3dview header template and into the python UI script
2009-11-28 22:35:56 +00:00
c6edbe5f2b UI:
* Removed most of the manual positioning from the 3dview header
2009-11-28 21:52:37 +00:00
9e6d1705a4 bugfix [#20050] Hex color value fields capped to 2 characters on first paste.
also use memmove rather then a loop for deleting the selected text
2009-11-28 21:45:34 +00:00
ac4cf783a2 UI/RNA:
* Added icon to paint mask RNA
* Added v3d->scenelock RNA
* Moved more of the 3dview header to use uiItems
2009-11-28 21:27:28 +00:00
2e61294cbc simple fixes
[#20123] "Import" menu entry becomes empty
[#20141] In Object menu Make Links appears twice - SVN 24970

also moved OBJs name cleaning func to bpy.utils.clean_name(name, replace="_")
2009-11-28 20:50:31 +00:00
c7f1ec7c3a bugfix [#20143] .obj import fails 2009-11-28 20:26:22 +00:00
267c8de581 UI/RNA:
* Removed retopo paint code from view3d header
* Added icons to 3dview pivot RNA
* Small warning fix
2009-11-28 20:02:10 +00:00
55c00c53bc UI/RNA:
* Added icons to proportional edit RNA
* Converted proportional edit and snap buttons in 3dview header to uiItems
2009-11-28 19:38:05 +00:00
b52c154f34 - color updating is not working when changing userpefs, added some commented out lines that works when the view in the same window as the userprefs, probably needs a new notifier.
- fix for warning
2009-11-28 19:32:23 +00:00
96900e793c RNA:
* Added ND_DRAW flag to particle selection mode update
2009-11-28 18:37:56 +00:00
da442c1d43 UI/RNA:
* Set default particleedit selection mode in add scene (TODO: not yet changed in the default blend)
* Corrected names for particleedit selection mode in RNA, added icons
* Added occlude geometry flag to view3d RNA
* Converted particleedit buttons to uiItems in view3d header
2009-11-28 18:19:34 +00:00
baa4a9c7d4 CMake/OSX: remove gcc arguments conflicts raising warnings when building in release mode
Quicktime/Qtkit linkflags fix for i386 platform
2009-11-28 18:19:22 +00:00
201f789cee qtkit : improve thread safety, enforce build on OSX 10.5+
qtkit movie creation functions can be started in a worker thread only from OSX 10.5
2009-11-28 18:16:27 +00:00
b3784c4751 * Restored the "Solid OpenGL lamps" Buttons in user Preferences. 2009-11-28 18:08:17 +00:00
cd574f32e6 experemental UI introspection added for mindrones,
in python this gives a map of the ui...
 ui_dict = eval(layout.introspect())
2009-11-28 17:45:23 +00:00
4780f89370 UI:
* Convert pose buttons in the 3dview header to uiItems. Fixes the spacing between pose buttons and opengl render buttons.
2009-11-28 17:30:56 +00:00
1c4150f211 BGE: ray casting works on soft body, the hit polygon is also returned. The modifications to Bullet have been reported to Bullet forum. Note: welding is completely disabled on soft body as it breaks the relationship between the soft body collision shape and the graphics mesh without bringing any additional stability (the reverse actually). 2009-11-28 17:30:34 +00:00
38ba32a423 UI:
* Added icons for the 3d manipulator RNA
* Fixed the snap RNA icon (was off by one)
2009-11-28 17:20:42 +00:00
5814a39aed lasso select for editbones missing flush select call 2009-11-28 15:11:10 +00:00
510c0facdf operator renaming for more consistent word ordering (_add/_remmove shold be last, ACT_OT_* --> ACTION_OT_*)
ACT_OT_clean --> ACTION_OT_clean
ACT_OT_clickselect --> ACTION_OT_clickselect
ACT_OT_copy --> ACTION_OT_copy
ACT_OT_delete --> ACTION_OT_delete
ACT_OT_duplicate --> ACTION_OT_duplicate
ACT_OT_extrapolation_type --> ACTION_OT_extrapolation_type
ACT_OT_frame_jump --> ACTION_OT_frame_jump
ACT_OT_handle_type --> ACTION_OT_handle_type
ACT_OT_insert_keyframe --> ACTION_OT_insert_keyframe
ACT_OT_insert_keyframe --> ACT_OT_keyframe_insert
ACT_OT_interpolation_type --> ACTION_OT_interpolation_type
ACT_OT_keyframe_type --> ACTION_OT_keyframe_type
ACT_OT_mirror --> ACTION_OT_mirror
ACT_OT_new --> ACTION_OT_new
ACT_OT_paste --> ACTION_OT_paste
ACT_OT_previewrange_set --> ACTION_OT_previewrange_set
ACT_OT_properties --> ACTION_OT_properties
ACT_OT_sample --> ACTION_OT_sample
ACT_OT_select_all_toggle --> ACTION_OT_select_all_toggle
ACT_OT_select_border --> ACTION_OT_select_border
ACT_OT_select_column --> ACTION_OT_select_column
ACT_OT_snap --> ACTION_OT_snap
ACT_OT_test --> ACTION_OT_test
ACT_OT_unlink --> ACTION_OT_unlink
ACT_OT_view_all --> ACTION_OT_view_all
ANIM_OT_add_driver_button --> ANIM_OT_driver_button_add
ANIM_OT_add_keyingset_button --> ANIM_OT_keyingset_button_add
ANIM_OT_delete_keyframe --> ANIM_OT_keyframe_delete
ANIM_OT_delete_keyframe_button --> ANIM_OT_keyframe_delete_button
ANIM_OT_delete_keyframe_v3d --> ANIM_OT_keyframe_delete_v3d
ANIM_OT_insert_keyframe --> ANIM_OT_keyframe_insert
ANIM_OT_insert_keyframe_button --> ANIM_OT_keyframe_insert_button
ANIM_OT_insert_keyframe_menu --> ANIM_OT_keyframe_insert_menu
ANIM_OT_remove_driver_button --> ANIM_OT_driver_button_remove
ANIM_OT_remove_keyingset_button --> ANIM_OT_keyingset_button_remove
FILE_OT_add_bookmark --> FILE_OT_bookmark_add
GRAPH_OT_insert_keyframe --> GRAPH_OT_keyframe_insert
NLA_OT_add_actionclip --> NLA_OT_actionclip_add
NLA_OT_add_meta --> NLA_OT_meta_add
NLA_OT_add_tracks --> NLA_OT_tracks_add
NLA_OT_add_transition --> NLA_OT_transition_add
NLA_OT_remove_meta --> NLA_OT_meta_remove
PARTICLE_OT_remove_target --> PARTICLE_OT_target_remove
PTCACHE_OT_add_new --> PTCACHE_OT_add
2009-11-28 14:37:21 +00:00
ac0039bfdb slight reorganization of 3D view UI region. 2009-11-28 13:39:35 +00:00
a2b370dd6f py/rna api
- object.modifiers.add()/remove()
- armature.edit_bones.active wasnt named correctly
2009-11-28 13:33:56 +00:00
c4933cccfa Mesh Deform Modifier
* Now support a Surface mode next to the existing Volume mode. This binds
  the mesh to the cage mesh surface rather than it's volume.
* Implemented reusing the bone heat weighting code.
* Advantage is that it works for cage meshes that are not volumes and that
  binding is much faster.
* Weak point is that disconnected components of a mesh are not guaranteed
  to stick together (same problem exists with bone heat weighting).
* Bind weights could still be compressed better to use less memory.

Example file:
http://download.blender.org/ftp/incoming/cloth_mdef_surface.blend
2009-11-28 13:33:17 +00:00
b83751d8c2 Math Lib: merging over some changes from the sculpt branch:
* swap v2/v3
* multiply-and-add (madd) v3
* inline v3 short/float conversion
* mul_v3_m3v3
2009-11-28 13:11:41 +00:00
9094f2072e Rename 'Object Center' to 'Centroid'. This makes the Center/Center Cursor etc popup menu much easier to understand. 2009-11-28 11:34:04 +00:00
b4aceb0e40 Fixed some more names after the Python UI API changes 2009-11-28 11:32:09 +00:00
bc43e47c2b Bugfix #20127: Crash in dope sheet when opening regression file
Was using wrong pointer to action/keyframe data for shapekey expander channels causing crash
2009-11-28 04:51:15 +00:00
49b828f7fe A few new mouse navigation config options to help transitioning users
* Dolly zoom Vertical/Horizontal switch
  Changes between using vertical or horizontal mouse movement for zooming

* Invert Zoom Direction
   Inverts the vertical or horizontal mouse movement for dolly zoom
2009-11-28 04:43:15 +00:00
aa3ed47848 * New tool - Join as Shapes
Available in object mode (Object -> Join as Shapes), only works for meshes at 
the present. Will merge all selected objects as shape keys on the active object, 
if the vertex count is the same.

This does not keep references to the external objects like in some applications, 
rather it's a quick way to update the shapes on the active object (perhaps after 
importing new versions from external applications).
2009-11-28 04:04:01 +00:00
54c5859578 Durian Rigging Requests: (Armature Layers + Rotation Locking Tweaks)
* Increased the number of Armature and Bone Layers from 16 to 32. Please note that older versions of Blender may not correctly resolve the layers that bones are on when loading new files.

* Newly added objects are now made by default to allow locking of 4-component rotations using 4 separate locks (i.e. one by component) instead of requiring the obscure 'W' toggle (renamed '4L' now) to be enabled first. The objects in the default scene need modifying manually though.
2009-11-28 03:49:45 +00:00
c6b4c2716a Head/Tail property was never added for Track To and Stretch To constraint types. Added to RNA and changed UI check. 2009-11-28 03:45:40 +00:00
afe4879991 Bugfix #20125: View 2D Zoom to Border was missing modal keymap
TODO: a better keymap for specifying zoom in or out mapped to LMB and RMB respectively for zoom to border is required. The current behaviour only allows zoom in...
2009-11-28 02:53:11 +00:00
Dalai Felinto
f3692d5e72 BPlayer fix (we were still using old scene.r instead of scene.gm here) and more stubs update from Mitchell Stokes (Moguri)
(+ a fix in a logic_window.c comment)
2009-11-28 01:26:14 +00:00
e96bd73513 Shaded view toggle key (Shift-Z) not needed anymore. 2009-11-27 21:15:01 +00:00
22f49ffe71 * Small Cleanup. 2009-11-27 18:55:59 +00:00
c3884d9547 shoulder improvements, fixes for linking arm/palm/finger together 2009-11-27 17:07:50 +00:00
20a2100a36 Add missing snap properties to transform operator.
This is used to force snap on and off when needed.

Also, when transform is not run modal, it will use default values for PET and snap properties (False) instead of scene settings. No need to force them off when calling transform with Exec.
2009-11-27 16:15:34 +00:00
994776811f edge loop delete was using snap, making it not actually delete the edge loop 2009-11-27 15:15:03 +00:00
794685da79 CLICK missing from *other* event rna enum (how many of these do we need?!) 2009-11-27 14:58:13 +00:00
552134db45 new palm rig type + some refactoring to make names less confusing for the arm rig
linked text would not run
2009-11-27 13:24:04 +00:00
05079dd773 Re-commit of new icons. It seems like the icon update got overridden somehow. 2009-11-27 12:50:08 +00:00
93b8098e0e Fix for bug #20039: panning and rotating view makes animation playback slow.
Recent click event changes moved variable up one level too far.

Also fixes use of timer event for fly operator, it should always check for
which timer it is, not really related to this bug.
2009-11-27 12:43:48 +00:00
5ca3d1919c fix for undo crashing when animating proxies that had ID props 2009-11-27 12:42:42 +00:00
65c4149f20 Fix for problems with region-flip operator not working from the RMB context menu.
I've had to add a special operator for this, since the generic region-flip operator doesn't seem to be getting the right region from RNA. This operator explicitly searches for an appropriate header region before beginning. I suspect by default, operators get the main region set as being context target...
2009-11-27 11:51:34 +00:00
692115356c Durian Request:
Renaming "Sync Audio" to "Realtime Playback" to make it clearer about its purpose. Internally, it's still called "sync_audio" since that's strictly what it represents, but that could be changed later if there is a need.
2009-11-27 11:19:13 +00:00
993da72d06 Added RMB-menu to Headers:
This contains two entries - one which calls the region flip operator, and one which calls the maxmize area operator. 

Unfortunately, there seem to be some context issues which are causing the wrong region to get activated for use by the region flipping, meaning that nothing happens.


Also, fixed own typo in 3d-view header/menu code...
2009-11-27 06:24:09 +00:00
15087ea783 fix for error in simpledeform modifier ui 2009-11-27 06:22:55 +00:00
54701e28fb Animation Playback - Return to original frame
Playback of animation will now be restored to the frame that playback started on when stopping if the SCREEN_OT_animation_cancel operator is used (i.e. ESCKEY). 

All other ways of stopping playback (pause button, alt-a) should act more like toggles, and do not reset the playhead.
2009-11-27 04:14:56 +00:00
2cb7a0b25c Fix for [#20080] Arrows Don't Scale (2.5 Alpha 0) 2009-11-27 00:45:01 +00:00
f3fbef04e9 Fix for [#20086] Mirror X, Z and Y crashes Blender 2.5 Alpha
Was wrong operator context

* Also added back 3d view locking options to view properties
2009-11-27 00:34:46 +00:00
d5267611f1 UV Editor: Added missing Snapping Operator keymaps (Shift-S) + menus (under UV's -> Snap) 2009-11-26 23:20:31 +00:00
af244d0403 Fix for rev. 24908 - committed the fix, but it was commented out. Forgot to uncomment it after doublecheck testing, hmm... 2009-11-26 21:56:31 +00:00
b6ea979690 MSVC project files: enable Blender Game renderer. 2009-11-26 20:44:55 +00:00
74715d00cc First changes to implement the 2.5 snapping proposal (discussed back in May and recently on IRC).
http://wiki.blender.org/index.php/User:Theeth/Snapping

The new widget isn't there yet, but the rest works, including:

Increment (gears) is now a snap mode

Ctrl click to toggle snap on or off (in transform and 3d view)
Shift+Ctrl click to select snap mode (3d view only)

Snap status (on/off) is persisted in tool settings, no need to always turn it back on when entering transform.

It's still possible to have something resembling the old system by editing the transform modal keymap to snap on on ctrl press and snap off on key release.
2009-11-26 19:47:55 +00:00
6ca1c913d3 Simplify mesh selection type operator and add missing header refresh notifier.
Also remove REGISTER flag from operator (no need to see this in operator history).
2009-11-26 19:32:33 +00:00
b658febb6a Missing from last commit:
New snap icons for Increment (gears)
2009-11-26 19:31:25 +00:00
deb942702d Preliminary RNA and DNA changes for further transform snap fixes.
Also make the mesh selection type enum available at runtime.
2009-11-26 19:29:57 +00:00
5457ab4fc3 fixed a crash when duplicating bones with ID-Props
remove duplicate code from armature_duplicate_selected_exec
2009-11-26 19:08:56 +00:00
9d026b30e7 more rna property renaming, axis_x --> use_x, rotationx --> use_rotation_x 2009-11-26 18:45:08 +00:00
7762aa8027 Click event detection ignores mouse move.
This makes it less tricky (don't have to hold the mouse extra still) but tweak events (like lasso) still  don't result in a click.
2009-11-26 18:36:24 +00:00
0a7b235199 rename rotate_like_x --> use_x, for copy loc/size/rot constraints.
including rotate in the property name isnt needed since its a copy rotation constraint.
2009-11-26 17:54:16 +00:00
3764c1ea26 Fixed typo 2009-11-26 17:20:02 +00:00
102f57ef26 fix for crash, Aligorith can you check if this is correct 2009-11-26 17:17:13 +00:00
a1b6b99a97 Fix warning. 2009-11-26 17:07:14 +00:00
383093957a Mathutils vec += vec wasnt running mathutls callbacks 2009-11-26 16:19:20 +00:00
c3937c93d5 minor changes made before commit broke this script 2009-11-26 16:05:32 +00:00
64f552356a ctrl 1-5 for changing subsurf levels 2009-11-26 15:36:23 +00:00
cd104206e7 allow accessing an array index from an rna button.
col.prop(ob, "location", index=1) # would edit the Y axis
2009-11-26 15:03:55 +00:00
68b100232b basic support for Sintels arm rig with property driven ik/fk switching and stretch bones to display connections, still need to do shoulder hinge and hand delta offset bones 2009-11-26 13:36:15 +00:00
0eb70a4ca9 Sequencer Drawing Code - Refactoring Part 1:
- Started cleaning up the sequencer drawing code by firstly decoupling the different draw modes from each other (i.e. timeline view doesn't call image view). 

- Also separated out a few distinct few phases in sequencer-timeline drawing into different functions instead of being lumped in the single one. Recoded part of this to make it less ugly too...

- Made markers get drawn again in the sequencer timeline view
2009-11-26 12:22:43 +00:00
7828f822df Bugfix: pose bone was doing double translation in some cases,
due to my commit yesterday.
2009-11-26 11:38:28 +00:00
802cc77f71 Patch #20037: Use named components for Drivers instead of array_index
This patch, by Elia Sarti (vekoon), simply adds the possibility to specify the final array component of the RNA path in the path itself, 
e.g. using location[0] or location["x"] or even location.x,  
instead of specifying this using an "array_index"

This should be easier for users to understand the driver system. The array-indices have been kept (but hidden from the UI under standard situations) since they are theoretically a tad faster than the in-path lookups still, and are easier for internal-tools to set for now...
2009-11-26 11:13:10 +00:00
baac1f2267 Bugfix #20069: Centre to cursor or centre to mouse, centre object.
- Was missing notifier after editing
- Menu entries go bad naming after the UI api renaming
2009-11-26 10:19:09 +00:00
9712e3a670 fix for adding drivers to constraints via python.
the RNA constraint api was checking the current context when getting the constraint driver path and renaming constraints.
this made scripts not work properly so changed this to search for the constraint pose channel user within the object (if the object its self is not the user).
2009-11-26 09:48:53 +00:00
8d9fba6568 BGE: allow using dynamic loaded mesh in replaceMesh for soft body. This is a quick fix, it doesn't work yet on skinned mesh. 2009-11-26 09:40:37 +00:00
6e467285cf [#20051] x for removing a mesh from a group doesnt scale with ui 2009-11-26 06:32:43 +00:00
42e8eb36bd Fix for [#20042] There are remains of "Shaded" draw type in a panel
Removed references to shaded view now it's disabled
2009-11-26 06:25:25 +00:00
5b7e83e5e2 Fix for [#20030] selection frame in edit mode turns white 2009-11-26 06:07:56 +00:00
543d8112ff Fix for [#20028] adding objects such as cameras in local view(/) doesn't work
Was getting the wrong operator context, so there was no view3d available
2009-11-26 05:57:34 +00:00
a9dff1ef57 Fix for [#20023] Renderer aborts in some cases when rendering only meta-objects with volume materials.
When metaballs were added to the render, if they weren't the basis ball, they'd be skipped, leaving a render object with no geometry. Now it doesn't add an object in the first place.
2009-11-26 05:01:28 +00:00
1fcffd1aa0 Bugfix #20041: Drivers don't work on bone visiblity
- Drivers on added to the 'armature' datablock (i.e. keyframing some settings for a "Bone" as opposed to "PoseBone") now evaluate correctly. Added proper recalcs for this case too.

- Also fixed some memory leaks and loading problems I encountered with the test file provided. After having problems loading the test file, I ended up reproducing and finding the error.
2009-11-26 03:43:39 +00:00
eee8bf344a Cursor Grab bugfix: passing NULL for bounds didn't initialize properly.
Symptom: first button drag gets stuck on values.

Cause: Buttons didn't set grab bounds, to use the whole window. But Ghost didn't do anything in that case, it left the bounds value as is. It only affected the first cursor grab, because cursor ungrab sets it to -1, which forces it to use the whole window size (checking every mouse move) for subsequent grabs.

Solution: When NULL, init bounds to window size (and don't query every mouse move).
2009-11-26 02:58:53 +00:00
cbc2c1886d * Spline IK 'Joint Bindings' array now available from RNA. This can be used to manually slide bone joints along the curves for extra tweaking. It's only recommended to be used by advanced users for extra control over the points.
* Added some missing file-reading code to try and get things working better
2009-11-26 02:13:56 +00:00
ca3a9f184f Fix for [#20034] Background Image Distortion while zooming and moving around 3D window.
This is working around an Apple OpenGL driver bug, chatted to Martin about this in IRC, seems ok. Hopefully can revert this if/when Apple comes up with a driver fix.
2009-11-26 02:11:07 +00:00
6a30bc6816 v Cloud to matrix
nice drawing for soft bodies
BTW could be used by any object by design
2009-11-26 00:15:26 +00:00
12968cdd8a adding function
vcloud_estimate_transform(..) to math library
comments there (@math_geom.c) should explain what it does
-- removing attached clutter from softbody.c
2009-11-25 23:54:21 +00:00
a306759b7a small change to BGE callbacks, only allocate empty args once in the callback loop. 2009-11-25 23:35:58 +00:00
aa5227664a After talking with Matt about this, added notifier NC_ID to handle ID changes, specifically ND_ID_RENAME for ID renaming. Done for outliner, 3d view and properties editor. 2009-11-25 23:13:47 +00:00
f6b0389394 Fix for opening images in the Background Image panel 2009-11-25 22:58:54 +00:00
c2762c28e4 Editmesh undo: restore selection counts after undo 2009-11-25 22:38:07 +00:00
8709f13a3b Decrease snap delay to 10 ms 2009-11-25 22:14:51 +00:00
2b121e6599 Pose Bone Local Location: now also works for non-connected bones with parents. 2009-11-25 18:48:29 +00:00
2582e3a900 Sculpt: fix windows compile issues, pointed out by JMS, thanks! 2009-11-25 18:20:46 +00:00
55d2a56d60 Sculpt:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24483:24889
2009-11-25 17:51:16 +00:00
323aa65671 Verlet integration method for particles (patch provided by farsthary). 2009-11-25 17:46:10 +00:00
553374bd4c selected_pchans --> selected_pose_bones, same for visible_pchans
added use_ prefix to bools offset --> use_offset, tail --> use_tail for eg.
2009-11-25 15:00:29 +00:00
b129ccf000 Pose Bone "Local Location" option. This is enabled by default, disabling it
puts the bone location in pose space rather than local bone space.
2009-11-25 14:59:02 +00:00
077edbb384 Sculpt: external file storage for multires
* This is experimental, the file format may change still!
* Helps reduce memory usage, keeps .blend files smaller, and makes
  saving quicker when not editing multires.
* This is implemented at the customdata level, currently only the
  multires displacements can be stored externally.

ToDo

* Better integration with object duplication/removal/..
* Memory is not yet freed when exiting sculpt mode.
* Loading only lower levels is not supported yet.
2009-11-25 14:27:50 +00:00
436969ce49 Sculpt: Fast Navigate option for multires. This will show the lowest multires
level when rotating/panning/zooming the viewport, and only draw the full thing
at the end, to make the viewport more interactive.
2009-11-25 14:13:43 +00:00
2fd2c04381 Sculpt: multires UI update. 2009-11-25 14:10:45 +00:00
fffce6c554 Sculpt: Multires
* Displacement coordinates are now stored differently, as a grid per
  face corner. This means there is duplication of coordinates, especially
  at low subdivision levels, but the simpler implementation justifies it
  I think.
* ToDo: conversion of existing multires files (2.4x or 2.5x), loading them
  may even crash now.
* Editmode preservation/interpolation code also has not been updated yet.

* Multires now works on the CCGDerivedMesh grids instead of CDDerivedMesh,
  which should be more memory efficient.
* There are still bad memory peaks (if you're using 32bit) when subdividing
  or propagating displacements. Though at least there should be no huge
  memory blocks allocated, which windows is now to have trouble with.
* Still found some weird spike artifacts at lower multires levels, some also
  happening before this commit. Perhaps computation of tangents needs to be
  tweaked more.

* Multires modifier now has viewport, sculpt and render levels. Also the
  levels have been made consistent with subsurf, previously the same level
  of subdivision was one less for multires.
* Both multires and subsurf modifier now can have their subdivision level
  set to 0 for no subdivision.
2009-11-25 14:07:12 +00:00
134935a8db Sculpt: Grid based PBVH
* PBVH can now be created contain both from face grids or standard
  meshes. The former is much quicker to build for high res meshes.
* Moved some drawing code into pbvh (mostly for the frustum test).
* Moved ray intersection code into pbvh.
* GPU buffers also can be built from either mesh or grids now.
* Updated sculpt code to work with this. The ugly part is that there
  is now a macro for iterating over vertices, to handle both cases,
  and some duplicated code for e.g. undo.
* Smooth brush does not work yet with grids.
2009-11-25 13:40:43 +00:00
f1fa79a595 fix for error in sequencer ui from recent changes 2009-11-25 13:17:09 +00:00
a1bf207be3 Sculpt: Subsurf
* Now uses the CCG DerivedMesh also in object mode, used to be edit mode only.
* Create CD_ORIGINDEX layer on demand, to save memory.
* Removed ss_to_cdderivedmesh function, and instead create ccgdm and then
  convert that to cddm, to avoid code duplication.
* Added and implement DerivedMesh interface functions to obtain face grids.
* Store edge/face flags more memory efficient.
* Export CCGDerivedMesh struct in BKE_subsurf.h
2009-11-25 13:11:44 +00:00
90cc7c8abd Sculpt: CCGSubsurf new functions to update normals, update subdivision
levels, copy coordinates from face grids, and stitch together face grids.
2009-11-25 12:27:21 +00:00
9a31f37d19 Sculpt: math lib functions
* swap v2/v3
* multiply-and-add (madd) v3
* inline v3 short/float conversion
2009-11-25 12:04:11 +00:00
6c881a7a6d AnimSys - Transform Locks + RNA:
The Animation System now respects the Transform Locks too (i.e. lock x-location, etc.) when writing settings. This means that it is no longer necessary to set up "constant drivers" to make sure some values don't get accidentally animated. 

Internally, added a new callback for properties in RNA, which is responsible for checking if the item at some array-index is editable. This needs to be manually called for each place which uses rna to set settings for arrays (see the code changes in anim_sys.c for changes how to do this; the same thing needs to be done in the UI code too, and probably in py-api too)
2009-11-25 12:00:31 +00:00
e57792feb4 Sculpt: tweak to memory statistics graph, showing both % and MB. 2009-11-25 11:59:57 +00:00
4c5b430520 ED_armature_edit_bone_remove wasnt clearing references from other bones, only affects rna api access 2009-11-25 11:47:53 +00:00
b40307df16 add access to bone add/remove from rna. eg.
bone = arm.edit_bones.new("SomeBone")
 arm.edit_bones.remove(bone)

regify (WIP)
2009-11-25 11:05:11 +00:00
50e3bb7f5f RNA: FModifier generator coefficients wrapped, implemented by Campbell. 2009-11-25 10:39:02 +00:00
c410a0e855 rna py api,
generic rna function driver_add(), now returns the driver added (or a list of drivers if all channels are set)
2009-11-25 10:13:24 +00:00
802779eb2d Assorted fixes - compile + drivers:
* Fixed a few compile warnings for scons+mingw
* Driver variables are now added with the ID-type set to ID_OB (objects) by default since this is more convenient
2009-11-25 09:25:58 +00:00
ce4b63aa3f Fix for [#20008] In the Graph Editor, clicking on the eye doesn't update the GUI
As part of this, fixed a typo in rna flags which was causing some strange behaviour with icons earlier. Reverted the workaround for this, too.
2009-11-25 08:28:57 +00:00
7b6bc0225d Add guardealloc for RAS_MeshObject.cpp (and clean whitespace). 2009-11-24 23:24:56 +00:00
5b722b1e87 BGE: replace mesh works for Soft Body (including reinstantiation of physics soft body mesh).
Even a static mesh can be used as replacement: the mesh
will be instantiated with the soft body settings of the
object. The position and orientation of the soft body
is preserved after the replacement.

Known limitation: the velocity of the soft body is reset
aftet the replacement. This is because soft body don't
have a well defined velocity.
2009-11-24 22:44:29 +00:00
6c55047b40 disallow dynamic sized rna arrays to be returned as mathutils types since it gives unpradictable results if in one case it returns a vector and another a rna float array. 2009-11-24 20:15:24 +00:00
1aebd524a2 Fix for continuous grab on X11.
Need to stop accumulating warp coordinates after the first cursor warp (store time of new generated event and skip warp for events time smaller).

There's some interesting X11 code in there, if people are curious.
2009-11-24 19:47:57 +00:00
dcd1642121 RNA api
- EditBone was missing 'selected'
- renamed 'selectable' to --> 'restrict_select', matching object mode.
- renamed 'active_pchan' --> 'active_pose_bone'
2009-11-24 17:12:32 +00:00
f28975dbc4 avoid operator type lookups when its known 2009-11-24 16:19:15 +00:00
6d7bb6593f Forgot this file. 2009-11-24 15:45:45 +00:00
d2c999020c Updated icons. Thanks to jendrzych.
Adds icon entries to the force fields.

Also reverted last menu naming commit - this is apparently due to a bug in the Python API that will be fixed.
2009-11-24 15:40:56 +00:00
89f9d3873d bugfix [#19983] clicking onto normal input of a material node crash
actually happened when clicking on any input
2009-11-24 14:03:29 +00:00
f21eb0603b Render Buttons:
* Made Audio Section in "Encoding Panel" easier.
2009-11-24 12:55:04 +00:00
284f66acf7 Fix for last commit, forgot to update collada. 2009-11-24 12:35:06 +00:00
2d4f112b18 Fix wrong names in 3D view View menu 2009-11-24 12:15:17 +00:00
ff5276b0ce - use a generic bone class so all 3 bone types (Edit/Pose/Armature) - can have the same utility functions, length, parent_recursive, parent_index(), etc
- change the wiki url to avoid redirects (from Luka)
- removed pose prefix from pose_head/pose_tail/pose_matrix
2009-11-24 11:58:49 +00:00
2e7dbdf025 Depsgraph/Drivers
* Removed ED_anim_dag_flush_update and ED_anim_object_flush_update. These
  were wrapping DAG_* calls and were intended be used instead of them when
  doing a DAG update from editors. That goes against the design in my opinion,
  no matter who calls the DAG, that should update the editors correctly, so
  any special checks in such functions for editors should be avoided.

* Driver RNA properties now do updates again, including DAG scene sorting,
  text buttons no longer update as you type anymore, so this should be
  safe I think.

* Remove scene.update() RNA function, all properties/functions should do this
  automatically, if changing some property or calling a function/operator
  does not do the correct update, that should be fixed.
2009-11-24 11:48:16 +00:00
397b52bdc7 Removed split region operator. This was only for tests, and was not recoverable. 2009-11-24 11:40:35 +00:00
96b6f32c54 Made render quality settings proper percentages. 2009-11-24 10:55:52 +00:00
78ce1fb6ca compile fix when compiling with WAIT_FOR_VSYNC = 1 (btw, is this still used ?) 2009-11-24 10:19:07 +00:00
0f280e631f Spline IK Bugfix:
"Y Stretch" option was broken in UI due to mismatch between RNA and scripts.
2009-11-24 09:55:41 +00:00
82a1ec17ce quicktime : small ui update to include the two qt import options in the output panel
+ pep8 fixes
2009-11-24 09:46:53 +00:00
d55ac4da2b - added rna api function scene.update(), needed for rig generation to update driver deps
- removed some warnings
2009-11-24 09:24:32 +00:00
85301a57bf Bugfix for Parenting to Bones:
Reshuffled the code a bit so that the parent-type gets set before the parent inverse matrices are calculated.

Thanks to Claas Eicke Kuhnen (cekuhnen) on Blender Artists for catching this.
2009-11-24 05:57:47 +00:00
2597d49664 Extend handler return values to distinguish between events that have been handled and passed through and those that haven't been handled at all.
This also solves a bug with Click event (not visible with keymaps that use Click in default)
2009-11-24 05:03:44 +00:00
4dd78dcbdf Made select operator return FINISHED only when it did something (only PASSTHROUGH otherwise) 2009-11-24 04:59:52 +00:00
1c4599522c Add CLICK to keymap RNA 2009-11-24 04:30:24 +00:00
04c68559bb Keyframing Operator Tweaks for Durian:
* Insert Keyframe (IKEY) now only shows the menu requesting to choose a KeyingSet to use if there is no active KeyingSet. To get the old behaviour, the "always_prompt" boolean property for the "ANIM_OT_insert_keyframe_menu" operator should be supplied.

* After inserting/deleting keyframes without the menu, a popup menu confirming that the keyframes have been modified is shown. Please note that you do not need to click on this popup.

TODO:
Make the confirmation popup fade out after a fixed time.
2009-11-24 04:21:32 +00:00
6ece643979 removed mmb pan/rotate user preference - this is handled by key maps now 2009-11-24 02:07:57 +00:00
Dalai Felinto
acdc3f4a44 commenting out "Todo" labels from bge player stereo options
the To Do was more like self-remaining since no one else is currently working with stereo :)
I will get back to that once 2.5alpha0 is out. In the mean time let's have a cleaner interface.
2009-11-24 01:09:19 +00:00
d594320c7f RNA update -- added RNA and functions for dealing with the clone UV layer for projection painting. This is just the guts -- someone smart can hook up the UI. 2009-11-24 00:56:52 +00:00
727d9bb059 rig-generation from metadata, the idea is to input a simple rig with metadata matching preset definitions
these are applied by adding constraints, drivers, control bones etc. making it possible to re-apply changes & improvements to many rigs at once.

testcase makes a finger rig (like in BBB) from 3 bones, the base tagged with an id property "type":"finger".

still missing is a way to update the driver dep's


also fixed an error  in the property UI when the active bone is not on the active layer.
2009-11-24 00:02:21 +00:00
e968017951 - new pyrna api functions srna & prop path_to_id(), useful when setting driver target paths.
This means you can have a pose bone for eg and get the path...
   pose.bones["Bone"]
 uses rna internal functions, so will work for sequence strips etc.

- StructRNA.get(), used for getting ID props without exceptions...
 val = C.object["someKey"]
 or..
 val = C.object.get("someKey", "defaultValue") # wont raise an error

- change rna property for testing if rna props are editable, test the flag rather then calling the function since the function depends on blenders state.

- fix a python exception with the ID-Property popup UI (when editing in more then 1 step)
2009-11-23 23:17:23 +00:00
b7d717cead added a function to duplicate bPoseChannel's internal data - constraints, id-props etc.
duplicate_pose_channel_data(), the code to do this was inline in editarmature.c

duplicating editbones now duplicates posebone id-props

also removed an if test for &channew->constraints since it will always be true.
2009-11-23 23:03:04 +00:00
9702ea7537 Improve links. 2009-11-23 21:17:53 +00:00
af1f542367 2.5 bugfix: splash would crash when .Blog contained file names without a
slash in them. Also removed the ctrl+alt+f1 shortcut key, was for testing.
2009-11-23 20:06:09 +00:00
f421558ac7 Fixed weird wrong names in Add menu. 2009-11-23 19:59:42 +00:00
e54fe21a43 Fixed a link and added irc.freenode.net for clarity 2009-11-23 19:26:59 +00:00
052290d2b3 fixed some error reporting issues with calling operators 2009-11-23 18:08:42 +00:00
4c03ce9100 fix for crashes displaying long strings in menu's 2009-11-23 17:55:52 +00:00
1c806f6bb4 workaround for an error with BKE_reportf (actually BLI_dynstr_vappendf)
fixes a crash that happens when formatting a python exception into a report. - for now use pythons string formatting function.

happens when running the simple operator template so not sure if its worth re-tagging :S
2009-11-23 17:36:44 +00:00
e2a5862e8f Two files missing in case conversion in r24816. 2009-11-23 17:27:00 +00:00
2dac330ac0 Remove forced sse compile flags on render for linux. This is very bad.
Use user flags instead.
2009-11-23 17:12:15 +00:00
53667cc693 2.5 bugfix: 3d view zoom operator delta had wrong range. 2009-11-23 17:07:30 +00:00
4cac7c88aa bugfix: uninitialized values 2009-11-23 16:58:24 +00:00
fe14b6d544 2.5 bugfix: transformation constraint values did not have correct range. 2009-11-23 16:53:29 +00:00
d1f314a217 New CLICK event value. If RELEASE is not handled and last event was PRESS of same type, redo handlers with CLICK value (this means you can "click" key events too).
Leftmouse+Ctrl to extrude now mapped to Click instead of Release. Release was used to avoid conflict with lasso, but it isn't safe with modal operators that use Press to confirm (subsequent Release then extruded). Click is semantically closer to what we want here.
2009-11-23 16:24:28 +00:00
66a013b06a use decorators for python attributes, added bone.length 2009-11-23 16:04:19 +00:00
bd1de4b4e3 made release log link point correctly to the release log. 2009-11-23 15:41:57 +00:00
190de2b664 remove F7 for running test.py, was useful when we had a py api but not text editor :)
this gets rid of F7 next to all the presets
2009-11-23 15:22:23 +00:00
f4d3ce197b links to Python API docs from splash and help menu 2009-11-23 15:20:56 +00:00
c0e26df259 2.5: fix python error when showing 3d view properties panel
with no active bone.
2009-11-23 15:19:30 +00:00
d92c151cb9 Beta -> Alpha ;) 2009-11-23 15:17:37 +00:00
a2c0f3dac4 missing include for memset() 2009-11-23 15:08:42 +00:00
f92524ab7d use lowercase filenames, they are prettyfied for the menu 2009-11-23 15:04:43 +00:00
6eaf249bc5 Replaced the blender.html file with a new readme.html
The old file was very outdated, messy and included lots of excess information.
The new one is more specific to Blender 2.5 and is more concise, to the point.
Additionally this should mean we can avoid having a release_250.txt file in addition to this, to help clean up the install folder.
2009-11-23 14:59:39 +00:00
cb51710f25 pose_bone attributes, children, children_recursive, parent_recursive & parent_index() function. 2009-11-23 14:58:27 +00:00
6b56738089 2.5 alpha0 splash image, by david revoy!
Now will check if we can call for ahoy...
2009-11-23 14:51:50 +00:00
cb255ba324 First of 2.5 alpha0 release commit 2009-11-23 14:51:05 +00:00
d459c9c9ab rename PoseChannelConstraints to PoseBoneConstraints 2009-11-23 14:08:04 +00:00
7b036e1dcb Splash screen, implemented by Matt.
* Now has documentation links and recent files.
* Click on image or outside splash to make it go away.
* Still has old image, new one will be committed later.
2009-11-23 13:58:55 +00:00
fc1c411e2c shaded mode isnt working in 2.5, comment for now 2009-11-23 13:52:08 +00:00
1baaa0134c copying a pose didnt copy its ID props, both poses would reference the same pointer (made proxy on objects with ID-prop pose channels fail) 2009-11-23 13:35:21 +00:00
fbeca721a2 Typo, it's called Skim, not Skin. reported by Oxben. Thanks! 2009-11-23 13:19:30 +00:00
e9db9f2a91 - made properties in the view3d panel only show when there are some properties available since this the option to add props isnt in this panel
- remove print on startup
2009-11-23 13:06:26 +00:00
78b76cc39f Auto-Keyframing and Clear Transform Operators:
Clear Location/Rotation/Scale (Alt-G/R/S) now insert keyframes when Auto-Keyframing is enabled.
2009-11-23 11:58:30 +00:00
f8d40d2da0 2.5 internal bugfix: remove modal handlers before exiting the screen,
since these may be using it.
2009-11-23 11:49:23 +00:00
e0fc6d0c33 more ui api changes.
- remove functions such as operator_int(), operator_enum(), operator_string
  this mixed with keyword arguments in a way that made them hard to read.
  Instead, have operator() always return properties rather then needing an argument.

- rename prop_pointer() --> prop_object(), pointer is more a C thing.

- missed item_enumR(), rename to prop_enum()
2009-11-23 11:43:38 +00:00
c6dbbde16b Various bugfixes:
* Tweaked the code for operator buttons so that only those operator buttons in the toolbar have their text left-aligned. This is done at layout-block level

* Silenced "file_init" print when opening the file browser

* Disabled animateability of the "active_shape_key_index" for Objects, since this property behaves in a very unpredictable manner, leading to problems with users trying to keyframe shapekey values and ending up keying the list. 

* Remove some unnecessary RNA wrapping code
2009-11-23 09:47:56 +00:00
7617736bd1 fix for py errors and missing return 2009-11-23 09:28:42 +00:00
8224dff9e2 Bugfix - Hook Operators:
These now work for curves, nurbs, and lattices in addition to meshes again.
2009-11-23 02:27:52 +00:00
acf837e3c5 epydocs for bge pre/post render callbacks 2009-11-23 01:10:47 +00:00
8e09171d5b temp hack to make the popup show wider when running the edit description operator 2009-11-23 00:56:19 +00:00
caab05ec8c rna UI api rename...
note: this aims to follow pep8 however I chose to use 'prop/props' rather then 'property/properties' because it would make function names too long.

itemR() --> prop()
items_enumR() --> props_enum()
item_menu_enumR() --> prop_menu_enum()
item_pointerR() --> prop_pointer()
itemO() --> operator()
item_enumO() --> operator_enum()
items_enumO() --> operator_enums()
item_menu_enumO() --> operator_menu_enum()
item_booleanO() --> operator_boolean()
item_intO() --> operator_int()
item_floatO() --> operator_float()
item_stringO() --> operator_string()
itemL() --> label()
itemM() --> menu()
itemS() --> separator()

batch script used http://www.pasteall.org/9345
2009-11-23 00:27:30 +00:00
6555eca6fe 2009-11-23 00:03:51 +00:00
215acdd803 * Changed default shortcut key for 'center view to cursor' to ctrl numpad . 2009-11-22 23:57:06 +00:00
c4a71795f5 Bugfixes:
* Restored Center View to 3D Cursor. For now, I've mapped this to QKEY since all other nice combinations of CKEY have been taken now.

* Fixed bug introduced in commit last night where parenting lattice to armatures with deforms would no longer work.
2009-11-22 23:11:32 +00:00
d83b251486 Repair display of iTaSC IK constraint. Fix crash in GE with high priority action overwriting low priority action. 2009-11-22 22:42:57 +00:00
042f52b162 * Fix for [#19941] File Browser : inability to select multiple files
Added border select on LMB tweak by default, and added shift-lmb to select multiple
2009-11-22 22:23:58 +00:00
b351d7804b needed to assign some values as bool's 2009-11-22 22:09:06 +00:00
ab6b1a363f Fix MSVC project files for blenderplayer: the player compiles and runs properly in debug and release mode. Still a problem with scons: the player compiles but crashes on startup. 2009-11-22 21:55:59 +00:00
dc5b0c8b9c rna functions were getting away with passing the string "True" instead of True, changed get the integer value and test its 1 or 0.
allow rna function return values as an exception since so many poll functions do... "return (context.blah and context.foo)", that makign all return bool's isnt that nice.
2009-11-22 21:51:12 +00:00
9c602bd455 note:
for a single tuple the last comma is needed. ('SOUND', ), otherwise its just a string.
 
 string in "STRING"
...is the same as
 string in ("STRING")
...which checks the substring, its normally used like this
 if string in "maybe one of these words contains STRING"

in this case its better just to do ==
2009-11-22 21:47:55 +00:00
db164d8849 Sequencer:
* It's now possible to set the scene for a scene strip.
2009-11-22 21:16:04 +00:00
2c461af8a3 == Sequencer ==
Broad back SCENE-rendering. (Hopefully did everything right)

Still missing: UI part (one can't select a scene, neither on add nor
in N-keys dialog...)
2009-11-22 20:49:13 +00:00
4f21b1fcba Adding undo flag to the python run flag operator.
It's safer this way.
2009-11-22 20:26:54 +00:00
c0a6d07212 filebrowser
* fix typo in operator property
* respect user setting for hide dot files
2009-11-22 20:24:36 +00:00
42f99939f6 == Sequencer ==
This should make animations in sequencer work again at most
places.

It removes facf0 and facf1 and replaces them by

* effect_fader (the fader position for transition effects
  limited 0-1 value range)
* speed_fader (full range fader for speed effect)

Also: default transitions should work again.

Still not working: non-IPO-locked curves. (Don't really know,
if we can / want to bring them back in new animation system.)
2009-11-22 20:22:35 +00:00
85080f9e3f blender.html:
* Renaming header to alpha 0.
* Some updates for the Python Installation notes.
2009-11-22 18:57:16 +00:00
aa77377052 == Sequencer ==
seqUniqueName() call was missing for effect strips.
2009-11-22 17:58:33 +00:00
bdb8004165 use is rather then == when comparing with singletons (None/False/True), its faster and suggested by pep8 2009-11-22 17:41:35 +00:00
4ff3af612c == Sequencer ==
"reload" should be "refresh all" on the sequencer header.
2009-11-22 17:35:26 +00:00
1295a213a4 2.5: Emulate numpad works again. 2009-11-22 16:33:47 +00:00
43e7950092 CMake: OS X build did not have proper warnings set by default, copied the
flags from non-apple Unix configuration.
2009-11-22 16:33:00 +00:00
8a50bcb163 * Update of the blender.html. Still lacks a bit, but better than before. Everyone, feel free to improve. 2009-11-22 15:19:18 +00:00
1d7e4e84d0 fix for py error when no text is displayed 2009-11-22 15:15:11 +00:00
20dc752e14 missing decref from patch #19258 2009-11-22 14:57:19 +00:00
c36f78dd41 [#19258] [patch] Adding drawing capabilities to BGE Python
patch from Mitchell Stokes (moguri)

simple use case
 scene.post_draw = [pyOpenGLFunc]

this only needs to be set once, then the funcion runs each redraw.

note, this patch also changes how python scripts run (not modules): Dont clear the namespace after running a script, since functions still use the namespace, BGE API is now better when dealing with stale data.

made some changes to this patch.
- assigning a list didnt decrement the existing list.
- initialize as NULL rather then a blank list
- dont use string comparisons for the callbacks, pass the python list to use instead.
- dont check the list items are callable. python will display an error if they are not.
- use python list macros that dont do any type checking sine blender does this when assigning the list

---- from tracker, edited since an updated patch changes some things.
Here is a patch to be able to draw to the screen with BGE Python. This will be very handy for GUI stuff. This patch
works by having the user register a callback in the scene. Two options are available KX_Scene.pre_draw
and KX_Scene.post_draw. The difference between these is when Python draws to the screen (before or after the BGE).
Each can take a list of functions. Here is an example that draws a blue semi-transparent
2009-11-22 14:42:22 +00:00
f4a0c9239f * Added fps and fps_base to some Render presets. They were missing there. 2009-11-22 14:10:58 +00:00
8be7b757e3 * New option on modifiers that don't change topology: Apply as Shape
Rather than applying the modifier to the object data, it will create a new shape 
with the deformed vertices in there. Only mesh at the moment, other object 
types on the todo.
2009-11-22 13:44:09 +00:00
8fdaa263c0 MSVC 9 projectfiles
* Added GLEW_STATIC where necessary to make Blender compile again
* First attempt at compiling blenderplayer again - compiles, but doesn't link yet 
* removed deprecated SND_ functions from blenderplayer
2009-11-22 13:15:36 +00:00
247f9cfc04 - add cloth button wasnt working because it was set to execute the operator.
- for adding an operator, start with a blank name and dont write the default one. (still writes each name you type in, will need to fix this properly)
- move the AddPresetBase class into presets.py since all the presets are defined there.
2009-11-22 13:15:21 +00:00
0fe908181e Just a few compiler warnings... 2009-11-22 12:45:37 +00:00
220669d1fd Parenting and Deforms:
Parenting an object to some deformer (i.e. Armature, Curve, Lattice) now adds a new modifier if the object is deformable.

The advantages of this over setting PAR_SKEL mode are:
- instead of a hidden 'virtual' modifier, the user has direct feedback about what sort of modifier is being applied to deform
- most of the time in 2.4, whenever a virtual modifier was added, users would inevitably end up clicking "Make Real" on it

Of course, it's still possible to get 'virtual' modifiers by setting the parent type using the menu-property, but this just makes general setup easier.
2009-11-22 12:28:38 +00:00
8e877c1f9f Added a first version of the Sound F-Curve Modifier, not really usable yet, but you can play around with it. 2009-11-22 12:10:45 +00:00
8b84cc2ab6 use context member rather then modifier name in presets 2009-11-22 11:33:44 +00:00
771406df94 - hide members of bpy from dir() and autocomp.
- path functions bpy.utils.script_paths(), bpy.utils_preset_paths(subdir)
- further simplified presets, use a generic draw function for preset menus and define the preset subdir and operator in the class
2009-11-22 11:23:19 +00:00
058454368a Small tweak to file-loading code for F-Curves so that F-Modifiers using library data get re-loaded correct 2009-11-22 11:15:38 +00:00
02e99b9a43 * Minor cleanups.
* Added Cloth Presets. Patch by nudelZ. Thanks!
2009-11-22 10:32:37 +00:00
07db9033c9 * Minor Cleanup. 2009-11-22 10:06:08 +00:00
adb14a2247 remove template uiTemplate_view3d_select_faceselmenu 2009-11-22 10:02:32 +00:00
8f8d5d3bdc * Made particle painting use leftmouse, rather than actionmouse, consistent with other paint tools 2009-11-22 06:27:17 +00:00
6e5cf0f3ee Patch #19953: [2.5] repeated include entries in a number of SConscript files
Thanks for the patch Jeff Doyle (nfz)
2009-11-22 06:22:53 +00:00
8e76e2d09c * Re-implemented/refactored 3D View hooks menu.
Now shares the same operators as the modifier buttons, works context-sensitive, and uses Python menu too.

* Cleanups/tweaks in 3D View vertex group menu
2009-11-22 06:20:56 +00:00
bb43bee5f5 Missing Transform Menus + Buggy Object Operators:
* Added missing menus, 'Transform' and 'Mirror'
- mirror menu seems to be resulting in some memory leaks with RNA_enum_items_add len: 160 038832F8

* Apply Rotation operator for Objects now takes into account the different rotation modes
2009-11-22 06:19:30 +00:00
288a08849b Patch #19952: [2.5] repeated include entry in SConscript for blender/editors/armature
Second #/intern/guardedalloc include removed. Thanks Jeff Doyle (nfz) for the patch.
2009-11-22 02:59:52 +00:00
9e2ed89105 SSS presets, Thomas and I added these at the same time, however I meant to make this a more general system.
this commit shows how to add a preset using the base preset class and menu with minimal effort.
2009-11-22 00:22:29 +00:00
6db600dddc moving this file back, sorry for the noise 2009-11-22 00:18:43 +00:00
d46e83e1c5 looks like we both added sss at once :) , removing since Im using the base class and a single presets file 2009-11-22 00:17:36 +00:00
e0e2c91879 Fixed minor sound UI errors. 2009-11-22 00:11:53 +00:00
4f6b95480f * Added Subsurface Scattering Presets.
Note: Add doesn't work, it writes some text into the file, not the values. (Maybe because the values are arrays?!)
Campbell, please check :)
2009-11-22 00:03:42 +00:00
Dalai Felinto
573be3e687 BGE: Removing OB prefix from object names - This will break scripts !!!! (also removing AC and ME :: internal changes only)
How it works now:
whenever you have to read/write object names you can do it without the prefix "OB". (it's not hard at all to fix scripts)

How it was before:
It was a mess :)
We had an inconsistent API where sometimes you had to input "OBname" and other "name" directly to assign object as data (usually in actuators).

Justification for the change:
Talking with Campbell we had since a while ago this feeling that this should be changed any time we were going to deprecate the API. So in order to deliver Blender 2.5beta0 with a more close-to-the-final API we decided that today was a good day to implement that.

Remaining issues:
1) VideoTexture uses IM or MA to identify the output material/texture. I haven't touched that, but it does look a bit off. (i.e. I didn't changed any MA, IM naming)
2) I didn't see the code of dynamic mesh. It may need to be edited as well.
2009-11-22 00:01:52 +00:00
1dfbf3a9f6 - aspectx wasnt saved in the render preset
- define a preset base class
- cleanup some comments and whitespace
2009-11-21 23:55:14 +00:00
7343de983e small fix
void SB_estimate_transform
no need for static now
2009-11-21 23:06:13 +00:00
2351d1c4d3 * Some cleanup for recent preset commit.
* Minor align fix for Frame Rate Buttons.
2009-11-21 22:54:02 +00:00
70e38422d2 new property for soft bodies
sb->lcom   : Center Of Mass .. might be used to create loc IPO
sb_>lrot   : is a matrix[3] esitmates the roatation in world coordinates .. might be used to create rot IPO
sb_>lscale : is a matrix[3] esitmates the scaling   in world coordinates .. might be used to create scale IPO
(no python for that yet .. but may be matt has mercy on me )

can be cropped direclty  in soft body module by function 
static void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscale[3][3])

The targets lloc,lrot,lscale should work to be NULL, just in case you don't need it. 

However i'd prefer if they were accessed via properties 
which should be calculated automagically if
sb->solverflags & SBSO_ESTIMATEIPO
is set, like they do in draw_sb_motion(..) in drawobject.c 

added static void draw_sb_motion(Scene *scene, Object *ob) to drawobject.c 
for debuggering (had a hard time with destructive matrix operations )
if it causes any trouble with your build on any OS make sure to comment that away.
softbody.c and DNA should compile fine in any case.
2009-11-21 22:45:25 +00:00
5e7debcecf render presets, select from a directory, button to add own presets 2009-11-21 21:39:20 +00:00
e65fee2f65 Sculpt branch:
Fixed grab brush, was creating holes in the mesh due to uninitialized values.
2009-11-21 21:34:00 +00:00
Dalai Felinto
d875f4927e patch [#19796] GLEW update by Mitchell Stokes (Moguri)
GLEW update to version 1.5.1 [11-03-08]
this opens room for Geometry Shader support.

* - Brecht, Campbell told me you did some local changes in order to make it right in Linux. I get to you in order to know what those changes are (or feel free to commit them directly)
2009-11-21 20:36:03 +00:00
75e82b5349 More macro goodness.
Macros now return finished if at least one operator in the macro finished properly. This is done to correctly insert an undo point.

This means that all the macros that combine with transform (extrude, loopcut, rip, duplicate) will correctly insert an undo step when transform is cancelled.
2009-11-21 19:49:11 +00:00
ae7286bbf0 Uncomment header. 2009-11-21 19:26:02 +00:00
c60f635ead made the merge limit show more precission and use a lower step. 2009-11-21 18:12:45 +00:00
Dalai Felinto
d594388a28 rna bge fix: using dynamode instead of mode for Dynamic Material option: Align to Normal (it was using Material->Shadow Receive) 2009-11-21 17:50:08 +00:00
da2db4bc58 patch from Ronan Bignaux
use python3 print()
2009-11-21 17:41:09 +00:00
a1c8d92151 Sculpt branch:
Corrected the calculation of the center of the flatten effect.
2009-11-21 17:22:03 +00:00
0ed0773eff fix for [#19943] Selected object border color incorect 2009-11-21 17:21:46 +00:00
f9d8145abe fix for [#19940] Remove vertex color layer and remove texture layer operators don't work
- only when in mesh editmode.
2009-11-21 17:16:00 +00:00
6f38938a64 [#19930] Nurb CV select is failing because of view clipping
- the clipping test function was using the rv3d->viewmatob where it needed to use the object matrix.
- added a local clipping member to rv3d, the clipping planes in object-space, avoids many matrix multiplications when testing verts or clipping pixels when projection painting.
2009-11-21 16:44:05 +00:00
bd1f548d8e fix for [#19655] Curve is a disaster
when changing curve twist I assumed 2D curves would not need dir or quat values set, however these are used when getting a path from a curve.
also added interp_v3_v3v3v3v3
2009-11-21 14:35:28 +00:00
09cf011879 patch from Dave Plater which fixes some problems building the BGE with cmake 2009-11-21 13:47:16 +00:00
455866ecf9 - added back Shift+Tab to toggle snap
- added curve tilt and shrink/fatten buttons into the toolbar
- fix typo in last commit for view3d snap header button
2009-11-21 13:01:28 +00:00
3d4fff3bc2 only show normal snap option in object mode 2009-11-21 12:44:09 +00:00
684405e0fb id properties for editbones and pose channels were not being freed in a number of cases,
added free_pose_channel(pchan) and use this in all places that free pose bones
2009-11-21 11:26:09 +00:00
6073bc9bc3 pep8 cleanup & default select axis to negative (artist requst, make sense if you model the RHS and spend most time looping at the models front) 2009-11-21 00:05:43 +00:00
d91e6e2160 * Made 'set active' vgroup menu fold out, rather than pop up new 2009-11-20 22:53:39 +00:00
d552c0ea5e Nodes Editor: Restored 'Show Cyclic Dependencies' Operator (CKEY) 2009-11-20 21:17:17 +00:00
03cfcc6007 Node Editor - More Cleanups (Reshuffling):
- removing duplicate chunks of code -> hide unused sockets now works
- moving some functions to the files that they get called from -> view all/home
- made duplicate a macro operator like the other places that work like this, eliminating the unnecessary transform-related property there still
- removed a few chunks of unused code
2009-11-20 21:04:41 +00:00
acf0fbbf70 left in print 2009-11-20 21:00:09 +00:00
34e7eb1676 use a metaclass to have operator attributes register and display in the order defined. 2009-11-20 20:58:46 +00:00
19aa69f6f2 use negative boolean option no_zbuf -> use_zbuf 2009-11-20 20:53:23 +00:00
b751bc5ef2 * More small modifier improvements by nudelZ.
* Code cleanup.
2009-11-20 20:40:29 +00:00
86f02c1353 RNA doc update. the "no_zbuf" flag in Defocus node was incorrectly doc'ed as "Use Zbuffer" when it really should be "Ignore Zbuffer". 2009-11-20 19:18:48 +00:00
525a4ec6a5 Improvements to tab -> spaces conversions and use in the Text Editor:
- A single undo removes all 4 inserted spaces at once.
- Indent and unindent now use spaces.

The number of spaces is still hardcoded as 4. PS: Campbell sharing a couple of the minor todo's with me, thanks :).
2009-11-20 19:15:57 +00:00
cb85365986 Modifier Layout improvements (single column and normal) by nudelZ. 2009-11-20 18:01:39 +00:00
e9a8db6e73 - dont define properties in the global script namespace
- set __file__ when running scripts (filename or textblock name)
2009-11-20 16:07:10 +00:00
9aa8d06259 Fix for unitialized variable and resulting render artifacts
when setting project x/y/z to none with a procedural texture.
2009-11-20 15:07:16 +00:00
854cc87a80 option to have scripts run on startup for per blendfile UI's 2009-11-20 15:01:09 +00:00
320cc0f12a Small update to render properties.
-Single column UI for Encoding panel
-Removed bad align in performance panel
-Made Quicktime's Quality percentage a slider
2009-11-20 12:26:41 +00:00
0cb20be29a Armature Editing Fixes:
* Restored WKEY Specials Menu. Had a few problems initially with the name of the menu being 1 character too long; this needs more comprehensive API warnings

* Made Extrude Forked work again as a macro operator. Added another extrude macro for this, but ideally would have worked with a single macro + setting properties for that macro (can't do so due to bug 19733)
2009-11-20 11:49:47 +00:00
68eaae8e0e Quicktime-qtkit : encoding settings now in blender ui (encoding panel)
- added "QuicktimeCodecSettings" struct in DNA
- old "QuicktimeCodecData" opaque struct is  nowdeprecated (read only use when QuicktimeCodecSettings is not set)
- fixed small bug when importing deep color movies

Note that you may need Final Cut Pro installed to be able to use the DVCPRO HD codecs
2009-11-20 10:37:50 +00:00
9672993bc1 Attempted fix for #19870 - Crash on Shift Numpad 1 based on the backtrace http://www.pasteall.org/9114 2009-11-20 10:34:31 +00:00
088c6d6666 Bugfix #19923: UVImage editor gets stuck in move/zoom mode 2009-11-20 10:21:31 +00:00
3119eaf284 - dir() now works for collection functions
- group.objects.link/unlink use exceptions rather then return values
- scene.add_object/remove_object --> scene.objects.link/unlink
2009-11-20 10:00:54 +00:00
e7413bf791 More Node Editor Fixups:
* Restored Mute and Hide Operators, M and H keys respectively
* Restored Make Links Operator (F). However, I can't figure out how to set the sockets so that this can be used
* Made Alt-RMB the new hotkey for breaking links by dragging, since Alt-LMB was taken for panning already
2009-11-20 06:31:49 +00:00
cb40583b90 * Added a quick little weight group 'Levels' operator, can interactively tweak overall weight value offset and gain in weight paint mode. 2009-11-20 05:09:57 +00:00
e6d382bd53 Node Editor: Various usability and code tidyups
* Fixed a nasty bug which meant that it was impossible to set an active node. Was caused by ntreeCopyTree() getting called when compo updates were done and clearing the active flags. The active flag clearing is only really needed for the "internal_select" case which is only used for duplicating selected nodes (from Shift-D duplicate).

* Recoded click-selection code. Was a mess of old code, bad exceptions from the old code half ported, duplicate operators, unnecessary flags/modes.

* Fixed bug #19927: compositing node groups can't be access via "tab" or ungrouped via "alt+g". Was probably related to the active group not being able to be set.

* Made resizing nodes work again. Again, this was due to the active node bug.

* Made adding a new group with Ctrl-G correctly update the views
2009-11-20 04:19:57 +00:00
3d1e618864 Simpler default smooth brush curve preset - less points, easier to tweak 2009-11-20 04:12:52 +00:00
38e1590fa7 * Removed tablet pressure sensitive number field widget scrubbing, wasn't that useful and I suspect it was the cause of a few bugs
* Added tablet pressure support (size/strength) for weight paint and vertex paint

* Added tablet eraser support for weight paint and vertex paint (inverts the effect of the current tool)

* Removed the old 'soft' option, now weight paint and vertex paint use the influence curve

* Made the default brush use a smooth influence curve, rather than sharp
2009-11-20 01:39:27 +00:00
e52c5a338f pep8 compliance, also removed use of exec() for netrender module importing 2009-11-19 23:59:37 +00:00
605e6850c2 Vertex Groups Operators:
* Added Ctrl-G hotkey back for displaying a menu showing the available Vertex Group operators

* Added descriptions for a few Vertex Group operators. The difference between "normalize" and "clean" isn't that obvious from just reading the code, so perhaps some attention to this is needed.
2009-11-19 23:39:19 +00:00
8522b4ede0 MSVC 9 projectfiles
* re-enabled collada now with hopefully correct debug libs
* python API IDProps added
2009-11-19 20:58:09 +00:00
7f42b10d0f Support for grab cursor in macro system (and vice versa).
This may result in cursor being grabbed twice (though we don't have any macro that can do this at the moment). If this is a problem, a check can be added.
2009-11-19 19:27:10 +00:00
ffbf4b6c8c missing check for the active object 2009-11-19 18:48:31 +00:00
512c06afdb - StructRNA's __dir__ was missing members from its classes __dict__
- property editor can now set button min/max values and edit the tooltip
- custom props tooltips were not displayed
- cleanup the property UI 
- remove hacks that were used for editing (edit is now a popup operator)
- object.children was broken
2009-11-19 18:22:21 +00:00
e61c90e416 operators were copying the properties from the rna operator into the class instance.
however this meant the invoke function could not modify properties for exec to use (unless it called exec directly after)
since the popup for eg would re-instance the python class each time.

now use the operator properties directly through rna without an automatic copy.

now an operator attribute is accessed like this...
self.path --> self.properties.path
2009-11-19 17:12:08 +00:00
ac8ff25b2d idprop.get(key, default=None)
matching pythons dict.get()

removed checks for a failed PyObject_New(), if python cant make a new object your probably going to crash anyway.
2009-11-19 17:04:28 +00:00
3f10b91235 operator properties were not the correct type 2009-11-19 16:15:22 +00:00
fc502cf481 Indentation fix. :/ 2009-11-19 14:37:07 +00:00
a51c7b5633 * Added Shift+Space hotkey for "Area Full Screen" as it is in 2.49.
Request by Pablo (venomgfx). :)
2009-11-19 14:33:28 +00:00
17013ca4ee added 'hidden' option for python defined rna props, means py operators can use hidden properties so the popup wont show
improved error message when bad args are given to propertyRNA funcs
2009-11-19 14:32:12 +00:00
2577bfddfd Renamed "col2" to "wide_ui" which is more meaningful. 2009-11-19 13:26:51 +00:00
08a7bbeae5 * Small Layout fixes.
* Single Layout for Softbody Panels.
2009-11-19 13:22:10 +00:00
d3600a92dc Single Column layout for Fields, Smoke, Cloth and Fluids.
Patch by nudelZ.
2009-11-19 12:58:19 +00:00
3b4c9d9699 correcting ID property list was incorrect on porting 2009-11-19 11:56:13 +00:00
b895b2e48f - remove CPPFLAG XP_UNIX from CMake, Scons and Irix make, checked our own code and /usr/include, its only used in our netscape plugin.
- CMake on unix default OpenMP to enabled.
- Scons on linux default OpenMP to enabled.
- copying python is slow, for scons only copy if the directory has not been created.
2009-11-19 11:49:42 +00:00
55b3280355 missed render border in modal keymap 2009-11-19 10:48:59 +00:00
040c2affa6 Revert toolbar shading commit. 2009-11-19 09:57:04 +00:00
169b0cbee9 Drag'n'drop : moved "setAcceptDragOperation" functions at window level
GHOST/Cocoa : changed strings encoding to isoLatin1 (was UTF-8)
2009-11-19 08:56:26 +00:00
525fbb22d2 * Fix for texture->image node not working
+ a few cleanups
2009-11-19 04:50:00 +00:00
bf575a1c16 * Changed scroll bar scale handles back to scaling from either side, rather than to the center (ctrl-drag or mouse wheel works fine for that) 2009-11-19 04:13:18 +00:00
a1b39ac06c * Fix for RMB keyframe/data path/etc operators not working in sub-regions, was getting the wrong region context to operate on. 2009-11-19 04:11:24 +00:00
2c08e182c7 * Added control and animation of sound volume of sequence sound strips (found in properties pane)
To insert keys, use I key while hovering over the button for now, rmb clicking on the property to insert a key doesn't work (general bug for all regions except property editor - will investigate).

Doesn't convert over from old fac0 ipos on opening old files though for the time being.

* Made sequence strip names unique while I was at it, to allow strip properties to be animated properly.
2009-11-19 03:21:37 +00:00
bb3afc81fc Sequencer UI: Sequencer now uses the standard timeline cursor instead of a hacky custom one that used a hardcoded colour 2009-11-19 02:58:48 +00:00
abe6b4c0c4 Bugfix:
Adding drivers to single values was broken.
2009-11-19 00:37:47 +00:00
5ed3081e5c 2.5 Single Column Layout:
* Added code to enable single column layout for general physic panels. 
Note: Force Field Falloff panel has some issues with single layout.
2009-11-18 21:57:13 +00:00
0c8b41e464 Fix crash on Windows when clicking anywhere in a window. Cursor grabbing code was missing checks for invalid tablet data. 2009-11-18 21:01:04 +00:00
ae5a814f26 ID properties that are displayed via RNA can now define their own UI settings,
only implimented min/max precision & step.

at the moment there is no way to edit these other then via python

example of setting UI limits...

>>> C.object['foo'] = 0.5
>>> C.object['_RNA_UI'] = {'foo': {'step': 0.5, 'soft_max': 10.0, 'soft_min': 0.0, 'precision': 2, 'description': 'Some setting'}}

Also fixed typo's: precission -> precision
2009-11-18 20:01:35 +00:00
5f6b9fd324 Quicktime-cocoa : fix file busy issue when rendering a second time with quicktime export 2009-11-18 19:35:03 +00:00
ec6f00c1bb SVN maintenance. 2009-11-18 18:45:38 +00:00
0df9ea6cd5 Made toolbar buttons slightly brighter, to make them stand out from the background more. 2009-11-18 18:01:54 +00:00
a73be8097d Netrender cleanup and bug fix
Blacklist and linked files work again

Store temp data in module
2009-11-18 18:00:46 +00:00
b5797272d0 New B.Blend.
Fixes an issue with the clipping that was set back to 0.01 Made it 0.1 once again as this fixes Z buffer issues.
Put the Item panel at the top in the n-key region
Removed Properties and Quad View Screens
Cleaned up UV Editing Screen, removing Properties
2009-11-18 17:54:04 +00:00
7f151b0dc6 Custom Ratio mouse input didn't check for initialization properly, which could lead to NaN values with edge slide.
Also adding missing modal keymaps for some transform operators.
2009-11-18 17:14:56 +00:00
a90c770286 Correctly detect and use modal keymaps in macros 2009-11-18 17:08:29 +00:00
5a6261afb3 Code cleanup in netrender 2009-11-18 17:07:42 +00:00
1f3ab7afd4 Disable continuous grab during tablet use (fixing tablet jerkiness issues) 2009-11-18 16:54:33 +00:00
5a4045ad7d Quicktime (non cocoa) crash upon export temporary fix
Removed the pop up of the codec settings dialog box that was causing the crash, as it was called from the render thread (and not the main one).

So qt export settings are now blocked on default settings:
codec=jpeg, quality=max, bitrate=5MBps

Complete fix will be done by replacing this dialog box by "encoding" settings in the render panel.
2009-11-18 16:38:22 +00:00
cee7d6ac4c Fix snap tooltip.
Make it a bit more generic to cover Ctrl hold or toggle.
2009-11-18 16:12:49 +00:00
a9e79d255d scons update to enable build with QTKit (Cocoa Quicktime)
Thx Jens Verwiebe for the patch
2009-11-18 15:54:25 +00:00
a57730875d Quicktime for Cocoa : export part
Following the quicktime import port, here is the movie export feature.

The codec selection remains to be implemented in the ui (render panel).
So the settings are now blocked on codec=jpeg, quality=max.
2009-11-18 15:01:59 +00:00
9e5305f67e own mistake meant bones could not drive eachother. 2009-11-18 14:36:23 +00:00
273a7ab9c5 remove GPL headers from templates, am happy for them to be public domain 2009-11-18 14:25:36 +00:00
8ddac2b6d5 Revert of ID Notifier, as requested by Matt. 2009-11-18 14:21:11 +00:00
34edfb9710 bone & object properties editing was broken. 2009-11-18 14:00:23 +00:00
6a357cabbf Durian request: Cloth
* structural can be set to 0

* pre-roll now available through GUI and works like following:
a) Pre rolled frames are NOT cached
b) reset cache + cloth on pre roll setting change
2009-11-18 13:33:52 +00:00
a62b3a534b fix for own error in 24623, removed a memfree call,
printed lots of errors like this one exit
 dynstr_cstring len: 24 0x54c4cb0
2009-11-18 13:14:49 +00:00
d3794d9f94 fix for memory leak, use Key Errors for pyrna getitem access & idprops 2009-11-18 13:02:09 +00:00
49c47fbf30 python pose_channels -> bones 2009-11-18 11:50:31 +00:00
67c295da9c rename pose_channels to bones
was: object.pose.pose_channels["Bone"]
now: object.pose.bones["Bone"]
2009-11-18 11:40:55 +00:00
95229aa6f5 Accidentally overrode a small change in the keymap preferences. Fixed. 2009-11-18 11:11:21 +00:00
28d1a35260 remove ID property lookups from rna..
ob["foo"] = 1
 print(ob.foo) # now raises an error
2009-11-18 10:59:17 +00:00
b1a5ba6804 Changed the appearance of the toolbar buttons.
When stacked on top of each other, it looks cleaner and simpler without the gradient.
This makes it easier to scan through long lists of tools.

http://www.reynish.com/files/blender25/toolbar_buttons.png
2009-11-18 10:57:30 +00:00
849ee94cf9 Partial fixes for #19881: Items existing on the same row as the window dividers are not interactive (selectable, etc.)
The View 2D function for handling scrollbar events now takes into account whether the scrollbar is visible or not, so that it won't block events when the scrollbar isn't visible.

Also, made the UI code take this into account too for its region testing code. Unforunately, there still seems to be something else which is still preventing UI buttons from being processed when they are in those regions.
2009-11-18 10:37:32 +00:00
624cd67d55 Quicktime for Cocoa : import part
This makes quicktime import (.mov & quicktime handled image files such as .gif) available also for 64bit OSX

Unfortunately, Apple currently incomplete implementation of QTKit has much lower performance than old Carbon Quicktime.
FYI, it spawns a 32bit process "QTKitserver" to place calls to Quicktime 7.

So this is mostly meant as a "backup" for 64bit OSX builds, until Apple releases full Quicktime X.

Export part will come just after.

CMake scripts updated: set WITH_QUICKTIME and USE_QTKIT to ON
2009-11-18 09:49:42 +00:00
22e8616a27 Attempted bugfix for #19909: missing text in frame indicator box
Not sure whether this fixes the issue, but it sounds like some Intel cards have issues with alpha values lingering around.
2009-11-18 08:50:09 +00:00
318e9aa5d1 - rna attribute setting problem, class instances could not set their own attributes because they are blocked by our own internal setattr.
this could be supported again easily however it leads typo's & api changes not showing any errors.

  This broke povray export.
  Solution for now is to allow setting private properties starting with '_'

  eg, 
    ob = bpy.context.object
    
    ob._foo = [1,2,3] # this is a python list, it will stay only as long as this PyObject is active
    ob.foo = 1 # raises an error!, only for rna properties
    ob["foo"] = 1 # converts to an ID property and is saved

    using the underscore like this should really be used for classes internally.

- povray failed on armatures

- menu key wasn't using WM_keymap_add_menu
2009-11-18 08:40:18 +00:00
1e1a0078da * NC_WINDOW Notifier for ID Name property (maybe not the best solution, but as ID blocks can be everything (object name, material, even scene) i chose the window Notifier. 2009-11-18 05:11:16 +00:00
7807a37b89 default name of keymap to 'keymap.py' + pedantic pep8 edits 2009-11-18 01:30:28 +00:00
5ad1563f34 insert spaces instead of tabs, makes editing templates less painfull, tho we should really have a function to insert strings rather then char's for this to work better. 2009-11-18 01:16:49 +00:00
b6e015f70c Small UI Tweaks - Toolbar + Graph Editor:
* "RNA Path" and "Array Index" for the active F-Curve in the Graph Editor are now shown in the properties region. These are greyed out unless the F-Curve cannot be evaluated, in which case they can be edited to make the F-Curve work again

* Made the Push and Relax operators in Pose Mode fit on a single row in the toolbar, since they're opposites of each other.
2009-11-17 22:46:42 +00:00
7b05c9ca30 Fun stuff with macro
Make macros work with more than one modal operator and mix of modal and invoke/exec

As a proof, brought back loopcut + edge slide in a single macro operator called Loopcut and Slide, replacing Loopcut as assigned to Ctrl-R.
2009-11-17 22:19:48 +00:00
2ae15e39ad make animation system and rna internals use getattr style syntax for user defined properties
bone["foo"] rather then bone.foo
matches python and avoids naming collisions
2009-11-17 20:46:59 +00:00
c07dde45a2 Macro for extrude along normals with a poll function to restrict it to face select.
Added before "free" extrude in the keymap means it's picked up first when applicable.
2009-11-17 20:40:39 +00:00
26695c15c2 Made toolbar buttons left-aligned.
Currently all tool buttons are left aligned, unless it has an icon like the Render Image and Animation buttons.
Later it might be nicer to introduce a proper flag to make text center aligned for those cases.
2009-11-17 20:19:35 +00:00
068545f3bd -Single column UI for image editor.
-Added buttons for Mark and Clear Seam in toolbar, replacing the less useful Rotate UVs and Mirror UVs commands.
2009-11-17 18:53:53 +00:00
ff5ea39733 * Create Group Operator had a wrong name, so it didn't showed up in the menu. 2009-11-17 17:09:54 +00:00
d438ec3080 adjusting generic props in the UI refreshes the depgraph, this is weak but allows custom props to be used as drivers 2009-11-17 16:53:52 +00:00
4076572874 [#19760] Extrude + Continuous Grab doesn't work
Flag macro as blocking

Make macro copy operator flags when one of them returns MODAL (these flags are needed by the event system)
2009-11-17 16:48:43 +00:00
5baa1d1759 * Alphabetical Order for Constraints.
* Formatting fix for last commit.
2009-11-17 16:27:53 +00:00
966b01665b use number keys to set the current brush in paint modes 2009-11-17 16:04:17 +00:00
fd64e0d662 Single column UI for constraints 2009-11-17 15:59:54 +00:00
99f8809b1a auto IK constraint was added twice, creating a circular list (HANG!) 2009-11-17 15:51:28 +00:00
df0f1d53b8 new function WM_keymap_add_menu(), similar to WM_keymap_add_item() except it takes a registered menu. the key will then trigger this menu. 2009-11-17 15:29:55 +00:00
68f94765bd switching the active brush with Alt+Wheel would crash when going past the last, need rna to clamp the range. 2009-11-17 15:10:19 +00:00
efae4c8f21 removing drivers was trying to remove the fcurve from the actions fcurve list if an action was set, now check if the context is for drivers first.
not 100% sure this is correct but removing fcurves worked in my tests for actions and drivers.
2009-11-17 14:32:19 +00:00
733b77063c was trying to add one too many drivers when inserting them on all items on an array (own error) 2009-11-17 14:10:29 +00:00
64104524cc fix for error editing a string property with quotes 2009-11-17 13:18:26 +00:00
5bc46cab8c Toolbar reorganization
Included more tools, such as Edge Slide and Shrink/Fatten in toolbar to make them easier to find.
Did some reorganization of tools in the mesh editing toolbar to categorize tools better.
Made some tools like Grease Pencil tools more compact in the UI
2009-11-17 12:59:55 +00:00
f7682e2e0f - in pose mode, pose bone properties are edited rather then armature bone
- new id property array method convert_to_pyobject()
- editing an array in the UI broke
- fixed for own error when updating ID prop api
2009-11-17 12:54:29 +00:00
51f2dcd08c - access console languages as modules rather then having the py operator call an operator
- workaround for __getattr__ existing for types that dont support it
2009-11-17 12:21:41 +00:00
7f8a24b614 select linked enables seam limit when in face mode and the "limit" property is not set (like in 2.4x) 2009-11-17 10:57:49 +00:00
cf26cdd508 nicer UI, allow editing of values without pressing edit for basic types 2009-11-17 10:30:54 +00:00
10e1780cf9 Assorted bugfixes - Sequencer/Preview Range:
* Snapping strips now works with the hotkey  Shift-S   as in the rest of Blender
* Preview Range works in Sequencer now (the operators for setting, clearing, and also drawing)
* Related to the Preview Range for Sequencer, toggling the time-display mode also works
* Preview Range Set operator now works again, after the modal keymaps change for borderselect broke it. Also sends correct notifiers now after bein called.
2009-11-17 10:12:35 +00:00
b1a6ef4bfc DopeSheet Drawing Optimisation (Long Keyframes):
Optimised the code for drawing Long Keyframes by making the code use a Red-Black Tree instead of performing linear search over all the (potentially unsorted) BezTriples to find the previous one with a matching value.

As a result, the Redraw Timer (Ctrl Alt T) tool reports that the time needed to draw the keyframes region on a heavy imported-BVH file has dropped from an average of 270ms per draw, to about 60ms. The view is also freely pannable as a result.

Note that this code will currently have some issues when there are more than 4 BezTriples occurring on the same frame, but that should only happen when transforming keyframes anyway. This will be addressed as necessary.
2009-11-17 08:27:46 +00:00
45e38635a4 Drag'n'drop : add freeing of dropped resources upon event object release 2009-11-17 08:27:11 +00:00
7636d17af6 property editor for bone and object ID props, add/remove/edit
good example of how editing NON rna data results in very weired scripts :/
2009-11-16 22:53:28 +00:00
3087da0b25 my chnges broke 'del idprop["key"]'
made it possible to remove properties from rna types.

eg.
 del group["someprop"]
2009-11-16 22:21:39 +00:00
98d4a56d55 Fixing keymap export:
- Didn't support new userdef keymaps (new "active" rna function to get the active version of a keymap)
- Didn't support modal keymaps (new "modal" param to add_keymap function, new "add_modal_item" function on keymaps (both functions now make sure the keymap is of the right type))
2009-11-16 20:50:02 +00:00
6ed0686fcc bpy/rna methods to find properties (works nice with autocomp!)
keys(), values() & items()

ed...
 print(bpy.context.active_object.keys())

Possible name conflict here, need to keep an eye on it.
2009-11-16 20:16:45 +00:00
061675b3eb 2.5 Texture RNA:
* Alphabetical Order for Texture Types, this way it's easier to find the texture inside the drop down.
2009-11-16 20:02:58 +00:00
5b2fdb6ebe missing include 2009-11-16 19:18:04 +00:00
578950c977 ID property access from python for pose channels, bones and any ID objects.
The advantage with this is that global property definitions are not needed to add a property to an object.

to avoid confusion these are accessed like a dictionary (closely matching how the BGE accesses properties)

 ob["mySetting"] = 1.0

 bone["foo"] = {"one":1, "two":2.1, "three":"Three"}

 if "foo" in bone: print("prop found...")

At the moment these can also be accessed as attributes, will be changed shortly. eg.
 bone.foo == bone["foo"]
2009-11-16 19:03:40 +00:00
66dfaabb9d update idproperty python api for python 3.1
- removed 'group.has_key("key")', use... '"key" in group' instead
- removed verbose float and int conversions that are not needed
- fixed memory leak
2009-11-16 18:56:58 +00:00
cf1700bdd5 python api for ID property access by Joseph Eager, copied from blender 2.4x. 2009-11-16 18:53:11 +00:00
ca5a912c3e Added single column support to modifiers
Tiny cleanups and improvements in some modifier layouts
2009-11-16 16:07:22 +00:00
d6c0680268 un-initialized variable, fix for own recent commit 2009-11-16 14:29:46 +00:00
20043a0fc0 add hook in vertex and control point menu's, Ctrl+H
TODO's
- add for lattice
- break up add_hook
- add other hook operators
2009-11-16 13:59:27 +00:00
88fe2d187b Bugfix: Remove drivers button was broken
Somehow this worked here, even though the pointer being referenced was supposed to have been freed already...
2009-11-16 12:44:33 +00:00
a12c2a8561 Constraints: Code cleanup
* Removing duplicate api functions
* Shuffled around newly added api functions to make the ordering more consistent
* Fixes for a few bugs in the api functions as I checked over them
* Replaced most of the #defines for flags and modes with enums
2009-11-16 12:33:42 +00:00
567ee32f14 - fcurve modifiers.new()/remove()/active
- renamed .add() to .new() for rna collection functions since they dont add an existing item.
- remove 'name' as an argument from the new driver target function, better to keep the api minimal and let scripters use the data api for editing values after.
- added some api functions to keep rna api from becoming a mess.
2009-11-16 11:11:16 +00:00
d2ca3e5582 fix for python UI glitch, need to make view3d active_pchan & active_bone's (since they dont check layers atm) 2009-11-16 10:10:29 +00:00
be07bb3cc3 functions returning non ID pointers that relied on having the ID set could crash, (adding a pose constraint crashed in one testcase)
now use the functions ID pointer.
2009-11-16 09:20:21 +00:00
Dalai Felinto
2e104b44c6 bge: fix for "dome mode not working with Letterboxing".
This bug was introduced after commit # 24102 (BGE: when letterbox is enabled use the camera framing as a clipping area) reported in IRC by Pete Carss (domejunky)

*) an extra stub fix for recent commit. By the way: we want to have blenderplayer running in blender 2.5 beta0. Therefore if you are doing big changes in the last minutes (Friday, Saturday??) It would help a lot if you could enable blenderplayer in your builds. links problems are really easy to fix)

**) an typo I spotted in recent mesh dynamic load in bge.
2009-11-16 02:52:02 +00:00
aa739e7a71 Add include path to find BLO_readfile.h. 2009-11-16 00:44:07 +00:00
b45ab480e0 BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
Dalai Felinto
349fa813ea bpplayer compiling fixes: ([#19890] Getting the Blenderplayer to build again by Mitchel Stokes (moguri) and some changes form mine)
1) SetDisplayArea was created in Blender but we forgot to set it in the player
2) Fix some SCons incs (using lists instead of strings)
3) added more nasty stubs calls (this file is getting big)

* typo fix from last commit

**) it's raining with bolts here and I have to turn the internet off. I couldnt hard test this commit but it looks like working. sorry if sometihng go wrong
2009-11-15 23:48:21 +00:00
fb4e3a13fc Update MSVC project files: disable COLLADA in debug build => runtime crash. 2009-11-15 23:46:13 +00:00
923e67fe1f Fix runtime check uninitialized pointer 2009-11-15 23:43:20 +00:00
11cfdfa264 === Better support for user defined modal keymaps ===
Fixing/Missing RNA properties:
- "virtual" property for "ANY" modifier for keymapitem
- modal property for keymap
- Look up modal_items in usermaps too

Lazy init usermaps needs to init modal_items too.

New function to initialize a user keymap (fill in modal_item and poll pointers).

Operator modal keymaps now look up if there's a user defined keymap that overwrites it.

Full Event UI buttons now show "Any" when modifier is set to that (instead of listing all of them).

Note: Having the modifiers as boolean still doesn't express the full breath of values possible for them. There is commented code in this commit to represent them as enum, which would solve this, but make the keymap editor more cryptic.
2009-11-15 19:25:34 +00:00
Dalai Felinto
6ea605797c patch [#19722] Text labels for Stereo and dome modes from Jorge Bernal (lordloki)
I'm not 100% happy with the dome mode description ("physical" doesn't really match the difference between all modes). But for the time being let's leave like this.
2009-11-15 17:10:52 +00:00
bbb2668ce0 Bugfix #19878: pressing shift+b or alt+b locks up blender
Modal keymaps for clip zoom and zoom border in 3D-View were missing, which lead to events for those operators never getting processed.
2009-11-15 11:46:08 +00:00
635a98a4ce [#19896] [bugfix] Fixing converting of rotation f-curves
from Mitchell Stokes (moguri) 

--- from the patch
With f-curves there are 3 rotation modes, rotation_euler, rotation_axis_angle, and rotation_quaternion. The IPO converter
was still simply looking for "rotation" f-curves instead of specific ones. This patch fixes that and also
fixes bug #19873 ( http://projects.blender.org/tracker/index.php?func=detail&aid=19873&group_id=9&atid=306
).
2009-11-15 11:32:53 +00:00
61fe981a0f Bugfix #19887: Blender crash when resizing nodes in node editor
This commit fixes the crash, but there are currently some issues with getting the active node in general with the Nodes Editor.
2009-11-15 11:32:29 +00:00
6468f21ddf Red-Black Tree Code Cleanups:
Added some more methods for the Red-Black Tree implementation in Blender (used for runtime viewing and searching of keyframes) which abstract away some of the lower-level handling of the BST (i.e. adding nodes without balancing and searching for nodes). 

Also, improved the implementation of the jump next/prev keyframe operator so that it pops up an error message when the last keyframe in whatever direction is encountered.
2009-11-15 11:20:44 +00:00
698086dfb1 MAC/Cocoa:
- Drag'n'Drop events are now correctly signaled to the main loop for dispatch (these events were directly handled in cocoa callbacks without notifying the process loop)
- Fix timestamping of events & add debug print of drag'n'drop events.
2009-11-15 08:34:31 +00:00
888565e248 *More single column stuff.
*Fixed and changed minor layout issues in curve and game properties
*Merged Curve and Text properties py file as they share a lot of options.
2009-11-14 23:24:15 +00:00
d04f94d0c6 skip rna property & function lookups for members starting with "_" (since makesrna disallows this)
added a way profile python startup in bpy/__init__.py, if'd out by default.
2009-11-14 23:11:46 +00:00
33da66d7b3 RNA property for propvalue in keymapitems.
Enables modification of modal keymaps.
2009-11-14 22:43:42 +00:00
a6eeb88aac sequencer select linked time option, (Selectmouse /w Ctrl & Ctrl+Shift), selects all strips that have the same start/end as the active strip or.. if your selecting a handle select all strips and handles on the same time 2009-11-14 20:46:18 +00:00
694525e38b Make it possible to put audio strips into meta strips in the sequencer. 2009-11-14 20:17:05 +00:00
e94640040b sequencer support for loading multiple movie and sounds at once.
- more api like functions for adding movie, sound & images (easier to use from pyrna api)
- operators share more settings
- renamed get_last_seq() to active_seq_get() - same for set.
2009-11-14 19:26:58 +00:00
c2e092ef8b reload with the active sequence strip set 2009-11-14 15:31:52 +00:00
c9d2186561 - sequencer speed effect back using fcurves, still needs manual reloading to refresh.
- added a function id_data_find_fcurve() to get the fcurve without RNA vars. Aligorith: this could be made to use a path rather then a property name.
2009-11-14 14:58:19 +00:00
d33291fcc4 used py error checking tools to fix some bugs & make pep8 corrections 2009-11-14 13:35:44 +00:00
aac16ce4ec - scons fix for 10.4 build (use the 10.4 libs dir)
- warning fix in ghost/cocoa
2009-11-14 13:01:14 +00:00
b386ef0abe * Compile fix. prop was declared in the middle of scope. 2009-11-14 08:50:02 +00:00
e191007d5f Action Constraints Bugfix:
Action Constraints were failing when the rotation mode was non-default. Fixed this by copying over the current rotation mode when creating temp elements to evaluate with.
2009-11-14 02:50:45 +00:00
c2624e1a4f fix for skinning uneven loops, fixed to use even edge removal currently 2009-11-13 19:18:17 +00:00
e53b05fbd8 report this broke MSVC 2009-11-13 18:47:20 +00:00
e12fe32feb documentat & cross reference collection types 2009-11-13 17:42:44 +00:00
c1d0f9179d fix for error with property getattro in recent commit which broke autocomp.
active base/bone & editbone were not converted to property srna
2009-11-13 16:37:44 +00:00
91352006c4 arbitrary property and function support for rna properties (arrays and collections), this means functions can be easily added.
eg.
 scene.objects.link()
 object.constraints.new()
 mesh.verts.transform(...)
 mesh.faces.active

PropertyRNA stores an StructRNA pointer where these can be defined.
2009-11-13 16:08:03 +00:00
6df83fba02 Merge -c 24547 from COLLADA branch (fix flipping of triangles created by tesselation). 2009-11-13 15:48:45 +00:00
2646558079 Update MSVC project files 2009-11-13 13:06:26 +00:00
5a322bd67c F8 reload works again, script errors are printed but dont stop loading every other script 2009-11-13 11:10:29 +00:00
b17964af11 temp disable fix from r24541, constrains extruding verts 2009-11-13 10:53:58 +00:00
4c7dc3e5c5 changes python initialization
- bpy is now a python package, this makes it easier to add utility modules and adjust python startup which was previously using verbose Py/C api. Access should not be any slower since both C and Python modules use dictionary access.
- loop over scripts and load via python (currently F8 reload isnt working, will add back shortly)
- the C module is kept but renamed to _bpy and not meant for direct access from anything but the bpy package.
- bpy_types.py is an exception since it runs before the bpy package is initialized.
2009-11-13 09:28:05 +00:00
d0dff582a8 dont use the actual scene when registering the class 2009-11-13 08:44:57 +00:00
206563241c Bugfix #19871: Extrude does not extrude on normal anymore
Just moving some old commented-out code over from the invoke() callback for extrude to the macro operator.
2009-11-13 01:26:13 +00:00
acd7225dea Driver Editing Tweaks:
* Updating dependencies for drivers now clears the disabled status of the relevant Driver FCurve too
* Changing the type of ID-block used for Driver Targets and Keying Set Paths will now clear the pointer to the ID-block if it is of the wrong type.
2009-11-13 01:04:01 +00:00
e12f39d116 Spline IK: Fixes for the crashes with non-existant path data that are applied elsewhere 2009-11-12 23:27:33 +00:00
6062e434d3 Deselect all for bones works again
It's still very irritating that the active bone pointer doesn't get cleared when this happens, but at least it's more consistent with how Objects work...
2009-11-12 23:12:34 +00:00
4123c1fd7b Made a few more property areas work with a single column.
Also fixed a few minor layout issues.
2009-11-12 21:44:35 +00:00
d0c1d182e9 Bug: [#19712] Manipulator widget missing functionality
With help from Patch [#19757] by Michael Jefferies.

-------------

Also, following talks with Matt and Campbell, make pressing Ctrl in transform toggle snap/gears instead of having to hold it down.

Important note: holding it down will no longer work correctly because of key repeats (it will toggle it constantly). It's possible to edit the modal keymap to bring back the old behavior (perhaps it should even be default).
2009-11-12 19:49:26 +00:00
20681f4980 Shift click on modifier works again.
For some reason, adding a keymap entry with KM_SHIFT didn't work, had to use KM_ANY and passthrough invalid modifiers.

Left a note to investigate later.
2009-11-12 19:42:53 +00:00
Chris Want
6c1a7a9a2d == Blender 2.4x ==
Removed highly annoying "recalc data OBxxxx" debug print.
2009-11-12 18:35:26 +00:00
fdcc0ff7c7 Merge -c 24531 from COLLADA branch (fix holes in imported meshes). 2009-11-12 17:08:32 +00:00
8f80297832 generating docs can make the rna api generate wrnings (which is fine)
but was giving python decoding errors and didnt even show the warning.

for now just print to the console fixes this
2009-11-12 15:46:45 +00:00
fbb2c38485 Implemented single column UI for textures, curve, mesh and empty.
Reverted 24524 materials change because it it made greying out not work correctly.
2009-11-12 15:41:44 +00:00
17b6dfa499 Bugfix: workaround for spline IK crash with curve path not created
yet, this is actually a depsgraph issue .. so instead of crashing it
will not update correct on file load now.
2009-11-12 15:18:01 +00:00
aeca8f6a35 undefined py variable 2009-11-12 15:13:47 +00:00
331d1b1b50 sintel's normals were rendering black around her eye.
Subsurf FLT_EPSILON from float.h was too high, using a smaller value fixes
2009-11-12 15:05:51 +00:00
9d6787c3e1 rename text3d "str" to "body", (text body), it was also using ID name setting functions which didnt work. 2009-11-12 14:40:09 +00:00
cb7aff89e8 * Minor code cleanup. 2009-11-12 14:37:13 +00:00
da799053a0 Use ACTIONMOUSE instead of hardcoded LEFTMOUSE for sequencer's frame scrubbing 2009-11-12 14:31:27 +00:00
bee2335aa0 Implemented suggestion be Matt to slightly tweak the code for single column UI 2009-11-12 13:05:12 +00:00
4f47f21d44 small corrections, no functionality change 2009-11-12 12:48:39 +00:00
9596b369bd Added single column UI layouts
This changes the layout when the properties window gets too narrow to render the contents properly. 

Currently implemented for render, scene, world, object and materials, but the rest can be done easily.
Here's a video for demonstration:

http://www.reynish.com/files/blender25/properties_resize.mov

It automatically detects the window width and then skips the indicators that tells the layout to go to the next column. It requires very minimal changes to the UI scripts so we don't have to maintain two versions of the layouts.
2009-11-12 12:35:37 +00:00
1df6575074 Spline IK: UI/Scaling Tweaks
* Renamed "Keep Max Length" to "Y Scaling" which has the opposite meaning

* Improved the way that Y-Scaling off behaves. Most of the time, bones that do not fit on the curve are now "blended off" their default rotations instead of being scaled to zero.

* Added option to offset an entire chain by moving the root bone of the chain. This is named "Chain Offset"
2009-11-12 12:20:57 +00:00
c53a8105da Project snapping is too slow for sintel's head at subsurf level 2, ifdef'd out per face snapping and added BVH raycasting.
adjust epsilon value for isect_ray_tri_v3()

from the comment...
/* note: these values were 0.000001 in 2.4x but for projection snapping on
 * a human head (1BU==1m), subsurf level 2, this gave many errors */
- 0.000001 -> 0.00000001
2009-11-12 11:45:29 +00:00
fa14e50650 Added frame change keymap to node editor 2009-11-12 08:46:41 +00:00
0adfc00e40 Merged -c 24514 from COLLADA branch (build edges on mesh import). 2009-11-12 03:41:41 +00:00
d05f20cb95 * Fix: node editor wasn't updating on tree type change 2009-11-12 01:22:51 +00:00
05df56033c * Tweak to button text clipping, now the text label part gets clipped from the right side 2009-11-12 00:48:44 +00:00
70a88611ff region width and height readonly rna access (for UI scripts) - see context.region.width/height 2009-11-11 20:42:18 +00:00
53250f85db object.constraints.add()/remove()/active, same for PoseChannel
modified internal api for minimal rna wrapper functions.

TODO
- missing updates for pose channels
- typecheck for pose/object constraints
2009-11-11 19:58:30 +00:00
047ee04418 Fix for import/export menus, hide collada if it is not compiled in. 2009-11-11 19:12:52 +00:00
5b9768d409 Fix tris to quads not working, operator still needs to get properties,
but at least now executes with the defaults.
2009-11-11 18:46:55 +00:00
c5b89a2b7a Forgot to include these files in sculpt shape key commit. 2009-11-11 18:31:19 +00:00
d70943c40c Fix bug #19864: edge slide factor field is wrong. Setting RNA float
property non-array property as array did not work correct.
2009-11-11 18:30:37 +00:00
71c0fbdee1 Fix bug #19762: sculpt does not work with shape keys. 2009-11-11 17:58:37 +00:00
f356ea764d - use double underscores to hide members in python (removes them from dir() therefor autocomp.)
- collection functions rename eg. bones_active -> bones__active, add_object -> objects__add since these should be accessed from the collections only.
- fix warnings in last commit
2009-11-11 17:12:48 +00:00
bc6190f3e3 python api for collection add()/remove()
Added a group example
 C = bpy.context
 ob = C.active_object
 bpy.data.groups[0].objects.add(ob)

- add_to_group and rem_from_group now take optional scene and base flags and deal with updating the object & base flags
- operators that add objects to groups were setting ob->recalc= OB_RECALC_OB; looks like its not needed.
- previously add() ignored python args, now add and remove are called like any other FunctionRNA from python.
- made the pyrna api use tp_getset's for collestions active/add()/remove()
2009-11-11 16:28:53 +00:00
f243928055 Added some missing theme entries and removed some unused ones. 2009-11-11 16:27:00 +00:00
f76a6020c0 Nodes:
* Added properties operator to the View menu.
* Added Notifier for Node Select Operator, so the new "Active Node" Panel gets refreshed.
2009-11-11 16:02:18 +00:00
55a7e73b7d Fix #19368: sculpting with subsurf modifier applied did not update correct.
Fix #19438: sculpt anchored + texture did not center texture correctly.
2009-11-11 15:50:49 +00:00
34644821de Fix #19842: timer events incorrectly cancelled tweak events, e.g. when
opening a file browser.
2009-11-11 15:29:22 +00:00
9a7099f428 Fix #19834: text edit mode left/right was not work due to frame prev/next. 2009-11-11 14:30:12 +00:00
e7f5e70187 Fix #19837: filtering in file browser was missing some common
video file extensions.
2009-11-11 14:05:10 +00:00
872a7aeb5a Fix #19313: running python scripts with PyRun_File could
crash on windows due to incompatible FILE struct between
Blender and python library, which is why it was not used
in 2.4x, so apply the same workaround now.
2009-11-11 13:27:54 +00:00
1bf387ede1 Bugfix: switching renderlayer in compositing node crashed. 2009-11-11 12:38:22 +00:00
52e4b9d020 Fix for [#19781] smoke domain displayed in wire even after removed it
Now it resets back to Shaded display, which still may not be what you want, but there's more chance of it, and it's the default.
2009-11-11 11:49:46 +00:00
5bedc65d61 fix for uninitialized variable when circle selecting faces in editmode. (was crashing on release build but not debug for some reason) 2009-11-11 11:29:56 +00:00
80e3f0fb3d Fix for [#19562] Little plus icon in upper right missing when opening files from 2.49
Now add the new sub-regions to all 3d views on file open
2009-11-11 10:59:58 +00:00
1d84b6bb3c Nodes Editor + other warning fixes:
* Added 'active node' panel for the Nodes Editor. This panel, in the NKEY region, shows the settings for the active node. Included in this panel is a field used for editing the unique-name of the node too. 

* Fixed a number of uninitialised vars warnings that I missed in previous commit...
2009-11-11 10:51:40 +00:00
2e3326c153 Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24330:24483 2009-11-11 10:44:46 +00:00
4157e51a25 * Fix for [#19488] Small slider = hidden values
Now number fields use a new method of clipping text when the available space is small:
http://vimeo.com/7545600
2009-11-11 10:27:25 +00:00
e4f10565ea recent change shows up incorrect context use: context.bone is not valid in the view3d context. 2009-11-11 10:07:52 +00:00
6dcb4ac7a4 * Fixing various compiler warnings under scons+mingw. Mostly unused variables and functions.
* Added missing lib-linking code for Grease Pencil in nodetrees
* Uncommented some code for curve shapekeys
2009-11-11 09:59:51 +00:00
5c69f19904 [#19859] Lasso select causing Blender to crash
missing null check in own commit
2009-11-11 09:58:24 +00:00
5816912dc1 - In the context, EditBones and Bases were set as 'RNA_UnknownType', replaced with propper types.
- renamed RNA_Base to RNA_ObjectBase
- only include id_data for the python api's autocomplete if it has an ID type set.
2009-11-11 09:16:53 +00:00
c0fae59c99 * Fixed nodetree animation by giving nodes unique names
Now the rna path to nodes happens via the node name, which is ensured to be unique via RNA.
As part of this, the node->username string has been removed, upon renaming the node itself it takes care of making sure it's unique (like bones, constraints, etc). There's currently no interactive rename tool, but you can do it via the datablocks editor.

- plus a few notifier tweaks, using the newer NC_NODE notifier to refresh graph editor etc.
2009-11-11 09:11:21 +00:00
b2bb9ca39a Mitchell Stokes BGE MouseWarp patch + warning fix
[#19854] [bugfix] Fix for broken Rasterizer mouse functions
---
This patch fixes the embedded player's ability to control the mouse. For example, hiding and unhiding the mouse cursor
did not work in 2.5, nor could the mouse's position be controlled. This was because these parts still needed to be ported
to 2.5 window manager code.
2009-11-11 08:32:29 +00:00
1dfc7942d3 Grease Pencil for Nodes Editor:
This commit restores Grease Pencil functionality for the Nodes Editor. Grease Pencil data is now stored at the NodeTree level, which means that annotations remain with the NodeTree they were made for. 

Possible TODO's:
* In future, it may be worth investigating attaching Grease Pencil data to individual nodes, to allow annotations to stay attached to nodes as they are moved
* Include the settings for the 'active node' in a panel in the new NKEY region where the Grease Pencil buttons appear.
2009-11-11 08:12:54 +00:00
7206437c72 node warning fixes 2009-11-11 06:01:42 +00:00
bf50cc8b39 Added compositing node support to the animation editors
Now when nodes are keyed, they will show up in the dopesheet/graph editor/etc in a new 'Nodetree' category.

Still a major problem left, nodes need unique names in order for the rna paths to hold animation data properly...
2009-11-11 05:03:49 +00:00
792c4d602d Fixes for martin's background mode commit - now works fine here on OS X 2009-11-11 04:38:37 +00:00
e776ecfdde Background mode in more working conditions.
What works:
The usual command line options for rendering.
All python scripts are loaded (which includes custom properties)
Render engines are loaded and can be used
-P to run scripts works partially: rna api works ok, not operators.

What doesn't: 
Most operator calls in python. This is a problem with poll functions. (Brecht and Campbell are aware of this already)

Changes:
-d now also applied with -b (it was ignored before)
user file (.B25.blend) now also loaded in bg mode. This helps for custom paths and all.
wm is also initialized (it's needed for a lot of context calls)
Ghost, however, is not initialized.
2009-11-11 04:08:09 +00:00
f7d7149936 Debug tools: new function MEM_testN(void*)
returns 0 if pointer is not in memlist
2009-11-11 03:45:26 +00:00
f0fc007c4b Wrapped node input and output sockets in RNA.
This allows you to set and animate the values of socket inputs and outputs, for example the value node.
It's also a step on the way to manipulating node trees via python (i.e. linking node sockets to each other).

This fixes [#19841] RGB Node in compositor not working
2009-11-11 02:15:09 +00:00
0807bc176a Actionzones (i.e. corner widgets for splitting views) were broken after the math-lib commit. Was caused by functions that got renamed to the same name but the order of arguments were different. 2009-11-11 01:32:38 +00:00
9256408612 Fix CMake build system for Windows
Add support for OPTION WITH_OPENCOLLADA for Windows
2009-11-11 00:02:49 +00:00
21385eb4ec New function:
void MEM_callbackmemlist(void (*func)(void*));

Will call the function passed as argument with all allocated address as parameter. Useful for debuging.
2009-11-10 21:33:53 +00:00
91446e9aad Math Lib
* Post-conversion commit, fixing some introduced warnings.
2009-11-10 20:50:34 +00:00
673396d285 Split operator internal call (for python) between invoke and exec. Only invoke needs window (for event), no need to require it for exec too.
No functionality changes, except that operator called with exec when a window isn't present (say, bg mode) won't silently fail.
2009-11-10 20:44:10 +00:00
37e4a311b0 Math Lib
* Convert all code to use new functions.
* Branch maintainers may want to skip this commit, and run this
  conversion script instead, if they use a lot of math functions
  in new code:
  http://www.pasteall.org/9052/python
2009-11-10 20:43:45 +00:00
4617bb68ba Math Lib
* Pre-conversion commit removing old arithb.c code, this will not compile,
  next commit fixes that.
2009-11-10 20:40:18 +00:00
84e3b2d726 NULL pointer check to prevent some crash in background mode 2009-11-10 20:34:35 +00:00
0797054c2d Running with -d, python context also prints members asked from context that are present.
Also, error messages were mixed up, wrong type and not present where inversed.
2009-11-10 19:57:04 +00:00
e29a70e136 Add Sticky was essentially a blank operator. Possibly context functions weren't around for this one when it was first looked at. Re-attached so it works now. 2009-11-10 19:54:59 +00:00
320fb05ebc SVN maintenance. 2009-11-10 19:22:10 +00:00
385875632d Math Lib
* Fix remaining issues before conversion.
* Inline various vector functions, currently enabled for all platforms.
  I expect this to work in GCC/MSVC at least, if other platforms don't
  support it, #ifdef's can be added.
2009-11-10 19:13:05 +00:00
d611dd3735 Function declaration for BPY_context_get 2009-11-10 16:18:54 +00:00
de7504807c fix error with python exceptions in BPy_errors_to_report 2009-11-10 16:17:49 +00:00
bc3eff97c4 2.4x fix for Blender.Load()
only bother checking script spaces when loading a blend file

Should be able to load a STL or DXF when script spaces are open now
2009-11-10 15:34:27 +00:00
7efc2c2375 modify the python context access so invalid names will raise an exception rather then returning None.
this way the UI scripts are less likely to fail silently and wont let typos work ok.

also allow subclassing of the context, added a copy function,
 bpy.context.copy(), returns the context as a python dict to be modified and used in python.

This also showed up an invalid brush member in the screen context.
2009-11-10 15:09:53 +00:00
1f2fe7ec14 fix for own error in active bone commit, wasnt checking object type was an armature
also fix for warning with printf
2009-11-10 13:20:32 +00:00
af2e6c38e9 Drag & drop implementation at GHOST level (only OSX for now)
The dragging sequence is performed in four phases:
 
- Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started. Already gives the object data type, and the entering mouse location

- Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the drag'n'drop operation stops, to give the updated mouse position.
Useful to highlight a potential destination, and update the status (through GHOST_setAcceptDragOperation) telling if the object can be dropped at the current cursor position.

- Abort drag'n'drop sequence (GHOST_kEventDraggingExited) sent when the user moved the mouse outside the window.

- Send the dropped data (GHOST_kEventDraggingDropDone)

- Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon). This can happen when the user drops an object on the application icon. (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)

Note that the event handler is responsible for freeing the received data.
And the mouse position is sent directly in blender client coordinates (y=0 at bottom)

The GHOST_setAcceptDragOperation(TRUE) call must be placed before the user drops the object for it to be accepted.

Current handled data types :
- Text string
- Array of filenames (full paths)
- Bitmap image (not implemented yet)
2009-11-10 12:56:46 +00:00
14f9e686fa Fix for math lib commit, had duplicate definitions of functions,
giving build issues on some platforms.
2009-11-10 10:24:58 +00:00
89c2e6c803 Bugfix #19835: While playing animation, Render>Dimensions>FrameRate does not change animation speed
The timestep used for the playback timer now gets adjusted accordingly when the frames-per-second setting gets changed during playback (i.e. in the "animation_step" operator). This is not as ideal as only updating this when the framerate setting is changed, but using an appropriate update function for this failed miserably.
2009-11-10 09:50:39 +00:00
4573120399 Fix for [#19847] Joined meshes fail to render
Join function was accessing invalid memory for material indices when no materials were originally present on the joining objects
2009-11-10 06:29:10 +00:00
297045fd96 Fix for [#19852] Animation rendering not working in new scene
As part of this commit, I moved the scene frame_step to RenderData, where the other frame-related data is.
2009-11-10 04:56:55 +00:00
b24b858394 Fix inconsistent order in Image editor alpha display buttons 2009-11-10 04:03:29 +00:00
84abb8ecb6 Fix for [#19855] Color Ramp Interpolation is not working 2009-11-10 04:02:44 +00:00
bc006655ba * Finished (well, almost ;) RNA wrapping and layout-engine-ing all the nodes.
Still a few quirks, including redraw issues on multilayer image input nodes, but it's pretty much there.
Would also be good to wrap the input/output sockets, too, will check on it.

This fixes bug [#19740] INPUT NODE: Cannot load images / motion pictures
2009-11-10 04:01:44 +00:00
ad409e5c7e * Small UI drawing tweaks, part of it allowing a bit of extra space for text in number fields 2009-11-10 03:48:02 +00:00
7fe52eedba Removed an unused function and changed the VBO functions to use the ARB name for consistency with the rest of the file. 2009-11-10 03:45:52 +00:00
d0cd641de3 Bugfixes for Armatures, SplineIK, and F-Curve RNA:
* Fixed the handling of the 'draw_active' flag for drawing of armatures. This is now cleared from bones in old files (so one bone always got represented as active in the viewport even when others were selected), and the flag is correctly set temporarily when drawing the bones (only one place had been done).

* Fixed typo with SplineIK that was making the root bone of the bone chains always be ignored. Similar functionality can come back at some point, but in a more useful form.

* Shortened the UI names for the F-Curve colouring modes to increase readability. The old ones were too long to be able to distinguish between entries in the UI.
2009-11-09 23:41:48 +00:00
d34261edab Don't free Context from python.
There might be a better way to do this, Cambo, please check.

This solves the Totblock == -1 error
2009-11-09 23:33:56 +00:00
60ea745613 Math Lib Reorganization
* New header and source files.
* Still need a few tweaks before switching code to use them.
2009-11-09 22:42:41 +00:00
5935ef0049 use armature active bone as a pointer rather then a flag for each bone that needs looking up.
- rna vars arm.bones.active & rna.edit_bones.active
- needed special undo support.
- readfile.c loads.
- duplicate and copy_armature support.
- keep the draw flag, renamed to BONE_DRAW_ACTIVE, only use for openGL drawing.

Note: it may be better to allow active/unselected as with objects.
2009-11-09 21:03:54 +00:00
3e2766bc2e Add FFTW3 support to Makefiles, make OpenJpeg use OS lib for Linux.
And handful of whitespace clean ups.
2009-11-09 20:08:19 +00:00
8ab49a4c5e fix for running datatoc on files in a subdir (was adding slashes into the C variable name) 2009-11-09 20:03:59 +00:00
6dd96fcfa8 Update of older commit (23102) from Bob Holcomb -- fix for Darken mode blending was only in place for nodes, not for general texture blending. This updates texture blending to reflect the fix. Now results don't trend toward black on Darken anymore as factor approaches 0. 2009-11-09 19:20:48 +00:00
45c0f70e3e - scons fix for linux build 2009-11-09 18:32:59 +00:00
ff0ba86a9b Mac :
- scons update to build with openCollada

- scons & cmake update for render optimization cflags
2009-11-09 17:52:13 +00:00
9c0cdd2501 - fix Cocoa window setOrder function to maintain focus on a blender window (e.g. ensure the blender window gets the focus when the user presses ESC to move back the render window)
- QuickTime export fixes.
Note that QuickTime export still crashes because it tries to open a "codec settings" dialog from the rendering background thread (and not the main/UI thread).
One quick fix may be to move the movie export initialization out of the render thread back into the operator function.
But a cleaner way would be to get rid of such a carbon/win32 dialog and place the codec settings inside blender interface
(additional fields in the output panel as it is currently the case for other file formats ?).
2009-11-09 17:06:48 +00:00
196ecb7bab material shader curve factor (same as compo node) 2009-11-09 16:00:12 +00:00
ded68d81d8 * Fixing tooltips: "ratraced" > "raytraced". Patch by Oxben on mailing list. Thanks. 2009-11-09 13:55:04 +00:00
0bb70e4fae workaround for crash when dragging nodes 2009-11-09 11:15:49 +00:00
0750a8dc5c simple fix, still worked on my PC somehow 2009-11-09 09:16:16 +00:00
97e7e26bab - added particle select_inverse
- added select root/tip to the select menu
- selection drawing updates for select more/less were not working
2009-11-09 08:51:34 +00:00
ae91ca7217 OpenGL grease pencil render
Algorith: needed to add some functions since offscreen render doesn't have a context pointer
 - draw_gpencil_3dview_ext
 - gpencil_data_get_active_v3d
2009-11-09 08:03:43 +00:00
521af99f59 Fixed this startup crash on windows:
- cd to blender dir
- type 'blender'
- crash
2009-11-08 21:33:43 +00:00
55beacfa47 *Small tooltip fix for strand start/end. 2009-11-08 17:58:06 +00:00
9e90cf6d78 Sequencer: (small Durian wish)
* new operator: set rendersize (SEQUENCE_OT_rendersize) sets the render output size in the current scene to the size of the active sequence strip
* works for movies and images right now
* TODO: currently only works if image or movie strip has been loaded (as in showing the preview for example) - reason is that otherwise the size is not initialized in the strip
2009-11-08 15:03:10 +00:00
af011f33a6 use the cwd for the shell prompt, use subprocess.getstatusoutput rather then popen() 2009-11-08 12:35:37 +00:00
49cb4d0065 support much longer prompts for the console 2009-11-08 11:33:01 +00:00
18a5cd095a * Removed "Lock" Prefix from items inside Transform Lock Panel for consistency.
* Code cleanup to match guidelines, we don't use subrow1 or so anymore, remember? :)
2009-11-08 11:07:00 +00:00
e214023c11 Nodes:
* Slight offset tweak for Node header icons, not so cluttered now.
2009-11-08 10:20:03 +00:00
12ee852c11 MSVC 9 projectfiles
* small maintenance: rna_fcurve_api.c added
2009-11-08 10:07:37 +00:00
10900f1de8 Graph Editor Drawing Tweaks:
* When there is only a single keyframe for a F-Curve, the handles aren't shown anymore. This looks nicer than the fat orange blobs that appeared
* Tweaked the management of GL_BLEND when drawing animation channels in the Graph Editor in an attempt to fix some of the missing text drawn issues.
* Converted the properties panel to use layout engine + added color selectors
2009-11-08 06:43:08 +00:00
fac2ca1c7c bpy/rna api class feature
- python defined classes will be used when available (otherwise automaically generated metaclasses are made as before)
- use properties rather then functions for python defined rna class's
- call the classes getattr AFTER doing an RNA lookup, avoids setting and clearing exceptions for most attribute lookups, tested UI scripts are ~25% faster.
- extending rna py classes this way is a nicer alternative to modifying the generated metaclasses in place.

Example class

--- snip
class Object(bpy.types.ID):

    def _get_children(self):
        return [child for child in bpy.data.objects if child.parent == self]

    children = property(_get_children)
--- snip

The C initialization function looks in bpy_types.py for classes matching RNA structure names, using them when available.
This means all objects in python will be instances of these classes.
Python properties/funcs defined in ID py class will also be available for subclasses for eg. (Group Mesh etc)
2009-11-08 01:13:19 +00:00
30c4c4599d pedantic enum string consistancy 2009-11-07 22:12:03 +00:00
4e61f8a836 pep8 whitespace commit
bpy/rna api (no functionality change, just move getting the srna py base into a function)
2009-11-07 22:07:46 +00:00
5bb88685ca fluid cache need a +1 offset, their frame 0 is blender frame 1 (fun stuff) 2009-11-07 17:47:54 +00:00
7b96bc00d5 Merge -c 24393 (patch by Jan) from COLLADA branch. 2009-11-07 14:34:04 +00:00
f25bc95688 missed committing this file (from Stani's patch) 2009-11-07 14:17:49 +00:00
ddeb9f8e24 - added console language type
- separated python console from the interactive console
- added shell console type (simple example)
- console types are autodetected and can be selected in the menu
2009-11-06 23:53:40 +00:00
6e47d9bb9c - modal keymap for border select
- revert circle select keys adjustments & view navigation while selecting (durian guys liked but allowed activating multiple circle select's at once)
2009-11-06 22:51:08 +00:00
e2f01e4c7c api changes suggested by Stani 2009-11-06 22:42:15 +00:00
5a5646934c Fix for transform orientation fix, probably forgot to commit this? 2009-11-06 22:10:08 +00:00
f21d0bacf7 Bugfix: crash in posemode transform buttons with no active pose bone. 2009-11-06 21:41:07 +00:00
0b027b4097 Make orientation matrix access function public.
Fix bug in previous code: passing 3x3 matrix to a function expecting a 4x4 (warnings are for something)
2009-11-06 21:31:14 +00:00
5c3a365ac4 * Added "Align View to Selected" to the View > Align View menu.
Patch by Jeff Doyle (nfz). Thanks!
2009-11-06 21:10:45 +00:00
1327833282 Sculpt: WIP brush behavior changes
* Draw/Inflate/Layer now keep working on the original mesh coordinates and
  normals from when the stroke started. This helps avoid the mesh blowing
  up, but can still be better. The old behavior is still available as
  "Accumulate" in the UI.
* This requires some more memory usage for the BVH, would like to find a
  way to avoid that.
* Smooth falloff is now the default.
* Spacing is now enabled by default, with a value of 7.5.
* Anchored now stores normals per node to save some memory.
2009-11-06 16:46:35 +00:00
0ffdcfecb3 B.blend.c update. Only change is that brushes and panels are not saved, so
that they will be recreated with defaults settings/order.
2009-11-06 14:46:07 +00:00
4e9699debf experemental durian request, allow view manipulation while using circle select 2009-11-06 12:43:20 +00:00
aa7374e471 - removing the last particle system now exits particle edit mode.
- py UI script used an undeclared variable
2009-11-06 12:27:28 +00:00
5a12b7d159 Driver Scripting:
Added RNA functions for adding and removing Driver Targets. Unfortunately, I couldn't do this by simply adding callbacks for the add/remove of the collection, as I've had to add to extra RNA functions to do that.

Example usage - driving Lamp Distance with Cube LocZ:
myOb= bpy.data.objects["Lamp"]
myOb.driver_add("data.distance")

# drivers is list of F-Curves that have driver data
drivers= myOb.animation_data.drivers
distDriver= drivers[0].driver 

dtar= distDriver.add_target("ctrl1")
dtar.id_type= 'OBJECT'
dtar.id= bpy.data.objects["Cube"]
dtar.rna_path= "location"
dtar.array_index= 2
2009-11-06 11:09:04 +00:00
d4fe2595f7 bring back align to view to object
- In 2.4x this was numpad *, however that would only align on the Z axis.
- New behavior for VIEW3D_OT_viewnumpad, holding Shift with Numpad 1/3/7 sets the left/top/front etc on the normal axis.
- Uses active bone, face, edge, vert, curve handel & object (just like the view manipulator with 'Normal' selected).
2009-11-06 10:38:00 +00:00
cc2476fde5 patch from Stani, support for function arguments in autocomplete 2009-11-06 08:53:07 +00:00
e1e6391a0b Fix for scons + mingw compiling
Removed the special exception for booleans lib priority, which was needed in the past to get it compiling ok with the src directory.
2009-11-06 08:32:50 +00:00
d315af74f0 Update MSVC project files for openCollada. 2009-11-05 21:34:47 +00:00
6771a0cb6d Fix #19763: crash with tooltip open & maximizing area to fullscreen. 2009-11-05 20:51:36 +00:00
bb0f4310aa Simple one liner....
Added options to add Flip normals to toolbar.  (iCer on irc is responsible)

Kent
2009-11-05 20:35:36 +00:00
43d916c08a Fix bug #19754: alt + scrollwheel to change button values was not
working in popup menus, silly workaround now until this uses modal
keymaps.
2009-11-05 20:32:46 +00:00
c0bfa4e462 Fix for bug #19692: setting text on curve, bevel or taper object did
not update dependency graph causing missing updates.
2009-11-05 19:32:10 +00:00
44db0b0e27 view docs was broken for operators - was getting the nested class string. 2009-11-05 19:31:38 +00:00
17c323b5a4 Fix for bug #19817: cloth simulation with collision slow on Mac.
The cause of this is in the bullet library, seems like some kind
of poor handling of many repeated allocations by Mac OS X, but the
allocation is unnecessary, so removed it.

Patch submitted to bullet:
http://code.google.com/p/bullet/issues/detail?id=303
2009-11-05 19:06:29 +00:00
aec92ddc51 operator to select pos/neg verts on any axis relative to the active vertex
- useful to select the center verts of a model without having to attempt to border select
- useful for selecting one half or a model
2009-11-05 18:29:48 +00:00
1196947a98 Fix makefiles for modifiers commit. 2009-11-05 18:17:18 +00:00
1e40adddc7 2.5 Modifiers: mesh deform, boolean and decimation work again. 2009-11-05 18:05:55 +00:00
bdfa652605 adding group instances didnt do an undo push 2009-11-05 17:43:23 +00:00
8109b13e83 - converted circle select use a modal map
- now works exactly like 2.4x, except that its accessed from the CKey
- hack to remember circle size, need some better way to do this
2009-11-05 17:32:06 +00:00
aec5fb9804 Fix warnings in RNA, one being an actual bug in setting an object's layer. 2009-11-05 17:28:10 +00:00
93b2ed3822 Moved the object and bone name fields out of the Transform panel in 3Dview properties. They're in a new panel now called 'Item'. Needs an update in the B.blend to put it on the top. 2009-11-05 17:22:11 +00:00
82baca3f36 Fix for bug #19807: renaming texture layers in editmode crashes. 2009-11-05 16:40:12 +00:00
18e069f486 only run the banner function for console (not reports) 2009-11-05 16:30:18 +00:00
0f1e28a13f - circle select mouse wheel resize now works (somehow mouse wheel generates a mouse up event)
- context.active_bone wasnt set to an editbone type
2009-11-05 15:59:14 +00:00
5481549725 was setting the active material on exit editmode rather then enter 2009-11-05 14:54:02 +00:00
59eaa1ff50 last commit broke entering editmode 2009-11-05 14:42:39 +00:00
2907c6fdf0 Moved the buttons around slightly in shape keys, to make it clearer what is action buttons, and what is toggles. 2009-11-05 14:31:17 +00:00
b1ac71b3a0 enter editmode when adding objects even if the object is not in an active layer,
useful for python but in rare cases this also happens for users.

Active layer getting out of sync is an old bug but hard find when it happens.
This at least fixes segfaulting on adding objects.
2009-11-05 14:25:08 +00:00
be4ceb5fdf Select interior faces, access from the mesh select menu
new mesh functions, remove duplicates in uvproject and mesh_skin
- face.edge_keys()
- edge.key()
- mesh.edge_face_count()
- mesh.edge_face_count_dict()
2009-11-05 12:37:49 +00:00
247f72fcc0 - added bpy.context to the python module
- made the console banner printing function into a python operator (includes sys.version)
- added 'C' into the consoles default namespace for convenience
2009-11-05 11:17:09 +00:00
cacd68c335 python console autocomplete would crash (missing NULL check for pose channels)
add rna functions id.animation_data_create() and id.animation_data_clear() - works for all ID types that support animdata.
2009-11-05 10:50:58 +00:00
06d5d53a24 Bugfixes + Spline IK Tweaks:
* #19819: 'Select' operator for Hooks was crashing when Hooks didn't have any vertices assigned yet

* Default twist resolution mode for curves is now 'Minimise'. This seems to work better for Curve Deforms and other purposes. Can be changed if other ways are better after some more testing.

* Spline IK now has more options for controlling how the x and z axis scaling is determined. There is now a choice between using the radius of the curve, the x+z scaling from the bones, or no scaling (default). This does break old files a bit, but this is to have a more stable base for later.
2009-11-05 10:09:45 +00:00
751f07d6d4 Fix for error in previous fix - oops ( [#19818] ) 2009-11-05 10:02:29 +00:00
48bc52ea1b fix for editing docs 2009-11-05 10:02:14 +00:00
0b2bc7785d * Fix for [#19700] undo doesn't display visual feedback on lattices
Depgraph update was commented out in undo system because of globals, restored this with new context/id-based depgraph

* Fix in UV editor UV menu
* Slightly nicer default names for adding forcefields with Add menu
2009-11-05 09:57:43 +00:00
63d6d6cb74 Armature Editing Bugfixes:
* #19790: Circle Select doesn't work for Armature edit mode or pose mode
* Duplicate bones (Shift-D) was calling the wrong operator. This now uses the macro version, instead of the copy only.
2009-11-05 08:54:33 +00:00
ce973efd4f Fix for [#19780] pivot for rotation/scaling doesn't use "active vert/edge/face"
Martin please doublecheck, but it should be all good.
2009-11-05 04:37:42 +00:00
539a68f6c0 Fix for [#19793] Resolution Sliding Crashes Blender 2.5 SVN 24256 2009-11-05 04:07:58 +00:00
38f7839218 Fix for [#19299] Color render bug
Caused by very evil AO subtractive mode going negative once again...
2009-11-05 03:39:42 +00:00
9eb0f20224 Added mass and spring vertex groups to softbody rna/ui 2009-11-05 02:50:26 +00:00
1be4158f5b RNA transform properties for edit bones and metaballs 2009-11-05 02:21:04 +00:00
fa5990cb9a Added RNA based transform properties for pose bones too.
I've left the old code commented out for now hough - do we still want to 
be able to edit all rotation types as eulers in the transform properties buttons? 
Seems a bit odd to me, what do animators think? If so, maybe we need some 
ui-level conversion options in the RNA buttons code...
2009-11-05 01:00:17 +00:00
be143c2244 * Partial fix for bug [#19734] N panel's transform doesn't display the units
Converted the Object transform properties to use rna/rna buttons. This has the advantage of not only displaying/editing units, but also RMB menu, keyframing, drivers, etc too. Part of this was to convert 'Dimensions' to an rna property, converting to and from scale. This also allows you to set the object's dimensions via fcurves or python, but note that it's driving the object scale setting internally so if you animate both dimension and scale at the same time one will override the other (i don't expect many people to attempt this).
2009-11-04 23:14:20 +00:00
e6ea68a31c - missing return values
- more detailed exceptions (always give file:line incase the python exception doesnt)
- fix some errors in the edit docs

editing docs still fails, need to figure out why.
2009-11-04 22:36:46 +00:00
9c1c0152df Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24257:24330 2009-11-04 21:21:30 +00:00
68278f35e8 Sculpt: tool updates for latest changes
* Smooth: vert-face map is now only created when this tool is used, would be
  best to also avoid using it here to avoid a sudden increase in memory, but
  is not trivial.
* Grab: now no longer uses active verts list and loops over nodes like other
  tools.
* Layer: uses original coordinates from undo now to save memory when not
  using persistent layer.
* Anchored: this option works again now, though is still quite slow as it
  loops over all verts/faces.

Smooth, layer tools and the anchored option could still be improved to use
less memory and/or work faster by only doing things per node.
2009-11-04 21:10:28 +00:00
678d37fe4e Sculpt: now uses it's own Undo stack like editmesh. The main advantage here is
that it is able to store changes in the mesh more compact than global undo.

It doesn't integrate well with multires yet, will tackle that when I start
looking into multires, for now still focusing on sculpt on regular meshes.
2009-11-04 20:56:46 +00:00
08bbda5005 - Stopping jobs on undo wasnt fixing undo/redo while with render previews as it was supposed to: needed WM_jobs_stop_all rather then WM_jobs_stop because it ends the thread rather then just setting 'stop'.
- gpl header + warning fix
2009-11-04 20:50:09 +00:00
e73a2bd55a make render, world and material buttons show when netrender is selected 2009-11-04 20:42:05 +00:00
55611fb2e6 Sculpt: don't create DM face normals in sculpt mode, only update them if
they exist already, to save memory.
2009-11-04 20:40:15 +00:00
636fe90680 Sculpt: updating normals now no longer uses the vert-face map, to save memory.
The weak point now is the thread-safe atomic access to normals from multiple
threads, did not seem to be a bottleneck in my tests but I don't really trust
it to be fast.
2009-11-04 20:36:38 +00:00
b90d8ec0f4 Sculpt: derivedmesh no longer created CD_ORIGINDEX layer when there
is no modifier, saving some memory.
2009-11-04 20:23:48 +00:00
3fa8959bb5 - move WM operators out of bpy_ops.py into their own file
- fix operator template
2009-11-04 20:21:08 +00:00
4bdfa8a7d7 Sculpt: split generic part of image paint undo system into separate
paint_undo.c file, to be reused for sculpt.
2009-11-04 20:19:41 +00:00
8b8f8fc11e Sculpt: fix bug where mouse release event was not caught in some cases. 2009-11-04 20:15:17 +00:00
6e1f215c20 Bugfix: sculpt layer brush "persistent" option was not showing up in UI. 2009-11-04 20:12:27 +00:00
4f10b3db6a Sculpt: memory statistics now also print out a small python script to
plot memory usage, requires matplotlib.
2009-11-04 20:11:57 +00:00
51943096a9 bugfix [#19804] .MDD is not working?? // Also filetype issue?
- made all exporters default to the blend filename with the extension replaced
- MDD's poll function now checks for an active mesh
- multiline docstrings are written as multiline docs when generating epydocs
2009-11-04 18:35:32 +00:00
fe82c2674e Mac / Cocoa:
- Fix update event fired at each loop iteration. Thx Brecht for the patch
- Fix missing deactivate event when in fullscreen mode
2009-11-04 17:50:31 +00:00
8af525f860 bpy.ops.import.obj("somepath") is invalid syntax because import is a keyword.
rename import to import_scene, import_anim, future import_sequence_edl, import_model etc..
2009-11-04 17:16:58 +00:00
edeae7477b fix for some python errors 2009-11-04 16:26:08 +00:00
b36c4f3987 Merging change 24311 from COLLADA branch into trunk which should fix object-based rotation import/export. Bone rotation animation not fixed yet. 2009-11-04 15:25:57 +00:00
3ac98f1abd python function for adding a driver. eg
ob.driver_add("location")
 ob.driver_add("location", 0) # x location only

Also changed ANIM_add_driver so an index of -1 adds drivers to every item in the array
2009-11-04 15:16:41 +00:00
4033aba579 new operator directory, move some scripts from io 2009-11-04 14:40:35 +00:00
69aaa43c24 quick update of bvh importer for blender 2.5, mostly this is to test the python api.
- bvh joint rotations are not working quite right yet
2009-11-04 14:33:37 +00:00
37fde5b335 bvh import from 2.4x (unchanged) 2009-11-04 14:31:14 +00:00
8436608513 Bridge edge loops would loose all edge flags.
Would happen in any case where python added new mesh data into an existing mesh.

fix by copying the old edges into the new array
2009-11-04 14:28:43 +00:00
42fb30f37a change to insert_keyframe() so an array index of -1 keys all arrays indices
made this default for python so you can do...
 pose_bone.keyframe_insert("location")

rather then
 pose_bone.keyframe_insert("location", 0)
 pose_bone.keyframe_insert("location", 1)
 pose_bone.keyframe_insert("location", 2)
2009-11-04 14:06:10 +00:00
510aa6ba53 particle vertex group UI
Changed RNA vgroup access to use strings (string functions adjust the ints used internally)
2009-11-04 12:09:02 +00:00
20c424730e Spline IK: Rolling Control
Recoded the way that Spline-IK computes the x+z axes of the bones so that flipping artifacts are minimised, and the rotation of individual bones can be used to affect the results of the solution, as per requests from Cessen. 

The bone matrices are now computed normally, and then made to conform to the orientation + scaling imposed by the splines, using the Damped-Track method. Previously, the axes of the bones were calculated without regarding the prior orientation of other bones in the chain, which lead to "z-twists". 

Notes for further investigation:
- There appears to be some shearing that gets introduced now. Unforunately, I can't seem to isolate the cause of this, but I hope it's not going to become too much of a problem in general.
- Maybe inverse corrections for rotation will now be necessary when using transform tools?
2009-11-04 11:30:48 +00:00
46c8bfe151 Make Links (Ctrl+L) back
- split into 2 operators: object.make_links_data() & object.make_links_scene since they are quite different.
- added reusable functions RNA_group_itemf & RNA_scene_itemf which can be used for any operator that takes ID data (easy to add more types Mesh, Text etc)
- DummyRNA_NULL_items for dynamic items so each operator need not define its own empty enum.
2009-11-04 10:25:57 +00:00
b221e57fd2 Second try at fixing this... the props were still not getting initialised in many cases, but this time because those were using the exec() callbacks which didn't set this. This fix ain't that nice, but at least the old functionality works again like 2.4x. 2009-11-04 09:55:24 +00:00
de7da7c779 Bugfixes for Adding Objects:
* Auto enter EditMode for adding Armatures was broken
* Adding a camera no longer tries to enter editmode, even though that's invalid...
2009-11-04 09:45:37 +00:00
7fad20eff8 Fix #19533: Autoupdate check box not working for UV/Image Editor. 2009-11-04 09:22:16 +00:00
ae37d92dbf Fix #19742: shape key crashes for curve & lattice. 2009-11-04 09:20:31 +00:00
834e8aa868 Fix bug #19749: browsing path in user preferences would crash. 2009-11-04 08:59:01 +00:00
e9ce90c238 Fix bug #19699: point density texture doesn't save particle system.
Non-ID pointers in DNA can only point to data from own ID block, so
now instead it uses an index into the particle system list, but still
exposed as a pointer through RNA.
2009-11-04 08:44:42 +00:00
3c6b721fc9 Bugfix #19777: Owner Space not Target Space for Action Constraint was getting exposed via the UI.
The former is useless and probably dangerous to enable here, while only the latter is useful for anything.
2009-11-04 05:45:57 +00:00
a799b6ee06 Fix for [#19745] displacement modifier is messing up texture coordinates when using an object for texture coordinates
Modifier was resetting object's imat to worldspace during render process, where it is assumed to be in camera space.
2009-11-04 05:31:42 +00:00
7699dcaab8 Fix for [#19460] (+) widgets to expand UI elements overlap other windows 2009-11-04 04:13:30 +00:00
183e698af8 Fix for [#19752] I cant get the particles to render as an object 2009-11-04 03:01:39 +00:00
2a8ef208b2 Soft bodies care for real time 2009-11-04 00:21:25 +00:00
a4e91f8f1a Moved the show brush flag from sculpt to paint, and it now shows/hides the brush as expected. Also fixed some errors in the UI scripts. 2009-11-03 22:50:09 +00:00
c8ee492e7a Changed hand-generated RNA paths to quote strings used as collection indexes.
Previous method worked fine for Blender animation system, but this is more convenient for Python.
2009-11-03 22:07:15 +00:00
f20b3b3102 Removed the unused partial redraw flag from sculpt. It's original purpose was to work around graphics cards that didn't support the old partial redraw method, but that should no longer be an issue. 2009-11-03 21:58:24 +00:00
2db1851c26 uv smart project now in unwrap menu with 2 most important options 2009-11-03 18:56:42 +00:00
65f92c893e - remove UV mapping operator, call a header menu directly (so python can add items there)
- forgot to move bpy_sys.py last commit
2009-11-03 18:20:03 +00:00
6680dcd24a renamed bpy.sys to bpy.utils, since it used to be a attempt to replace pythons sys which is bundled now 2009-11-03 18:08:25 +00:00
e4f90d9379 quick port of smart project to 2.5x, no operator options yet 2009-11-03 17:51:22 +00:00
89c2b9a77e script copied from 2.4x with no changes 2009-11-03 17:47:44 +00:00
11c36d0ea5 Patch [#19799] Add trackball loop to rotate manipulator
by Adrian Winchell (slightly modified)

This adds a center circle (like translation and resize) to the rotation manipulator that triggers trackball rotation.
2009-11-03 17:44:12 +00:00
2a61c7fd89 error in last commit (wasnt writing NULL when no active property exists)
added id.tag so you can tag any library data - materials, meshes etc
2009-11-03 17:00:38 +00:00
b8b89d5ae4 active property for collections for things like scene.objects.active
will add more properties later
2009-11-03 16:07:29 +00:00
b3c8935b06 - Shift+F1 is append in 2.4x (not link). Lee asked it to be made the same.
- use OBJECT_OT_mode_set rather then OBJECT_OT_*_toggle, better for using report output for script input. OBJECT_OT_posemode_toggle and OBJECT_OT_editmode_toggle are called by OBJECT_OT_mode_set.
2009-11-03 11:00:10 +00:00
f18c7161c4 Mac :
- add optimize flags setting in CMake for release builds
2009-11-03 09:56:18 +00:00
8a57ff7afa Slightly nicer OS X quit message 2009-11-03 07:24:22 +00:00
cbc5a78576 whitespace commit, (was some tabs mixed with spaces too) 2009-11-03 07:23:02 +00:00
8cbad63c22 Fix [#19759] Point Density Texture
Use derivedmesh functions to get object vertices, rather than objectren verts (which can not exist if object is non-renderable)
2009-11-03 06:04:42 +00:00
918d07dd5d * Fix for bug [#19726] Cannot add FCurve to any option under the physics panel except cloth
I had to add some ugly RNA path finding code here, checking for all places these structs can possibly be reused. Can't think of a better way to go about this though with the path stored in the RNA type...?
2009-11-03 02:49:36 +00:00
Nathan Letwory
46487ad59e == COLLADA ==
* fix win64 build and add proper library usage for COLLADA 64bit. Update also lib/win64 (r24263).
2009-11-02 23:55:04 +00:00
5ff7cbd2f9 fixing minor issues
such as ignoring forward timing rule
2009-11-02 23:42:08 +00:00
5c538fc832 Mac :
- remove CMake warnings when building with openMP
2009-11-02 20:40:47 +00:00
acc09693c4 update from Keith Boshoff, use selected faces while in face-mask mode as well as some other cleanup 2009-11-02 20:18:05 +00:00
eafd94e1bd Make transform axis constraint projection more robust (less flip).
It will still flip, but it now has a small buffer region before it does that which returns a really large positive or negative value. This still only happens in perspective cases, when moving along an axis that is nearly aligned with the view.
2009-11-02 19:37:18 +00:00
efd6d5f3a7 Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24152:24257 2009-11-02 18:56:56 +00:00
3078c80635 Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
  using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
  bounding boxes, partial redraw, .. . There's probably still a few
  left, but should be better now.
* Clicking once now does a single paint instead of two (was also
  painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
  uses it (so it can be tested at least).

Implementation Notes:

* PBVH search can now be done either using a callback or bt gathering the
  nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
  should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
  to indicate what needs to be updated for them, found that this makes it
  easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
  clear what is happening than having it's data passed as part of callback
  functions.
* Active_verts list was replaced by looping over nodes and the vertices
  inside them. However the grab brush still uses the active_verts system,
  will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
  using local variables instead of pointers, or looping over fewer vertices
  to update the bounding boxes.
2009-11-02 18:47:03 +00:00
6bfcd5a811 how embarrassing! 2009-11-02 17:25:15 +00:00
072a39004e - "selected_pchans" is now at screen level context (not just view3d) so can use for adding bones to a group.
- separate assign to Y key rather then Ctrl+4
2009-11-02 17:24:06 +00:00
67fd40f54c Enabled theme editing in user preferences. There's still no way to Load/Save/Add/Delete though.
Code could be optimized greatly, but found it hard to get it to work nicely with auto-generated code.
2009-11-02 17:18:17 +00:00
54d7ca9e3b armatures didnt allocate enough memort for make_trans_verts
result in blender crash when pressing numpad del.
2009-11-02 17:15:14 +00:00
bd88c3e944 moving nodes would crash because it ran object update functions 2009-11-02 16:55:06 +00:00
8557f617f0 Pose bone menu (Ctrl+G) wasnt working, replace with a reference to python menu. 2009-11-02 16:39:45 +00:00
1d9f90ed42 - all add object operators now take view_align as an argument, and enter_editmode where its used. Makes running the operator from python pradictable without having to know the user prefs.
- missing return in function
- python error in view3d (assumed active object exists)
2009-11-02 16:07:49 +00:00
9ea97203ae Mac :
- Updated CMake files for building with openCollada

Update of the 10.5 libs including openCollada is coming in next commit
2009-11-02 14:03:13 +00:00
9e9ab1a227 *Added subdivide to armature toolbar, and gave it a hotkey (W)
*Fixed some remaining icon issue in the shape key properties
2009-11-02 13:20:14 +00:00
a87c16947d * Set some custom empty draw types on adding force fields, where relevant 2009-11-02 11:37:35 +00:00
4b8c64246e * Added a new 'bone constraint' property editor icon and panel titles to distinguish bone constraints from object constraints
It was a bit too confusing and people were easily getting them mixed up.
2009-11-02 11:36:45 +00:00
3b43a5228e Mac / COCOA :
- revert tiff load/save to use standard libtiff (to ensure 100% colorimetry & alpha interpretation across platforms)
- include patch #18720 to fix load of libtiff dynlib (if present on system)
2009-11-02 11:20:31 +00:00
da1765765b many operators uses Bases, for the python to set operators context python too needs to be able to access bases.
- added scene.bases (like scene.objects)
- renamed group create operator.

Example
 scene = bpy.data.scenes[0]
 C = {}
 C["scene"] = scene
 C["selected_editable_bases"] = [scene.bases[2], scene.bases[3]]
 
 bpy.ops.group.create(C)


Also made operator fake modules not return __call__ (reported by Stani, fixes autocomp. bug)
2009-11-02 11:14:22 +00:00
da6081f266 Fix for bug [#19668] Blender freezes if step size 0 is used for a volumetric material -- limit the minimum step size 2009-11-02 10:30:51 +00:00
3b910a7809 Fixed typo in key display code, was making the shortcuts for [ and ] (used in bone selection) inverted in the menu shortcut hint 2009-11-02 10:20:06 +00:00
334a80a4f8 Spline IK Experimental Features:
1) "Even Divisions" - This option ignores the length of bones when considering how they should fit along the curve. This is useful for getting a smoother curve fit without having to worry about getting the bone lengths spot on. By default, this is disabled.

2) "Keep Max Length" - This option prevents the bone chain from extending past its natural length when the spline is stretched beyond that length. When the spline length is substatially shorter though, this bones get scaled to zero; making this option possibly useful for doing "growing tips". 
This is essentially a 'no scale' option, although the behaviour when the curve is shorter is really a compromise since the curve cannot be accurately satisfied + left intact without some scaling being applied due to the way this works.

3) "Radius to Thickness" - The average radius of the spline between at the head+tail of each bone determines the x+z scaling of the bone.
2009-11-02 10:04:37 +00:00
27580daf27 Added back texture filter/minimum settings to image texture properties 2009-11-02 09:31:55 +00:00
a9f6eaf847 vertex paint script ported by - Keith "Wahooney" Boshoff
Todo
- Add back nicer normal calculation function
- Make pep8 compliant
- Add vertex color layer when none exist
2009-11-02 09:26:55 +00:00
dd130350d5 make python operator instances subclasses of the wmOperator when called.
was subclassing the operator's type before.

Removes the need for passing self.__operator__, can pass self directly.
2009-11-02 08:32:00 +00:00
ab7a174f92 Added some missing menu items + fixes 2009-11-02 08:05:16 +00:00
Nathan Letwory
773253df72 == COLLADA ==
* proper library names and order. Goes together with 76MB commit for r24225
2009-11-02 00:30:52 +00:00
c90db8d270 last commit broke running python operators
note that you can still set rna properties like this.
 bpy.data.__dict__["var"] = 1
 print(bpy.data.var)

but this is only stored for the python objects lifetime and not actually attached to blenders data
2009-11-02 00:20:07 +00:00
e8b5effdff Spline IK Bugfixes 1:
* Fixed crash when reloading a file with Spline IK and/or Damped Track constraints. The targets for these constraints weren't getting relinked.
* Fixed problems with removing Spline IK making some bones unable to be manipulated.
* Jotted down some comments in the Spline IK code noting places where additional tweaks will be added.
2009-11-01 22:30:47 +00:00
a99157b20d rna structs would not raise an error when assigning invalid properties
netrender needed updating for this.
 hint, bpy.data is not a module
2009-11-01 21:53:45 +00:00
94209d58aa Simplify gimbal axis code and make gimbal orientation work correctly with parents (objects or pose bones). Works for all euler orders too, obviously. 2009-11-01 21:10:54 +00:00
7bb6e18f20 Fix view3d rna to work with new number of orientations (use constant instead of value, safer for future). 2009-11-01 20:17:30 +00:00
39021ac4ea after transform update didn't run because of stupid typo 2009-11-01 20:09:03 +00:00
a51fe76ff2 Fixed a few icons in user preferences Input tab 2009-11-01 19:45:50 +00:00
2cf22b53bc add_mesh_torus now passes the pep8 test 2009-11-01 18:07:35 +00:00
29aea786cb Added proper icon for full screen mode. Would be nice to have this button eventually be right-aligned. 2009-11-01 18:05:01 +00:00
e4617d8a5f MSVC project files update for collada. It won't compile yet, waiting for lib/windows/collada to be updated. 2009-11-01 17:12:09 +00:00
9ea292290b Correct GPL license header for all python scripts 2009-11-01 15:21:20 +00:00
9cf155d012 Compile fix for too many arguments to uiItemO 2009-11-01 14:19:35 +00:00
4f4b637a35 * OpenGL Render is now available again from the View3D Header. 2009-11-01 14:04:37 +00:00
3111ebde65 Quick tweak to version patching code for Camera IPO's to fix one of the issues in bugreport 19761.
For now, this just assumes that the 'lens' parameter was animated (assuming a perspective lens was used). Unfortunately, this may not always be correct, but at least there's a path now that can lead to further tweaking.
2009-11-01 11:33:41 +00:00
2068eaf1b7 Rigging Goodies: Spline IK Constraint
At last, this commit introduces the Spline IK Constraint to Blender. Spline IK is a constraint that makes n bones follow the shape of a specified curve. 

Simply add a chain of bones, add a curve, add a Spline IK Constraint to the tip bone and set the number of bones in the chain to make it work. Or, try the following test file:
http://download.blender.org/ftp/incoming/250_splineik_spine01.blend

Screenshots of this in action (as proof):
http://download.blender.org/ftp/incoming/b250_splineik_001_before.png
http://download.blender.org/ftp/incoming/b250_splineik_001_after.png

I've implemented this in a similar way to how standard IK solvers are done. However, this code is currently not an IK plugin, since I imagine that it would be useful to be able to combine the 2 types of IK. This can be easily changed though :)

Finally, a few notes on what to expect still:
* Constraint blending currently doesn't affect this. Getting that to work correctly will take a bit more work still.
* Options for not affecting the root joint (to make it easier to attach the chain to a stump or whatever), and non-uniform scaling options have yet to be added. I've marked the places where they can be added though
* Control over the twisting of the chain still needs investigation. 

Have fun!
2009-11-01 11:29:40 +00:00
cb45db0336 * Some guideline work for the particle py file.
* Minor layout tweaks in Node RNA to match most other RNA enums.
2009-11-01 10:45:42 +00:00
95fbca7dc9 Mac / COCOA :
- fix imbuf Cocoa resolution handling issue
2009-11-01 08:23:53 +00:00
69feedf139 Object PET works with autokey.
Reordering some function calls in transform cleanup to make it simpler (that means other fixes are possible too, sequencer probably don't need it's own freeing function anymore).
2009-11-01 02:52:38 +00:00
d964808846 made scripts pass the pep8 test (though not fully pep8 yet)
added comment in header to know if a script has been converted or not.
2009-10-31 23:35:56 +00:00
41c0236aaa GPL2 header from firebird (without disclaimer), notice theres no copyright attributed and only the GPLv2 (without the v2 or later clause).
Contributors list isnt used much in our C code so probably its easier if people just use svn blame for this.

Can change if this isnt acceptable but I guessed people didnt care so much since most scripts had no header.
2009-10-31 20:16:59 +00:00
944a8d33fe renamed buttons ui files to properties to match UI name change, needed to update some imports too 2009-10-31 19:57:59 +00:00
f9b19d54b5 tabs to spaces, remove trailing white space. (apart of pep8)
didnt do "release/scripts/io" since some exporters cant be auto converted
2009-10-31 19:31:45 +00:00
af72bb50ae improved class validation, variables defined by the rna interface as non-optional could fail silently when absent in the class. Set these to PROP_REGISTER_OPTIONAL and raise an error when others are not found.
last commit broke povray too.
2009-10-31 18:48:58 +00:00
e4881eef52 define operator properties in the class, similar to django fields
# Before
[
	bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= ""),
	bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
	bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
	bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
	bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
]

# After
path = StringProperty(attr="", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
use_modifiers = BoolProperty(attr="", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
use_normals = BoolProperty(attr="", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True)
use_uvs = BoolProperty(attr="", name="Export UVs", description="Exort the active UV layer", default= True)
use_colors = BoolProperty(attr="", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
2009-10-31 16:40:14 +00:00
ea265fc697 change blender python interface for classes not to ise __idname__ rather bl_idname since __somename__ is for pythons internal use.
replacements...
"__idname__" -> "bl_idname"
"__props__" -> "bl_props"
"__label__" -> "bl_label"
"__register__" -> "bl_register"
"__undo__" -> "bl_undo"
"__space_type__" -> "bl_space_type"
"__default_closed__" -> "bl_default_closed"
"__region_type__" -> "bl_region_type"
"__context__" -> "bl_context"
"__show_header__" -> "bl_show_header"
"__URL__" -> "_url"
2009-10-31 13:31:23 +00:00
85eb9d6a2f Commit of Patch [#19768] Add View3d Menu Items: View -> Playback Animation and View->Cameras->Active Camera
by Jeff Doyle (nfz). Thanks!
2009-10-31 10:17:19 +00:00
ea8c41bf54 Resizing didn't handle PET correctly for size attributes (position was ok, that's why it worked alright in edit mode). 2009-10-31 02:54:27 +00:00
9efc427f80 pep8 compliance for bpy_ops.py
add bpy.props to the modules so you can do...
 from bpy.props import *
2009-10-31 01:23:49 +00:00
a8e56a274e Commit of Patch [#19711] Add Menu Item: View3d -> View -> Show All Layers
by Jeff Doyle (nfz). Thanks! 

This adds:
* "Show All Layers" to the View3d -> View menu
* "Center Cursor and View All" and "Align
Active Camera to View" to the align view submenu.
2009-10-30 21:56:09 +00:00
9c1fc8497b small change to strip-swap, Made keys Alt+L/RArrowKey, added in menu, dont treat color strips like other effects 2009-10-30 21:40:07 +00:00
9aa380b67e Make Collada False by default everywhere 2009-10-30 20:47:13 +00:00
0cf1d391ed 2.5 Sequencer
Swap active sequence with the sequence on the right (CTRL+R) or left (CTRL+L).
was small Durian wish.

Note: in find_next_prev removed the code to find selected only if sel was != 0
I believe it should be possible to pass -1 in the case I want to find the next strip
regardless of selection state.
2009-10-30 20:40:41 +00:00
93173a6dd4 Mac / COCOA :
- fix 10.4 compile issues

- fix some scons issues & add WITH_BF_COLLADA = False in scons darwin_config.py to allow build waiting for complete Collada Mac implementation
2009-10-30 20:20:48 +00:00
f03257cc1f B.blend update
Received some additional feedback on the various screens

*Added Game Logic screen, with Logic editor, text editor, outliner and 3D view
*Added Properties screen, good for having direct access to loads of properties on a second monitor
*Tweaked UV Editing screen, removing timeline, and providing access to texture mapping and texture layers
*Tweaked Compositing screen, adding image editor and 3D view camera, and providing fast access to passes.
*Reordered some panels in the N-key area
*Added n-key properties area in the sequencer.
2009-10-30 20:02:56 +00:00
c47a768af7 2.5 Nodes:
* Wrapped Math, Vector Math and Texture Node.
2009-10-30 19:31:44 +00:00
ac8480f42a Revert changes committed by accident in 24168
(this was experimental code for "ladder-like" mouse adjustment of float values)
2009-10-30 17:50:45 +00:00
d5921a274f Proportional edit for object mode.
Limitations:

1) Parents and children of selected objects are excluded from the pool (siblings are ok) Making it work with that would required unparenting and reparenting after transform, that would turn nasty really quick.

2) Does not support Connected (this could be done through parent links, but see 3 first).

3) Parent relationships in affected objects aren't taken into account. When parent and children in the area of effect, remember that the children will also take the motion of the parents (with additive results). This could perhaps be fixed, but it could be nasty.


Other stuff:
New BASE_EDITABLE macro that checks if base is editable (like TESTBASELIB except it doesn't check for selection)
Add scene parameter to TESTBASELIB_BGMODE macro (using it from current scope is nasty)
2009-10-30 17:48:50 +00:00
89c7ad970c - setting the active object in rna works properly now (notifiers added)
- adding keyframes now works for bones and other data types (not just ID types)

# Add a pose bone keyframe
bpy.data.objects['Armature.001'].pose.pose_channels["Hip"].keyframe_insert("location")

# Add an object keyframe (worked before)
bpy.data.objects['Armature.001'].keyframe_insert("location")
2009-10-30 17:23:40 +00:00
31258507d0 Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).

SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.

The detailed command log of the merge (can be useful for educational purposes):

branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
84eb897caa updating mathutils wrapped attributes now runs rna update functions too 2009-10-30 13:58:43 +00:00
01f6dfaac9 own commit r24178 broke adding objects, need to look into why but this fixes for now 2009-10-30 13:26:29 +00:00
6f2ca7c2bf check for error that could happen when making editmode armatures 2009-10-30 13:08:58 +00:00
d3e1696d4f use context functions rather then macros 2009-10-30 12:35:17 +00:00
312c487201 - Simplified EulToGimbalAxis, its still only works on XYZ and ZXY but at least its more clear whats going on.
- Made RotOrderInfo use a vector rather then i/j/k
- Added gimbal_axis to transform.h (was extern)
2009-10-30 12:11:04 +00:00
77532f6f8a two things; made ctrl-p add an armature modifier instead of using PARSKEL, and also made wpaint auto-normalize work with PARSKEL armature setups 2009-10-30 09:50:35 +00:00
ae9eae222c Patch from Stani for autocomplete
adds ability to complete in these situations
 bpy -> bpy.
 bpy.data.objects -> bpy.data.objects["Mesh"]

my autocomplete could only do bpy -> bpy.
2009-10-30 09:34:57 +00:00
ae3cf92491 New Track To Constraint: "Damped"
This is effectively a C-port of Nathan Vegdahl's "No Twist" TrackTo PyConstraint, and has been added as a separate type of constraint to be consistent with the existing constraints (Locked Track, and Track To). 

In general, this works considerably better than the existing "Track To" constraint, since it works by determining the smallest rotation necessary to get the current orientation of the owner to an orientation which would be tracking the target. It is also a much more straightforward approach than the weird old method the old Track To uses.

I've made a few tweaks to the code to deal with the (hopefully rare) cases where the target and the constrained are coincident. These don't appear to cause too much trouble in general.

TODO:
- Probably the naming of the constraints will change, to better convey their purposes. Naming suggestions welcome.
2009-10-30 06:33:40 +00:00
fe68d2672d added an 'auto-normalize' option for weight paint mode, that automatically ensures vertex groups that affect bones all add up to 1.0. please test and give feedback. 2009-10-30 02:09:52 +00:00
c0a785a23e * Some Whitespace and small code-guideline cleanup. 2009-10-29 23:46:12 +00:00
c26ee3ab57 * Tiny Force Field Layout improvements and tooltip fix by nudelZ. Thanks! 2009-10-29 22:08:09 +00:00
51a9da2dcf BGE patch #19751: Add game actuator like methods to GameLogic. 2009-10-29 21:59:31 +00:00
1a8b9e63d9 When transform orientation is not orthogonal (which is often the case with Gimbal), orthogonalize the orientation separately when drawing each rotation circles (this makes sure they really appear perpendicular and not just be that way in the skewed space of the orientation). 2009-10-29 21:34:09 +00:00
0400f3cd5c Functions to test for and correct orientation matrix orthogonality (since MatXOrtho only normalizes and should probably be renamed) 2009-10-29 21:31:55 +00:00
c30553f7f3 * Added greying out for Bound Box Menu. 2009-10-29 21:31:00 +00:00
4b3fd4a8e0 replacement for my own autocomplete module by stani
--- from his patch
All the functionality is in the console
folder:
- intellisense.py: the central module which loads others on demand
- complete_namespace: more or less a replacement for the old autocomplete.py
- complete_import: module completion (I find this very handy, not just luxury)

These complete_* modules work very simple and should also work outside blender. You give some  input and it returns a list with possible completions.

autocomplete.py is now deprecated.
2009-10-29 20:55:45 +00:00
8c707b2a5f moved the following into the screen context rather then the view3d context so python scripts can access these when running in the console.
"visible_bones", "editable_bones", "selected_bones", "selected_editable_bones", "visible_pchans", "selected_pchans", "active_bone", "active_pchan",

added "C" to the consoles namespace, temp hack but useful
2009-10-29 19:59:38 +00:00
099438f087 Smoke:
* Bugfix for crash when deleting particle system used by Smoke Flow modifier (reported by nudelZ).
2009-10-29 19:26:13 +00:00
9a13a84f15 No need to force ortho on a unit matrix 2009-10-29 18:59:48 +00:00
98527a7106 various small fixes
- undo stops all running jobs (operator redo was crashing with threaded render)
- adding new armatures was crashing if there was no valid view3d
- transform with an active hidden object would crash
2009-10-29 18:49:36 +00:00
88b38c30a1 SVN maintenance. 2009-10-29 18:37:34 +00:00
b1a832a7e2 Mac / COCOA : Imbuf
- replace libtiff by calls to Cocoa services to load/save tiff files
(Libtiff, dynamically linked is not distributed with OS X, and would have had to be shipped for all four architectures)

The imb_cocoaLoadImage & imb_cocoaSaveImage are generic towards the bitmap format, and thus can handle TIFF, GIF, JPG, JP2000, BMP and raw camera formats (read-only for these), even if today only TIFF is used as the other formats are already handled.

- CMake updated
- scons updated (Thx to Jens Verwiebe)
2009-10-29 18:06:49 +00:00
f5d62d885b Fixed [#19735] No normal map button in texture->image pane
Put it into the "Image Sampling" Panel, not sure if its the right location.
2009-10-29 14:27:56 +00:00
6f1e9a843e Script templates, including game logic scripts from 2.4x and new operator template.
Files copied into scripts/templates will automatically appear in the menu.

the operator template is a bit rough but a start.
2009-10-29 11:26:44 +00:00
00d5fd9cb7 Sculpt: fix first partial redraw giving wrong bounds. 2009-10-29 11:12:59 +00:00
a365ccd20e Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24095:24152 2009-10-29 10:12:07 +00:00
e14a8635cc Modified python rna property types (BPy_PropertyRNA), so PySequence_Check() returns true
this means you can do...
C = {"selected_editable_objects":bpy.data.objects}
...when defining pythons context, without doing list(bpy.data.objects)
2009-10-29 10:03:34 +00:00
c508e6198a Python can now run operators with their own context (data context).
The aim of this is to avoid having to set the selection each time before running an operator from python.

At the moment this is set as a python dictionary with string keys and rna values... eg.

C = {}
C["active_object"] = bpy.data.objects['SomeOb']
bpy.ops.object.game_property_new(C)

# ofcourse this works too..
bpy.ops.object.game_property_new({"active_object":ob})

# or...
C = {"main":bpy.data, "scene":bpy.data.scenes[0], "active_object":bpy.data.objects['SomeOb'], "selected_editable_objects":list(bpy.data.objects)}
bpy.ops.object.location_apply(C)
2009-10-29 09:25:11 +00:00
40731af9d0 use objects rather then bases where possible, use context rather then OBACT macro 2009-10-29 09:14:20 +00:00
2aa2f53265 * Added missing "Passes" Button for AAO, reported by nudelZ.
* Some Layout tweaks for Cloth Panel, put Quality option to top. Patch by nudelZ.
2009-10-28 23:47:56 +00:00
3ff0032ec8 2.5 Nodes:
* Wraped Texture Nodes: Output and Bricks.
* Show Quality Slider (Composite > File Output) only for JPEG.
2009-10-28 22:14:31 +00:00
40cc202dac Comment out "forked" parameter for extrude_mode macro operator (it doesn't work yet and give warning in console) 2009-10-28 20:54:20 +00:00
3187e365d9 Gimbal Transform orientations
Will use rotation gimbal axis when an object or bone set to Euler rotation mode is selected (global axis otherwise)

Use case: being able to do rotations that only affect one animation curve in the 3d view instead of just in the curve editor.

I'm committing this right now despite what follows because it's already useful as is.

Known bug: manipulator arrows can look slightly skewed (not really a big problem), but more importantly, rotation circles for the rotation manipulator are skewed and will not perfectly reflect the rotation axis (it will still use the correct one though). That will be fixed shortly.

To do: This orientation should act like Local, where each object/bone uses its own orientation and not just the one of the active object/bone.

Note: Saved files with custom orientations might end up with other orientations selected when being opened up. I don't think it's that useful to make a do_version for that, but I can if warranted.
2009-10-28 20:30:33 +00:00
c2f9cfb40a 2.5 Sequencer
New Operator for 'Move current frame to next/previous edit point'
Keymap: PageUp/PageDown
(small Durian wish)
2009-10-28 19:53:25 +00:00
ce441678de Fix compilation for r24142. 2009-10-28 18:31:13 +00:00
b6459105b4 OpenGL Render restored.
I tried to make it integrate more with regular render but couldn't
do it well, it still needs a 3D view to take the settings from, and
can't run in a separate thread due to OpenGL.

However, it is now rendering to an offscreen buffer which then gets
displayed in the image window. This requires FBO's to be available, so
a fallback creating a new window is still needed. Currently available
from the Render menu in the top header.
2009-10-28 18:03:04 +00:00
044f7c5f33 New B.blend
-Continuous Grab is now on by default
-Opened scene panels by default
-Multiple new screens:
	*Default (same as before)	
	*Animation
	*Compositing
	*Quad View
	*Scripting
	*UV Editing
	*Video Editing

These have been inspired by other Open Movie artists, and their B.blends, including Nathan Vegdahl, Andy Goralczyk, and Bassam Kurdali. The new screens are designed to make optimal use of the new 2.5 UI, and expose newer areas like the compositor, new animation editors and console.
2009-10-28 16:32:14 +00:00
d6cde96286 Added support for custom RNA properties on Bones, only worked for
PoseChannel previously.
2009-10-28 15:33:45 +00:00
2138afc087 editing operator descriptions now works. 2009-10-28 11:55:58 +00:00
a7a77e3e94 Bugfix: particle editmode cut tool still wasn't working correct. 2009-10-28 11:35:19 +00:00
e024b46eb6 - 'id_data' attribute for py rna api, so you can get the Mesh from a face, Armature from a bone, etc.
- fixed crash when adjusting added objects settngs from the toolbar.
2009-10-28 11:31:24 +00:00
e694e30721 UI Icon Toggles Fix:
Boolean settings now use TOG instead of ICONTOG when they have icons, since ICONTOG was causing too much trouble with icons changing when they shouldn't be. Perhaps in future there should be some flag for specifying from RNA/UI-Layouts which one you want, but for now, this will do. 

Reverting r23936 since that fix depended on ICONTOG behaviour.
2009-10-28 10:16:49 +00:00
8510723cf4 patch from mindrones, uploads user edited docs to http://www.mindrones.com/blender/svn/
(rmb, edit docs)
2009-10-28 10:04:09 +00:00
64455004e0 ob.getChilren() often requested for 2.4x api, notice this is only 1 line of python. 2009-10-28 09:39:16 +00:00
29cae6de75 viewing docs for nested classes would fail, expects bpy.types.Scene.SceneGameData-class.html rather then bpy.types.SceneGameData-class.html 2009-10-28 09:03:08 +00:00
7ce5c951c5 Avoid an unecessary rebuild of the pbvh. 2009-10-28 07:15:01 +00:00
243c73e96e Moved the PBVH from sculpt session to DerivedMesh/CDDM.
* Multires sculpting appears to work now
* PBVH gets recalculated in some cases where it shouldn't, haven't looked into this yet
2009-10-28 06:06:05 +00:00
9aac7dd218 * Added 'report a bug' help menu item, taking you to the 2.5 bug tracker. 2009-10-27 23:28:56 +00:00
49d7a2c51a Fixes for AutoKeying + File Loading Prints:
* AutoKeying was broken after the fix to get automerge working again in 3D view. The 3D-View check was swallowing the processing before autokeying could be done. Separated these out again.

* The error print when some external data couldn't be found for objects was missing a newline.
2009-10-27 23:21:26 +00:00
be42f422da Bugfix: RNA_path_from_ID_to_struct crashed in automatic nested struct detection. 2009-10-27 21:58:03 +00:00
cb1b2649f1 2.5 Nodes:
*Wrapped File Output Node. 
Note: Crashs on execution while rendering.
2009-10-27 21:54:29 +00:00
93beb0b85a Commit of the sculpt patch (#19672). Further development will be in this branch until we merge to trunk. 2009-10-27 19:53:34 +00:00
e0fecb7fa3 CMake: attempt to make build not fail in case "svnversion" command is not found. 2009-10-27 19:32:22 +00:00
3266e10456 Proper cast to silence warning and comment to explain WTH is happening here. 2009-10-27 18:50:26 +00:00
9b7f3133e6 made minimum zoom level smaller (zoom out further) 2009-10-27 18:50:10 +00:00
6c4388e3b0 - fixed enum syntax in BKE_fcurve.h and ED_keyframing.h to make g++ happy
- exporting addEditBone from armature module for COLLADA importer
2009-10-27 16:13:50 +00:00
d160891c36 Shape Propagate to all back in vertex menu 2009-10-27 15:40:56 +00:00
4e7768066e patch from Stani to prevent hasattr(bpy.ops, '__call__') being True 2009-10-27 15:25:27 +00:00
560a0108b2 Bugfix: brush texture buttons were not showing map mode. 2009-10-27 15:19:44 +00:00
63e3cfb82f ifix syntax error in SConscript 2009-10-27 14:17:29 +00:00
Nathan Letwory
abf7bebac5 and another bump! Gotta love indentation °_° 2009-10-27 14:15:40 +00:00
Nathan Letwory
8a7a70f55c bumping commit count. 2009-10-27 14:14:40 +00:00
Nathan Letwory
a9610d45b6 r24111 broke the build on non-osx systems. 2009-10-27 14:11:28 +00:00
b66046339b 2.5 Nodes:
* Added missing button set functions for Matte Nodes.
* Wrapped some Matte Nodes to new Layout Engine.
2009-10-27 13:46:02 +00:00
b8a7f844ca Mac:
Fixed gcc-4.0 compile error (cocoa)

Updated scons to build cocoa (32bit & 64bit) (Thx Jens Verwiebe for the patch):
- make sure right python is unzipped to app-bundle ( printing information at the end of compiling )
- make sure arch-setting appends needed flags ( depending on OSX-version obsolete sometimes but harmless )
- link correct frameworks depending on gfx-api ( cocoa/carbon)
- conscript prepared for cocoa objC-files
- link to openAL-framework, using the headers from blender-lib + the symbols in framework

Usage instruction:
The default build is Cocoa 32bit.
To change it, copy config/darwin-config.py to user-config.py in the blender folder, and edit:
- WITH_GHOST_COCOA & MACOSX_ARCHITECTURE variables to select cocoa/carbon, and the arch (i386, X86_64, ppc, ..)
- the libs options as usual
2009-10-27 13:40:41 +00:00
54facb5cfe Added missing X mirror option to armature edit mode. 2009-10-27 12:46:20 +00:00
ba8ff9a339 Graph Editor: Added panel for numerically adjusting the cursor position 2009-10-27 11:46:46 +00:00
90957ed0dd A bunch of fixes for macro-type operators - Armatures + Objects
* Extrude and Duplicate for Armatures now use proper macros instead of manually calling transform themselves. This means that repeating these operators now works properly.
** NOTE: there's a bug with macros now which prevents the 'forked' extrude operator working correctly. Bug report filed for this.

* Included the proper operators for extrude and duplicate in the toolbar + menus. The operators used there did not activate transform, which meant that users often could not tell that the operation had occurred at all.
2009-10-27 11:10:30 +00:00
81c17a9fa3 Memory Statistics operator back, printing information about what memory
is being used for to the console. Not shortcut key, use the search menu.
2009-10-27 10:29:51 +00:00
e61facbf85 Bugfix #19729: Color Ramps are not animatable (Part 1)
This first part of the fix makes it possible to animate ramp settings by making sure that the paths for ramps and their elements can be determined. While the code for constructing the path to the ramps is relatively simple, the code for the elements is a bit more involved :/

However, this commit only fixes the paths, but most of the ramp settings still cannot be keyframed directly from the UI buttons/widgets (i.e. from Material/Texture buttons) since the buttons still use the old layouts.
2009-10-27 10:14:02 +00:00
e76ce369bb Compiler warning fixes for mingw:
* There's an unresolved error in transform_conversions.c which I've flagged in this commit. I'm not quite sure what the exact intentions of that code were (i.e. was the "void_pointer = 1" really intended)
2009-10-27 09:38:15 +00:00
1c1659eb28 - Right click menu can open links directly to API reference docs (rna and operators)
- Generated and uploaded api docs - http://www.blender.org/documentation/250PythonDoc
- Added Edit docs menu item & operators as discussed with Mindrones, Brecht, Stani & Letterip @ bconf, needs some web backend. python operator can aparently use xml/rpc to upload docstrings.
- Added operator invoke function - context.manager.invoke_props_popup(self.__operator__, event)
  this calls a popup for invoke by default (which intern calls execute())

- Own recent commit to game framing applied to non-camera views too.
- v3d->persp is deprecated but still used in some places.

- Transforming strips could overlap 1 frame if moving them below frame 0
- Transforming overlapping strips could go into an eternal loop (though overlapping strips should not exist)
2009-10-27 02:54:25 +00:00
641072a769 BGE: when letterbox is enabled use the camera framing as a clipping area (good for avoiding the HUD showing outside the bounds), use the framing color too (from dalai and myself) 2009-10-27 00:25:38 +00:00
491463c416 remove ARegion from the Canvas, use a RAS_Rect instead. (pair programming with Dalai ;) ) 2009-10-26 23:00:06 +00:00
839ac92f65 added SetDisplayArea, GetDisplayArea was used in a confusing way 2009-10-26 22:33:43 +00:00
5d333f72c3 Bugfix: material texture slot checkboxes were not showing up anymore. 2009-10-26 19:54:55 +00:00
6565193523 Revert multiplication order change from revision 23692
The previous order is correct, the new order forced all global scale on local axis (in object mode).

The "problem" with scaling (or mirroring) in object mode along an axis that is not aligned along one of the local axis is that the result has to be decomposed (as best it can by TransMat3ToSize) into scaling factors along local axis. The more axis aligned the object is, the more "correct" it will look, with the worse being a scale along two local axis when the scaling axis is right between them.

One "solution" could be to make all Mirror transform in object mode work on local axis only (but I don't think that would be correct, since it still works correctly on aligned axis).
2009-10-26 19:50:07 +00:00
4fcd358e53 Correct default file to be on frame 1, not 252 2009-10-26 19:19:55 +00:00
b2c2dafb68 Create branch for experimental 2.5 sculpting work. 2009-10-26 18:33:33 +00:00
2b1705afff Cocoa/Mac:
- fix bad window context initialization bug introduced in rev # 24081
2009-10-26 18:00:06 +00:00
c4067b62d1 Durian text editor requests:
-Added Run Script button in header
-Added hotkey for Line Select (Ctrl-Shift-A)
2009-10-26 16:48:23 +00:00
53ac50ea8b Bugfix: 3d view with scene layer lock were not updated when the
scene layer or other 3d view layers were changed.
2009-10-26 12:42:25 +00:00
7603479b6e Compile fix. 2009-10-26 12:30:28 +00:00
d46232a792 Fix bug #19715: remove doubles was not working. 2009-10-26 12:06:14 +00:00
3f7f2b869c Bugfix #19709: Influence and Mapping param in texture not yet animatable
Coded a 'path' getter for Texture Slots. This was a bit more involved than for other paths, since texture slots used the names of the textures assigned, which would be troublesome when a texture got used twice or more.
2009-10-26 11:56:12 +00:00
32dd928ed6 Bugfix: opening file browser or starting render with mouse outside
of window could crash, these functions relied too much on context.
2009-10-26 11:43:27 +00:00
536fe27ba3 Restored 'Make Parent Without Inverse' Operator (Ctrl Shift P)
I've made this a separate operator to Make Parent, since the two were signficantly different (this version only works for Objects, and doesn't care about other types of parenting).
2009-10-26 11:20:16 +00:00
b2f9672078 Animation Bugfixes - Noise Modifier + Graph Editor:
* #19727: Noise modifier does nothing with size 1.0
When the 'Size' and 'Phase' parameters were both 1.0 exactly, and evaltime was an integer (as is the case when doing animation evaluation but not for Graph Editor drawing), the noise calculation function was bailing out. Now, the 'z' component supplied to this function is a decimal value (hardcoded to 0.1 after experimentation) to try and avoid this situation.

* Graph Editor 'Bake' operator was using wrong poll callback, making it useless when trying to use it on a F-Curve that only has modifiers on it (i.e. the main use case of the operator!)
2009-10-26 11:10:04 +00:00
39d62a12d9 *Started to add theme editing in Preferences. Isn't visible in the UI yet.
*Moved some preferences around
*Changed the file browser '..' icon (Thanks Elubie!)
2009-10-26 11:03:12 +00:00
03d13ac9e8 64bit Mac:
- fix glew.h typedefs using long instead of int 
A visible impact of this issue was a wrong manipulators behavior in 64bit mac blender. (buffer passed to glSelectbuffer was of wrong data type)
2009-10-26 10:19:25 +00:00
47f80e026e crash fix for recent commit 2009-10-26 09:35:33 +00:00
21757e1161 Cocoa / Mac:
- use Cocoa function to convert keys character value to isoLatin-1 encoding instead of the translation table. Works better with international keyboards

- enable stereo GL option

- fix source/creator CMake file to remove unneeded folders in the app bundle (the __MACOSX stuff). (Thx jensverwiebe)
2009-10-26 08:43:24 +00:00
538697719a Bugreports #19724 and #19725 for Lasso Select
Fixes for these were provided by the submitter, Clark Tucker (ctucker_toc). Thanks!

- #19724: Fix for problems with lasso select with 'occlude background geometry' turned off. Removed a duplicate call to ED_view3d_init_mats_rv3d(). 
(NOTE: I couldn't reproduce the error on my system, but the duplicate call does look rather fishy. Removing it doesn't seem to have any negative effects at least)
- #19725: Lasso select does not update 'selected vertex count' in 'INFO bar'. Added a notifier here to get the counter refreshed.
2009-10-26 03:35:37 +00:00
3af9333251 Fix for crash when doing File -> Open, File -> New (without closing the FileBrowser first) 2009-10-25 05:33:35 +00:00
c90e05bb42 Toolbar Fixes:
* Restored the Grease Pencil tools to the toolbar
Probably, if the reason they were commented out before was so that the repeat stuff is visible, we can swap the order of those two. Otherwise, it's good to have somewhere for the operators now (so that the hotkeys can be found)

* Hotkey displays in the tooltips now show the keymodifier too
For example, "D LeftMouse" or "Ctrl D LeftMouse" for the Grease Pencil operators, instead of just "LeftMouse" or "Ctrl LeftMouse".
2009-10-25 03:47:14 +00:00
4815e07b6f Fix minor typos. 2009-10-25 00:24:56 +00:00
4aa7ddfe33 description patch from Ron Walker 2009-10-24 23:26:28 +00:00
bf5f63f09b bugfix [#19719] segfault assigning a different mesh to object in edit mode 2009-10-24 22:41:40 +00:00
Ken Hughes
f34cdb4e0b Removing unnecessary semicolon, causing compile problems with MSVC. 2009-10-24 14:22:46 +00:00
dd8ea0c61a Bugfix to restore shape key add creating a new shape based on the
shape visible in the 3d view, rather than a copy of the basis shape.
2009-10-24 11:25:05 +00:00
66d47d2f27 New b.blend.
-Made it work with new tool area, resizing correctly
-Put properties tabs on the top
2009-10-24 07:50:39 +00:00
74ed5fd306 More human readable formating in enums and others.
This makes some code inspection tools give cleaner results.
2009-10-23 23:19:23 +00:00
068ab484ac Cocoa / Mac:
- tablet : fix pressure retrieval => value sliding now works with tablet, UV-painting is pressure sensitive, and no more crash when clicking on window minimize button with the tablet

- update CMake file to remove unneeded folders in the app bundle (the __MACOSX stuff). From Jens' patch
2009-10-23 12:12:44 +00:00
Ken Hughes
5133f75779 Python API
----------
Incorrect row and column values were passed to newMatrixObject() by
Matrix_new() when the argument to Matrix() was a matrix.
2009-10-23 00:44:18 +00:00
caa27f09fd Bugfixes:
* The python 'math' library is now included in the py-namespace used to evaluate button expressions. So it is now possible to do 'radians(somevalue)' to get a rotation value that Blender can understand...

* Shapekey path getting function now uses the appropriate wrapper for grabbing the pointer to the ID block for the ShapeKey

* Made the Graph Editor's minimum zoom size finer...
2009-10-22 23:23:09 +00:00
e8af794441 face mask mode
- border select
- linked selection (Ctrl+L)
- select all
2009-10-22 19:17:46 +00:00
e2b74dc736 Shape Keys
Active shape key can now be changed while in edit mode. This is based
on exit/enter editmode again in the background, which is not ideal,
as that loses the undo history. But that already happened anyway when
you did exit/change-active/enter manually.
2009-10-22 17:12:28 +00:00
3ffb695b10 Shape Keys
Blended shape keys can now be displayed & edited in edit mode. This
is much like showing an armature modifier in edit mode, and shape keys
now are a applied as a virtual modifier (for mesh & lattice only, curve
doesn't fit in the stack well due to tilt).

The main thing missing still is being able to switch between the active
shape key in edit mode, that's more complicated.. but the weights of
other shapes can be edited while in edit mode.

One thing to be careful about is that this does automatic crazyspace
correction, which means that if you edit a shape key with a low value,
the actual vertices will be moved to correct for that and actually move
a (potentially much) longer distance.

Also includes some UI tweaks, mainly placing some buttons horizontally
since the vertical list was getting too long.
2009-10-22 16:35:51 +00:00
b06640c583 changed WM_OT_context_* operators to pass through if one of the members in the path is None, rather then raising an error.
This means if you refer to a member of an object it will fail silently if there is no active object, but if you use an invalid attribute of the object it raises an error.
The method to check this is not nice but works well enough.

also removed pageup/down keys for changing the active shape since listviews can do this now.
2009-10-22 16:21:06 +00:00
fe823ce3ce Fix for Texture Tab. Influence Panel got shown even when no active slot was selected, raised errors. 2009-10-22 15:33:53 +00:00
d037061b68 after transform if strips overlap, move the frame rather then the channel to fix.
useful while snap isnt working. metastrips still need to be supported.
2009-10-22 14:40:32 +00:00
a407a21bfb added back face mask mouse selection and made shift+k fill weight paint and vertex color 2009-10-22 12:59:14 +00:00
76879599f5 Shape Key UI
* Curves/Surfaces now have the shape key panel as well, this
  is new compared to 2.4x.
* The previous commit also fixed curve tilt blending for relative
  keys, this was writing to the wrong memory location.
* Minor button tweaks
2009-10-22 09:48:44 +00:00
06d57fdae0 Shape Keys
Internal change to not apply the shape keys to the Mesh vertex coordinates,
but rather use it as part of the derivedmesh/displist evaluation. This only
has one practical advantage right now, which is that you can now make a
linked duplicate and pin it's shape key to a different shape than the first
object.

Further, this makes shape keys correctly fit into the modifier stack design,
which will help implement some other features later. Also it means the mesh
vertex coordinates are now really the orco's.
2009-10-22 09:31:07 +00:00
ddf965b63a Graph Editor: Jump to Keyframes Operator now also sets the cursor value 2009-10-22 09:15:56 +00:00
5777c624a5 Animation Editors: Menu Tweaks
* Submenus displaying the options available for certain operators now will now show the hotkey for the operator on the menu entries. 

* Added an option for mirroring keyframes in the Graph Editor which makes use of the new cursor
2009-10-22 09:07:19 +00:00
c9092a6738 Patch [#19708] Add Menu Item: View3d -> View -> View Global/Local
by Jeff Doyle (nfz).
2009-10-22 06:09:43 +00:00
359a3d1811 Two fixes:
* RNA Path fixing when renaming data now checks if a path in question cannot be resolved before trying to fix it. This should reduce the number of misindentified cases I hope.

* Silenced compiler warnings for EdgeSlide stuff that mingw was making about unused variables.
2009-10-22 03:12:44 +00:00
c825a9aeaa Bugfix #19703: Axis Angle wont work
* Transform code was not properly fixed to work with the new way that axis-angle data was stored
* The order of the args for the conversion function when switching rotation representations was wrong, causing problems when switching from quaternion to axis angle (i.e. these occurred for newly created bones).
2009-10-22 02:14:11 +00:00
64d4ae639b Bugfix #19707: Save Over (Ctrl+W/ Ctrl+S) anoyiance
Using standard 'save' now pops up a filebrowser when the file hasn't been saved before instead of just assuming that the file should be called "untitled.blend" and dumped in the last used directory.
2009-10-21 23:05:54 +00:00
180d74ab57 UI: List Template tweaks to get it a bit more usable
* Mouse wheel now scrolls the list.
* Up/down key and alt mouse wheel change the active item.
* Adding/removing items from the list now automatically scrolls so the
  active item is in the view.
* Shift mouse wheel changes the size of the list widget to display more
  items. Lazy replacement for a proper grip.

* Shape key list now displays the influence value next to the name,
* Also fix the range of the value slider to match the defined min/max
  range.
2009-10-21 20:58:10 +00:00
5fb73d8b81 Make compiler happy, remove doubtful non init usage. 2009-10-21 17:56:26 +00:00
eab11543f3 Cocoa / Mac:
- fix set mouse cursor position in case of multi-display setting. Enables continuous grab to work when blender window is on a secondary display
2009-10-21 15:39:32 +00:00
77ccb5aec1 shape key operators and buttons for reordering 2009-10-21 14:33:52 +00:00
2344d62dfb Silencing some compiler warnings for mingw
* Unused functions
* Uninitialised vars
2009-10-21 10:56:31 +00:00
7685def9af Graph Editor: Pivot Modes for Transform
It is now possible to choose from 'Bounding Box' (default), '2D-Cursor', and 'Individual Centers' as the pivot point(s) that rotation/scaling is performed around.
2009-10-21 10:36:46 +00:00
3a6da12ab1 added new context operator WM_OT_context_cycle_int, use for switching between active shape keys 2009-10-21 10:11:03 +00:00
1f33a90f05 Bugfix to allow list templates to have more than 5 rows when you set
it in the python script, didn't work correct with scrolling.
2009-10-21 09:17:46 +00:00
f4d6bbd656 - improvements from Mathias Panzenböck (panzi) patch [#19695], which avoid conversion to/from strings with context property assignment. though didnt apply entire patch.
- [#19698] Add Menu Item: View3d -> Object -> Move to layer
  from Howard Brooks (hbroo)
- had cursor grab commented by mistake for X11
2009-10-21 07:56:08 +00:00
ddb1f64fff Outliner: Tweaks for Driver Operators
* Driver adding/removing operators in the Outliner now work properly for arrays
* Renamed these operators so that their names are more indicative of how they work (i.e. based on the data in the Outliner that is selected)
* Added a menu labelled 'Edit' in the Datablocks view which gives access to (and includes the hotkeys for) these tools.
2009-10-21 05:59:51 +00:00
908061378c * fix for colour management, compositor image node wasn't working correctly. There are a few other issues around here I need to get to eventually as well.. 2009-10-21 00:33:08 +00:00
daa1e5449d Graph Editor: Small optimisations for drawing
Moving out a few gl state changes to higher-level calls to improve performance when drawing handles. This already improves the responsiveness a lot on a few files, though a few other tweaks will also help.
2009-10-20 23:51:31 +00:00
c0d74fa192 Bugfix #19696: Crash when adding an Empty or Force field 2009-10-20 23:18:00 +00:00
ca87f28f5b Text Editor: Scrollbar now drawn on the right 2009-10-20 22:51:20 +00:00
1224835188 Size and position are normally requested by program, not user. 2009-10-20 21:58:19 +00:00
4044f057ca Bugfix: rendering with multiple windows open did not use image editors
with render results in other windows.
2009-10-20 21:13:42 +00:00
29b0afde6e [#19445] New Object is not Grabbed after using Duplicate Linked 2009-10-20 21:12:09 +00:00
cac0e48dfb Region post redraw is now split up in a view space and pixel space
part. This fixes a bug where transform help line drawing would not
work with view clipping and mess up the z-buffer. This avoids the
transform code having to figure out what kind of opengl state is
enabled and disable it temporarily.
2009-10-20 21:05:22 +00:00
487a5045c9 [#19688] pressing O and alt+O doesn't toggle proportional edit mode when editing a lattice.
- proportional edit keybindings for particle and lattice
2009-10-20 20:59:02 +00:00
a864b7037b Bugfix for node editor refreshing too often when moving nodes,
split up notifier in redraw/refresh.
2009-10-20 20:00:12 +00:00
f8d3f0582d Bugfix for paint cursor not showing up in paint/sculpt modes
after saving the file in that mode and reloading.
2009-10-20 19:52:31 +00:00
f22872dded Bugfix for use of freed memory in jobs manager. 2009-10-20 19:46:36 +00:00
d27649e9f0 Bugfix: adding a curve path did not mark it as being a path/3d
correctly, causing e.g. curve guides not to work with it.
2009-10-20 19:37:49 +00:00
23f69cbe92 move G_FACESELECT from G.f to mesh->editflag, renamed to ME_EDIT_PAINT_MASK 2009-10-20 19:27:27 +00:00
5240d39e48 Smoke:
* Revert "speedup" through not using GL_POLYGON - wasn't helping at all, only confusing the source
2009-10-20 19:22:19 +00:00
9327dd9112 Bugfix: render clipping was not using correct matrix, own mistake
in recent commit.
2009-10-20 19:14:55 +00:00
ad260a0370 basename() function, at least know it should compile.
Feel free to replace with the proper WIN32 code.
2009-10-20 19:09:12 +00:00
d8ee1e2737 Bugfix for a crash with the cut tool in particle mode. 2009-10-20 18:49:21 +00:00
022be64517 Bugfix: raytracer building could crash (abort due to an assert), when
using for example a text object scaled down to size zero. This was due
to nan's generated through division by zero.
2009-10-20 18:27:46 +00:00
49a937c521 fix for mirror select and added to the menu 2009-10-20 17:10:01 +00:00
25e9be0002 Smoke:
* "Fixing" slowdown (no idea where it comes from) by lowering the number of drawn slices again
2009-10-20 17:08:07 +00:00
5e5a38cdc3 Bugfixes for quit.blend + library linking, the last commit didn't solve
that completely:

* quit.blend is saved from the undo file, which did not save out library
  ID_LI and ID_ID blocks, for quick undo keeping the library datablocks.
  However this means library links are lost on reading the quit.blend, so
  now instead of not writing them, they are not read on undo.
* Libraries were not not using the right path yet always.

Note the screen setup is still not recovered from the quit.blend if no
auto save happened yet, but that is not important enough to spend time on
now.
2009-10-20 16:43:25 +00:00
9a00cc55c1 - editmesh select mirror (in editmode select menu)
- weight blending (Vertex specials menu), currently blends from surrounding unselected verts (nice for blending edge loops), but will eventually support face mask mode.
2009-10-20 16:31:03 +00:00
5d0f5d210a Fix in KDL for gcc 3.3 compilation
Thanks to Benoit Bolsee and Alexander Clausen for help!
2009-10-20 16:02:41 +00:00
b2d771a438 Smoke:
* Use GL_QUADS and GL_TRIANGLES instead of GL_POLYGON for faster drawing
* Use variable count of slices
2009-10-20 15:51:25 +00:00
0e5a6a21e8 Fixes to get Blender compile and run on PowerPC OSX 10.3, gcc 3.3
(yes antique, but having 5 year old OS's work is very cool)

In short:
- include <cmath> after <math.h> fails
- STL template issues (recursion, syntax)
2009-10-20 15:51:18 +00:00
5571d37e94 Cocoa:
- fix windowDidResize event not forwarded in some cases on 10.6
- fix crash on repeated Cmd-Q + Cancel quit actions
- place stub for .blend drop on blender app icon
2009-10-20 15:23:04 +00:00
4197253b26 split weight normalize into 2 operators, normalize and normalize_all.
Added an option for normalize_all that keeps the active group at its existing weight while normaling all other groups around it.
Thsi makes it easy to paint up to 100% where all other groups will use progressivly less until the active group is 100% and all others are 0.

Added weight operators to the toolbar
2009-10-20 13:59:26 +00:00
cb8f7fd385 Auto Save
Auto save is now working again in 2.5. It will also remember now what
the location of the original file was when recovering it, so that
library links still work and saving the restored file does not save to
the temp directory. There is also a new Recover Auto Save operator
which will open the filebrowser in the temp directory and show the
auto saved .blends.

Implemenation Notes:

* Timer storage was moved from window to windowmanager, so we can have
  windowmanager level timers too now, doesn't make sense to have
  autosave timer attached to a particular window.
* FileGlobal now has a filename field storing where the file was saved.
  Note that this is only used when loading a file through the recover
  operators, regular file read doesn't use it, so copying the quit.blend
  manually over the original file will still work as expected.
* Jobs timer no longer uses operator now, this seems more like an
  internal thing, changing keymaps should not make it possible to break
  the jobs manager.
* Autosave is postponed by 10 seconds when a modal operator is running,
  e.g. transform or file browsing.
* Moved setting G.sce in setup_app_data before depsgraph updates, these
  can use the filename for pointcaches.
2009-10-20 13:58:53 +00:00
b8eec2b8fe Added a button in the header to toggle full screen mode. It'd be nice to have this right-aligned, but this doesn't seem possible in the layout engine currently. 2009-10-20 13:56:53 +00:00
5e2ddea1f3 Smoke:
* Fix 3dview drawing issue which caused smoke to disappear in some cases, reported by nudelZ
2009-10-20 13:46:47 +00:00
00f3d83b6a Graph Editor: Added 2D Cursor
I've finally given in, and implemented a '2d-cursor' for the Graph Editor. This is simply represented as an additional horizontal line that meets with the current frame indicator, forming a cross-hair. It can be disabled from the View menu.

Currently, the only tool which takes this into account is the Snapping tools (Shift-S), where I've hooked up a tool I added some time ago. 

TODO:
- expose this cursor to the transform tools for scaling/rotation options...
2009-10-20 12:04:56 +00:00
ec6bccfad1 Renamed the modifier category 'Physics' to 'Simulate'. Seems to better encompass those modifiers. 2009-10-20 11:26:21 +00:00
c01c716346 *Made the Add Constraint menu similar to modifiers, with categories in columns. Makes them consistent, and also ensures the menu fits even on smaller displays.
*Put the Modifiers tab *before* the ObData (mesh, curve etc) tab, because modifiers actually apply to Object , not the ObData, even though the opposite would appear to make more sense.
2009-10-20 10:41:44 +00:00
9f841f5b35 weight paint operators - normalize/clean/invert 2009-10-20 10:19:48 +00:00
cf29a23723 Use Eigen2 2.0 head version rather then 2.0.6. It contains various bug fix. 2009-10-20 09:50:24 +00:00
2c45509805 Renamed "Save Key Configuration" to "Export Key Configuration", so it
is clear this is different from "Save As Default".
2009-10-20 08:47:28 +00:00
1f9d8826db Cocoa:
- fix 10.6 API used in window resizing callback causing crash on 10.5 systems (Thx Jasper Mine for the bug report)
- implemented min window size enforcement to prevent tiny windows messing up blender's internal ui layout (same as done by Campbell on X11, is a partial fix of bug #19550)
- added (commented) code for enabling multithreaded opengl (this optimization is here for experimental tests, not for mainstream, so bleeding edge testers would want to uncomment the three "Multithreaded opengl code : uncomment for enabling" sections)
2009-10-20 08:13:12 +00:00
8a8e00af07 Attempted fix for mingw buildinfo.c compile problem. 2009-10-20 08:01:17 +00:00
cae71123e5 set the min size hints for x11 to prevent tiny windows messing up blenders internal ui layout 2009-10-20 07:51:42 +00:00
8bc1087e2e Fixes for Path-Renaming Fix:
* Now the old/new names get tagged with [" "] before the search and replace operation, which should alleviate problems with searching for 'bone' and ending up with all instances of 'boney' 'boney.r' etc. also getting renamed.

* Cleaned up some compiler warnings, and removed an unused function from an earlier attempt at this work.
2009-10-20 04:07:57 +00:00
7f133f65b2 Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily. 

The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
2009-10-20 03:44:35 +00:00
9e6d1c6cfa Rearrange includes, and more fill_paths code. 2009-10-20 02:20:00 +00:00
b8141658a8 etch-a-ton RNA and UI, back in 2.5 2009-10-20 00:45:51 +00:00
fcc27ca8aa separate image strip length popup 2009-10-19 21:34:38 +00:00
059d4f181c file browser
* the code for BLI_is_dir can be shared on Windows, no need of extra implementation - error was usage of BLI_exists instead of BLI_exist! 
* left BLI_is_dir in since it's nicer to read and understand
* also removed deprecated outliner_header from MSVC projectfiles.
2009-10-19 19:26:28 +00:00
0ce2950649 fix for crashing when unlinking a world from a scene 2009-10-19 19:17:05 +00:00
631fbf88e8 Consolidate tube and cylinder primitives.
Removing old add tube operator and replacing it with add cylinder. The resulting operator is called add tube, since that's the name in the menu. Other people can debate about the name and change it later if they feel like it.
2009-10-19 19:16:15 +00:00
45a21e4736 Some cleanup for particle edit snap.
Update comment to point at the root of the problem.
2009-10-19 18:49:04 +00:00
680e724e37 Continue development of bfile system.
Still not usable, but some parts could be made more portable already.
Help welcome for MacOSX and MSWindows calls and paths.
2009-10-19 18:44:09 +00:00
1f4d07fd19 run flushTransParticles after snapping applyProject so you can project/snap particles in editmode 2009-10-19 17:50:26 +00:00
401c185fbc Get 2.5 trunk to compile. this C++ code failed for gcc 3.3.
Error log:

/usr/include/gcc/darwin/3.3/c++/cmath: In function `float std::ceil(float)':
/usr/include/gcc/darwin/3.3/c++/cmath:175: error: parse error before `(' token
/usr/include/gcc/darwin/3.3/c++/cmath: In function `float std::floor(float)':
/usr/include/gcc/darwin/3.3/c++/cmath:249: error: parse error before `(' token
/usr/include/gcc/darwin/3.3/c++/cmath: In function `float std::fmod(float, 
   float)':
/usr/include/gcc/darwin/3.3/c++/cmath:267: error: parse error before `(' token
2009-10-19 17:47:24 +00:00
031da438e4 - enable snap to work for particle editmode so you can snap onto the emitter.
theeth: maybe there needs to be a new SnapMode for this? - SNAP_SELF?, like editmode but without setting t->editob

- dont run special_aftertrans_update on scene objects when after sequencer transform
2009-10-19 17:20:09 +00:00
5821e0ddf7 Patch #19667: cmake/windows build info now has time & date,
patch by Guillaume, thanks!
2009-10-19 17:18:31 +00:00
48f3e3340a Fix #19618: invalid vertex group data could be created when
assign vertices without an existing vertex group, causing e.g.
armature modifiers to crash.
2009-10-19 17:11:42 +00:00
7cc9998eb4 Added old 2.4x keymap entries for Open, Save As, and Save Image, per request from Ton. 2009-10-19 17:10:16 +00:00
cb44f29043 Fix #19574: winbuildinfo.h error when compiling with cmake on windows. I've now removed winbuildinfo.h code and let scons on window just set environment vars like other operating systems. Note that cmake still doesn't get the date information on windows, implementation is missing for this. 2009-10-19 16:55:51 +00:00
85a8f315b4 Bugfix: scons builds didn't print build info when running blender -v. 2009-10-19 16:29:26 +00:00
16c1a2944c Fix/workaround #19617: new raytracer use of SSE is crashing Mingw builds,
so disable SSE in that case now.
2009-10-19 15:58:09 +00:00
653815923f Fix #19523: spot lamp blend display size was tweaked so it was always
showing, but that also is confusing because it then shows the wrong
size, so just hide it now when blend size is 0 or 1.
2009-10-19 15:53:57 +00:00
655d34f9cd weightpaint bug where hidden faces would not draw into the backbuffer, now check face mask mode first which is where hidden faces also dont draw. 2009-10-19 15:01:07 +00:00
7af69ffa24 Scons/make update for use of GPU include in interface module. 2009-10-19 14:54:42 +00:00
fc1dcc4748 Fix #19645: debug properties not showing while game is running. 2009-10-19 14:48:35 +00:00
8d7c69ffa9 CMake files update to allow use of MAC OSX 10.5 libs (and build 64bit blender on mac)
The WITH_LIBS10.5 option switches the use of the libs included in the darwin-9.x.universal folder

Use the CMAKE_OSX_ARCHITECTURES variable to set the architecture you want to build for (e.g. i386, x86_64). Only one at a time, this value is used to select the python_?.zip that is bundled with the app.

WITH_COCOA (build Cocoa ghost and not Carbon) is now on by default.
2009-10-19 14:38:19 +00:00
54abd775d3 Fix #19604: defocus node was not using camera object yet. Could use
a proper fix, but for now this makes things work again.
2009-10-19 14:32:32 +00:00
652ea9ee30 Fix #19627: previews in materials nodes were not cleared before re-render. 2009-10-19 14:10:37 +00:00
dd96bf6168 - added xmirror to the weightpaint options
- made texture_slot return the texture slot for the node texture
2009-10-19 14:03:02 +00:00
51f11abe45 Fix #19605: material hardness was wrapped as float while it is an int,
which made number buttons not increase the value on clicking the arrows.
2009-10-19 13:41:02 +00:00
c3f18a2d73 Moved some tool settings (mirror, auto-IK) to the tools pane. 2009-10-19 13:24:18 +00:00
596d25773a Another fix for duplicating objects with particles. 2009-10-19 13:21:37 +00:00
2d0f3274bd Fix #19588: duplicating objects with particle systems would crash.
Also an unrelated warning fix.
2009-10-19 13:17:47 +00:00
60c50dda70 Fix #19678: full sample / save buffers was crashing due to two issues:
* Nested write lock on render results.
* RayHits pass was always enabled, commented it out now.
2009-10-19 13:09:24 +00:00
4c6b66132e use the meshes mirror flag for weight painting 2009-10-19 13:09:13 +00:00
520e805dad Make the sequencer Ctrl+RMB select all strips on the mouse side of the playhead (just like the dope sheet).
Changes how selecting linked left/right work since this conflicts. rather then Ctrl for left and Alt for right, Just use Alt and select the side based on the handle selected.
2009-10-19 12:27:40 +00:00
666b480830 Fix #19646: changing collision bounds type in game physics was
missing viewport redraw.
2009-10-19 12:19:19 +00:00
a84a59b64e Fix #19638: crash when assiging self in boolean modifier.
Also:
* UI now takes ID self check flag into account so that e.g. it
  doesn't offer to the make object it's own parent.
* Mesh loop cuts number of cuts had wrong limits.
* Don't use mesh_get_derived_final in modifier stack, but
  ob->derivedFinal instead. Avoids crashes on dependency loops,
  and in case there is no loop it should have been created.
2009-10-19 12:13:32 +00:00
952322e71c Fix #19632: GLSL was not updated for soft/linear light blending modes. 2009-10-19 11:50:01 +00:00
23101be4d6 Fix use of uninitialized variable in node editor. 2009-10-19 11:49:23 +00:00
a216ce6cf8 - fixed python error when there is no active object
- made sequence strip selection more like object mode - only de-select the active with Shift+RMB
2009-10-19 11:39:57 +00:00
915c40708e Fix #19640: user defined keymaps did not use poll function. 2009-10-19 11:11:35 +00:00
243e024a63 Fix #19683: rendering with compo nodes but no render layer node crashed. 2009-10-19 11:04:56 +00:00
05d33dc6af Fix #19633: material & texture didn't use autocomplete for
selecting uv layers yet.
2009-10-19 11:00:43 +00:00
c19e7197aa Fix #19622: crash in glsl, forgot to commit this file when
I changed the GLSL code for texture influences update.
2009-10-19 10:49:46 +00:00
b18eeed225 Cocoa :
- fix#19592 : implemented updated continuous grab feature (fixing compilation issues)
- fix some 10.6 & 64bit warnings
2009-10-19 10:49:45 +00:00
55249e255a fix for bug where moving strips that are next to eachother would detect invalid overlaps
first update strips, then check overlap in a second loop
2009-10-19 10:37:50 +00:00
e2fa58f7f3 Fix #19669 and other: triple buffer & icon texture drawing could cause
a system crash and other issues on ATI/Apple, due to a buggy driver
(similar issues reported for other OpenGL applications). For now, work
around it by not using non-power-of-two textures on this combination.
2009-10-19 10:10:05 +00:00
2c985dee97 - listener for sequencer space panels added for frame changes, now redraws during transform
- invalid pointer was used for getting the sequencer length crashing blender or setting the length to negative values.
- printf_strip(seq) for debugging sequence strip locations
- Spelling: Cheet Sheet -> Cheat Sheet
2009-10-19 10:07:19 +00:00
8802bea7a0 Fix for a preview render crash that happened sometimes, when
the thread was marked as ready while it had not started yet.
2009-10-19 09:57:55 +00:00
256348eb6b Fix #19657: crash when cancelling volume material render, raytree
is invalid if it cancels during build, so don't use it then.

Also fixes some use of unitialized variables in raytracing code.
2009-10-19 09:54:25 +00:00
73d0c673e8 Fixed Layout-Engine bug that was causing checkbox menu entries to draw with the wrong icon when enabled. 2009-10-19 09:50:02 +00:00
0445ff1ae9 Give sequencer its own transform freeing function.
Updating the sequencer after transform could not use special_aftertrans_update because it relies on data that is freed

theeth: moved the customFree function to run before freeing t->data, t->data2d in postTrans(), checked that customData is not needed.
2009-10-19 08:01:30 +00:00
1a7ec53dc4 Assorted 3D-View Tweaks:
* Paste Flipped Pose in PoseMode should now work. The parameters weren't getting set before

* Added a notifier that gets sent when changing layers with scene lock on. For some reason, this doesn't seem to be sending the correct updates though.

* Made the tools region no longer overlap the 3D-View. The default .b.blend file still needs to be updated so that this gets reflected.
2009-10-19 04:56:19 +00:00
ed032e13f2 Patch #19034: (2.5) Display titles of closed panels in horizontal mode
This patch was one of the patches submitted by Wolfgang W. (bender) (the others have already been committed). In the patch, there was commented out code for counter-clockwise rotation of the text, but I've removed that.

--

In this commit, I've also removed all of the panel tabbing code instead of merely commenting it out.
2009-10-19 03:54:30 +00:00
3c26d886b5 Graph Editor: Visibility toggles improved (Durian Request)
Toggling one of the visibility toggles in the Graph Editor now flushes the new value up/down the hierarchy. 
- when enabling a visibility toggle, all the 'higher' up and lower down channels get their visibility turned on
- when disabling a visibility toggle, only the ones lower down get their visibility turned off (since there might still be other channels at the same level which are still enabled.

This makes showing/hiding groups of F-Curves much easier, since previously you'd have to use multiple clicks to isolate particular F-Curves. For example, to isolate only X Location curves, previously, the workflow would have been to select all AKEY, hide all VKEY, then toggle the individual X Location curves in group, then make sure the groups and objects, etc. were also visible. Now, the steps of making sure that the parents were visible too has been eliminated.


---

Also, fixed a few minor bugs with the animation-backend code for Graph Editor.
2009-10-19 02:17:57 +00:00
e029e05646 [#19680] Add cap ends option for new cylinders in 2.5
Patch by Howard Brooks
2009-10-18 23:23:41 +00:00
5d97c9f595 select all seq strips removed other flags, add menu was running exec rather then invoke. 2009-10-18 21:32:03 +00:00
816856f953 Small particles feature: Multiple group visualization counts per group object are now possible (+/- buttons next to the count list). This allows for example an array of duplicated objects "ob1, ob2, ob1, ob3" without duplicating the actual object (ob1 in the example) in the group. 2009-10-18 21:12:04 +00:00
f750cc7dbd Changing particle physics type to boids and not boids multiple times crashed. 2009-10-18 20:52:15 +00:00
442d767d16 Fix for [#19610] Hair cut tool, keeps cutting hidden hairs. 2009-10-18 19:48:33 +00:00
5506d12bba 2.5/Sculpt:
Fixed "Persistent" option for layer brush, someone changed the RNA name but missed the UI script
2009-10-18 18:48:48 +00:00
Ken Hughes
1f0f2cc629 Bugfix: memory was leaking when opening a new file (Ctl-N). Reports were not being freed.
Brecht (or someone), can you check this?
2009-10-18 18:05:34 +00:00
a0c567d1b1 fix Win64 compile: Should now work with cmake again, does this break win64 scons anyone? 2009-10-18 17:41:42 +00:00
505f5c58ce Bug fixes:
[#19596] Child particle in particle mode show for one redraw, then disappear
[#19598] Draw actual particles options draws in wrong location
2009-10-18 16:55:33 +00:00
9b26e7d7ca minor changes to x11 cursor grab wrapping
- when wrapping 2 mouse events were added.
- on release blender still had the last event (possibly outside the screen), where menus would fail to show. Add a mouse event by calling XWarpPointer with no movement when leaving grab.
2009-10-18 09:55:39 +00:00
55e6aa77c4 Removing MESH_OT_vertices_transform_to_sphere.
This operator was a port of the old ToSphere button that worked only around the cursor.

To Sphere transform (Alt-Shift-S) can already do it around cursor if pivot is set to that, can be used interactively and work on more data types, so this is unneeded.
2009-10-18 02:55:30 +00:00
adba1c302d Reverting revision 23913.
Actions on press is used everywhere in Blender, lets not make an exception here because there's something missing in the event system.

Bug report and potential solution is here, if anyone wants to have a go at it: http://projects.blender.org/tracker/index.php?func=detail&aid=19510
2009-10-18 02:45:05 +00:00
babf9b2d88 Another attempt to fix the problems with confirming transforms while snapping (LMB confirm, CTRL-key still held for snapping) and "ctrl-click" extrusion.
Made the confirm keymap for transforms use KM_RELEASE instead of KM_ANY (I didn't see any case where this failed yet?), and restored the "ctrl-click" as it was before r23903
2009-10-18 02:15:55 +00:00
eff008385b Bugfix #19673: Blender crashes when I open "operator cheat sheet"
Missing check before using 'obedit' pointer for shape_itemf() (i.e. shapekey enum generator)
2009-10-18 02:06:06 +00:00
2d7587bf0c Smoke:
*Should fix crash with collision objects
2009-10-17 22:34:40 +00:00
13a70d22f9 Added torus icon to the add menu, and made naming consistent with the other add menus. 2009-10-17 21:08:22 +00:00
69c6a33ba1 wrap the mouse within the region while grabbing so on release the current view never changes and less likelyhood of loosing the cursor when running blender on 2+ screens. (assuming the 3d view isnt stretched over both) 2009-10-17 19:32:28 +00:00
484bf962c6 simple fix for blend from shape when no keys exist 2009-10-17 16:52:09 +00:00
bdafc20cff enable wrap cursor for transform. might want this disabled when the manipulator is used? 2009-10-17 15:25:19 +00:00
d11888b470 - wrapping failed with the cursor at the screen edge,
- changed numbuts behavior with continuous grab so dragging back after passing the button limit immediately adjusts the value
2009-10-17 14:54:13 +00:00
9d98b48925 Temporary remap extrude to Ctrl+Alt+Click, to avoid conflict with transform. 2009-10-17 14:45:49 +00:00
91d89c1ff7 Adjustments to continuous grab
- Use an enum for grab modes rather then boolean options.
 -- GHOST_kGrabNormal: continuous grab userpref disabled
 -- GHOST_kGrabWrap: wrap the mouse at the screen bounds *
 -- GHOST_kGrabHide: hide the mouse while grabbing and restore the mouse where it was initially pressed *

GrabWrap is nice for transform and tools where you want some idea where the cursor is, previously I found both restoring the mouse at its original location and restoring at a clamped location was confusing with operators like transform, wrapping is not ideal but IMHO the best of a bad bunch of options.
GrabHide  is for numbuts, where restoring the mouse at the initial location isnt so confusing.
2009-10-17 14:08:01 +00:00
53624a53d9 Assorted tweaks for animation editors:
* Changing to the ShapeKey editor now automatically enables the value sliders
* Filtering code for ShapeKey editor can now do AnimData block filtering too (internal details...)
* Silenced console warnings when inserting keyframes on F-Curves with no keyframes already (for Animation Editor sliders)
* Made the update code for keyframe transforms send more general depsgraph updates. Unfortuately, this still doesn't resolve the update problems with shapekeys
2009-10-17 04:22:52 +00:00
474e97e6d2 Fix for World tab:
Unlinking an World Data block caused the whole tab to disappear.
2009-10-16 19:46:53 +00:00
38ce0c64cd Forgot to commit these files in 23837. 2009-10-16 19:25:51 +00:00
99ec29193a bisplay shapekeys as sliders in the dope sheet editor 2009-10-16 18:03:38 +00:00
4957d50b79 shape key mirror failed with center verts 2009-10-16 16:09:57 +00:00
863e661cc3 Bugfix: sculpting with a multires modifier at level 1 would crash. 2009-10-16 15:28:43 +00:00
299adde803 shape key mirror tool, access from shapekey list buttons 2009-10-16 13:04:59 +00:00
f6494ff3cf ShapeKey Editor (sub-mode of DopeSheet Editor)
Special priority request from Durian team to get this sub-editor of the DopeSheet Editor restored. Originally I was kindof planning to drop it, but obviously it still has a role!

It now supports all the modern features that the DopeSheet supports, complete with selection, muting, locking, DopeSheet summary, and all the other tools that you know and love from the other views. 

Also, this no longer uses the old hacky sliders that 2.4x used (instead it uses RNA-based ones), so should function just the same as other DopeSheet views).
2009-10-16 12:08:47 +00:00
6846abb2ca Added Notifier for Adding and Removing Keying sets. 2009-10-16 10:49:54 +00:00
fbfbb2afe9 Toggle visibility of channels operator (VKEY) in Graph Editor channels view now works for channels with the toggles other than F-Curves and Groups 2009-10-16 10:44:10 +00:00
299d7531ed Fix for last commit, used wrong operators. 2009-10-16 10:40:03 +00:00
2e74a6ba30 Added a button to clear the weights of all shape keys, useful
when editing shapes and doing blending tests.
2009-10-16 10:29:41 +00:00
04f17fed4d 2.5 Outliner:
Finally, the Outliner Header is drawn via Python too. 
* Also added some Operators to the View Menu.
2009-10-16 10:25:39 +00:00
5938b4c93e new utility function for BLI_storage.h - BLI_is_dir
currently unsupported on windows.

should fix this too [#19656] N-Panel in filebrowser not working
though typing in invalid names then becomes possible
2009-10-16 10:22:11 +00:00
59f330cce0 Add back Blend From Shape in mesh edit mode. 2009-10-16 10:05:58 +00:00
61a88bb597 Bugfix: z-offset for materials was not added back yet. 2009-10-16 10:03:39 +00:00
680888419d A few Graph Editor tweaks:
* Tiny tweak of GL commands used when drawing F-Curves (single GL_LINES instead of multiple GL_LINE_STRIPS) to hopefully improve the performance with heaps of handles drawn a bit

* Spelling fix for initTransDataCurveHandes -> initTransDataCurveHandles
2009-10-16 10:01:15 +00:00
3d80fa9728 new operator - OBJECT_OT_make_single_user
Added keybindings and menu items
- Make Single User, Ukey
- Make Local, Lkey
- Make Duplis real, Ctrl+Shift+A
2009-10-16 10:00:45 +00:00
004199efd4 Graph Editor - Transform Crash Fix
The code for transforming a mixture of keyframes with bezier and non-bezier interpolation was crashing. 

The old code only took all the handles when a keyframe was bezier, and one when it was not; but sometimes this underestimated the situation (the first handle is only really used if the previous keyframe was bezier, as per the standard evaluation rules for these, but it didn't really check for this). Now, it just adds them whenever, since there is the possibility that keyframes may be moved before other unselected ones, in which case the handles may become invalid.

Thanks to Lee (from Durian, who found the crash), and Jess Balint (who had submitted a patch with some steps towards fixing this)
2009-10-16 06:24:39 +00:00
7016400278 Zoom to mouse pointer with mouse wheel works again.
The point where it zooms to can now be specified as operator properties and will be used if zoom to pointer is on. (when not specified, it will use the x and y of the event)
2009-10-16 00:23:40 +00:00
6ffb79107c X Mirror editmesh with PET
Lock vertice near the middle (|x| < 0.0001) on the mirror's plane.
Don't propagate transformation across mirror plane (this could probably be smarter)
2009-10-15 21:54:22 +00:00
dcecd8e043 Force cursor grab OFF when running with -d.
It helps running a debugger when you can click on stuff when on a breakpoint...
2009-10-15 20:38:35 +00:00
17c7b46334 object apply menu and keybinding (Ctrl+A) 2009-10-15 20:15:21 +00:00
ee6dd8ec38 Cocoa :
- implemented custom cursor handling
2009-10-15 20:09:50 +00:00
5fff9cf660 stamp font size and added rendertime stamp option 2009-10-15 19:18:40 +00:00
66725a189e disallow editing particle settings when first entering particle editmode, would crash instantly when changing the amount for eg. 2009-10-15 18:27:41 +00:00
d464e2454e move view3d keymaps so edit&paint mode keymaps override removed workaround that prevented switching directly from editmode to paint modes
+ other minor changes
2009-10-15 17:59:42 +00:00
bd0fee9a4c Network Render:
* Some code cleanups to match layout file code guidelines.
* Ported Operator Labels to op file itself.
* Added some Tooltips, theeth: Feel free to change/improve them as you like. :)
2009-10-15 17:18:47 +00:00
c102cedbf5 [#19644] Rotate around selection doesn't work
offset structures weren't initialized properly.
2009-10-15 15:58:12 +00:00
81beef19a3 Add side clicking in sliders.
Hold Alt and click where arrows are in num buttons.
2009-10-15 14:41:21 +00:00
33cd5fb85a Tiny tweak to make Anim Player button wide enough for icon+text. 2009-10-15 13:52:27 +00:00
d80074f18c Updated icons. Changed some icon names that weren't blank. 2009-10-15 13:47:18 +00:00
158534d404 Bugfix: editing shape keys in edit mode would not work correct
when blending shape keys.
2009-10-15 13:33:56 +00:00
fe649ec580 Num Sliders Tweak:
The dark bar for sliders will now be drawn in a way that takes into account the state of the slider (this includes info about keyframing and/or drivers). This means no more ambiguarity about whether these sliders are animated or not!

I've had to make a little hack here to make sure that the sliders bar will still be visible after the state has been blended, but this should probably be solved nicer by adding a separate setting for blending-factor in this case.
2009-10-15 11:52:23 +00:00
734d50e8df typing in non-existant dirs now goes back to the previous dir. (also for bookmarks and when changing dir's in other places) 2009-10-15 11:11:52 +00:00
384a1b5a5c UI Templates: RNA-Path Builder (Skeleton Code)
Added a base-template for editing/creating RNA-Paths. This is now used for KeyingSets and Driver UI's, so that when the actual magic gets put in, it will work.
2009-10-15 10:13:59 +00:00
29e738f60c Bugfix: deep shadow buffer commit made mixed solid/ztransp rendering
not work correct without OSA.
2009-10-15 09:56:10 +00:00
a28b9512fe made texflag a short everywhere (only stores one flag)
fix for crash with separate (missing NULL check)
2009-10-15 09:00:40 +00:00
a6645bfafb pack all was giving an error on the render result 2009-10-15 08:39:47 +00:00
3b2d752933 Cocoa :
- Small changes to make ghost_cocoa compatible with 10.4 + gcc4.0 (the initial goal was to be 10.5+ compatible, but 10.4 is finally also possible)

- Main window title is now in Apple document window title style (proxy icon + filename)

- fix for top menu "Blender" sub-menu not anchored correctly in 10.5
2009-10-15 08:27:31 +00:00
e6e8ba98df Fixed some icons in user preferences. These seem to be caused to an issue in the icon file itself though, where it assumes the wrong icon when pressed. (See checkboxes in menus that become locks when enabled) 2009-10-15 07:07:01 +00:00
316d604daf TransformOrientation enum is in the transform operators too, so we can't always cast to screen. 2009-10-15 01:34:29 +00:00
1da4a06fc7 Don't depend on context for transform_orientation enum
New current_orientation property that returns the current transform orientation data (if any)
New UI elements to rename and remove custom orientation (visible only when needed)
2009-10-14 21:05:35 +00:00
7bed5e35b4 added operators for setting rna for each type, this avoids having double "'quoted'" strings from C which is ugly. 2009-10-14 20:09:21 +00:00
991e67ddc7 RNA:
* Enums with an _itemf callback now never get context NULL passed in,
  rather a fixed list of enum items are defined which should contain
  all items (if possible), from which the _itemf callback can then use
  a subset.
2009-10-14 19:19:43 +00:00
96d2dc7d09 iTaSC: Selection of constrained axis for CopyPose constraint
This commit implements more of the CopyPose capabilities in
Blender. It is now possible to select which axis will be
constrained in position and orientation to obtain
interesting effects. Another option selects if the axis
are relative to the end effector or to the target.

Unlocking a position axis means that the coordinate along
this axis is not constrained and can take any value.
Unlocking the Y axis of the End Effector produces an
'aiming' effect: the end effector is oriented towards
the target but without stretching.

Unlocking a rotation axis means that the end effector can
freely rotation along that axis. Unlocking the Y axis
produces a 'tangent' effect: the end effector aligns with
the Y axis of the target but can rotate along that axis.

A 'floor' effect is possible if the position Z axis of the
target is unlocked. More effects are possible an can be
combined.
2009-10-14 18:51:00 +00:00
f579fe5681 fixes for warnings and crashes during doc generation 2009-10-14 18:48:19 +00:00
58cabaa1e3 weight-paint colorband wasnt working 2009-10-14 16:23:23 +00:00
59e3a08c8c Fixed shape key mute icon. 2009-10-14 15:37:10 +00:00
e2ae8843d7 texture mapping buttons were not visible, (own fault) 2009-10-14 15:28:57 +00:00
922461830f Scene/Render Buttons:
* Keep Render as default tab instead of Scene.
* Remove unnecessary Keying Sets label.
* Fix missing scene name in render context path.
2009-10-14 15:14:06 +00:00
bc0916c630 - added name field for renderlayer
- skin/loft now adds faces with active material
- defailt for scene panels isnt closed anymore since there is a lot of room there now.
2009-10-14 15:06:42 +00:00
866e41520c Bugfix: mesh menu was using two columns due to enum with label. 2009-10-14 14:55:01 +00:00
c27a94849c * Fixes for Render Tab separation.
* All Edges is now in the object mode "Display" Tab, as the option doesn't affect Edit Mode. 
Missing Redraw here...
2009-10-14 14:45:58 +00:00
0f6190a19b fix for continuous grab where you couldnt properly click the button for incremental changes or editing 2009-10-14 14:44:21 +00:00
73076a623b Bugfixes for python RNA/
* Adding properties to python defined subclasses could add
  them to the base type instead.
* FloatProperty did not work correct with negative min/max.
2009-10-14 14:44:05 +00:00
4ef0ef1927 added mesh mirror flag, now store this per mesh
button in mesh interface
also dont register operators that change context
2009-10-14 14:28:05 +00:00
1847f6198e After discussion with Campbell, split Scene tab in Scene and Render. This makes a clearer distinction between render and scene settings. 2009-10-14 14:07:32 +00:00
1ce959b16e Shape Keys: disable the temporary shape display system, where
it would show you the last selected shape key until doing
another operation. This is confusing, and the Pin button allows
you to do the same kind of shape browsing.
2009-10-14 13:21:54 +00:00
c7c2e3de1e set scene, currently UI is in the render buttons, should be moved to a scene buttons area.
added a property flag PROP_ID_SELF_CHECK, so properties can be set to point to anything but themselves.
2009-10-14 13:20:20 +00:00
cd202a1a24 Drivers UI - Converting to Layout Engine
* Converted Drivers UI to mostly use the Layout Engine
* All the buttons that perform actions are not operators yet (the code for that would be quite icky still)

* I've added some (commented out) calls for the property definitions of Driver properties to perform Depsgraph updates. I've left these commented out until we have the option to turn off auto-updates, since with driver editing, that could be very dangerous.

* Drivers can now (in theory) use any ID-block, using the Any-ID template added earlier. However, be warned that the stupid depsgraph won't be able to cope with most of these cases.


TODO: 
- more fancy widgets for RNA-Path and Index will come later
2009-10-14 11:57:26 +00:00
3d57e84088 Bugfix: new bump mapping with UV coordinates wasn't working
correct, my mistake in merging the patch.
2009-10-14 11:17:59 +00:00
0b19577930 skin/loft was broken, was passing short[2] as float[2] 2009-10-14 10:33:27 +00:00
d389406766 DopeSheet/Action Editors - Summary Channel Tweaks:
* Summary channel now works in DopeSheet AND Action Editors
* By clicking on the expand/collapse widget on the summary channel, you can now show/hide all the other channels in the editor.
2009-10-14 09:54:29 +00:00
107447b79e Cocoa : bugfix #19591
Add trackpad 2 fingers gesture handling, to have it mimicking correctly mouse wheel, and thus zoom in/out correctly in the 3D view
2009-10-14 09:46:41 +00:00
8884f3fe5c Bugfix: compositing nodes + border render + crop didn't work correct. 2009-10-14 09:40:09 +00:00
1ef163f1e0 UI Templates: ('Any ID' Selector)
Added new template for choosing to use any type of ID-block. The first combo box allows you to choose the type of ID-block that gets used, and the second box allows you to choose the ID-block of the type specified by the first one.

This is currently used for setting the ID-block used for Keying Sets, but the main user for this was intended to be the Drivers UI. However, I still need to clear up a few button-event issues there before I can port this over.


Additional Bugfixes:
* Adding new Keying Set path was setting the active path wrong, meaning that you had to click on the list to get some response after adding
* Bone Groups list was being drawn too long by default (when empty)
2009-10-14 09:08:53 +00:00
daebfaaa49 Bugfix: uv editor transform operators were not working anymore
after the recent retopo/snap commit.
2009-10-14 09:08:48 +00:00
6f2146e848 Cocoa : bugfix on continuous grab (cursor was returning to a wrong position upon button grab end) 2009-10-14 08:24:40 +00:00
828e3f3059 Left in debug prints 2009-10-14 03:00:35 +00:00
e87839b673 Bugfix: Automerge keyframes was broken - the function call to perform the merging was commented out 2009-10-14 02:18:59 +00:00
adddfffe23 * Fixed crash with operator cheat-sheet
* Removed obsolete comment
2009-10-14 00:01:34 +00:00
a9cf4bbf02 Use new operator to toggle view3d draw type. 2009-10-13 23:15:34 +00:00
3b805af8af Various warning fixes 2009-10-13 19:02:30 +00:00
e3d8c8eba8 added back space switching keys Shift+F2 to F12
- Shift+F2 was Export DXF, made Logic Editor
- Shift+F4 was data browser, made console
- Shift+F11 was fullscreen in 2.5, changed fullscreen to Alt+F11

added Area.type so RNA can switch the type.
2009-10-13 17:50:14 +00:00
ee29802378 [#19634] Missing - "All Edges" Button in edit mode Preferences 2009-10-13 17:49:05 +00:00
12b3d458f2 Bugfixes for particle mode:
* Fix crash removing all particles.
* Brush added particles did not get correct coordinates.
2009-10-13 17:15:12 +00:00
52f1ed4db8 Rename all enums called "prop_mode_items" into something more sensible. 2009-10-13 16:08:34 +00:00
db763fc445 - Identify and use retopo icon from icons image.
- Reuse proportional edit enums between rna scene and transform operator
2009-10-13 16:08:02 +00:00
4636438394 Enable snapping for curve edit mode.
It's still not possible to snap TO a curve, but at least curves control points can be snapped (or projected) to mesh geometry.
2009-10-13 16:05:57 +00:00
edfe78aec9 Context operators for adjusting context values directly to avoid adding operators for adjusting single values which also need duplicate notifiers.
wm.context_set(path="scene.tool_settings.someattr", somevalue)
wm.context_toggle(path="scene.tool_settings.somebool")
wm.context_toggle_values(path="scene.tool_settings.some_enum", value_1="somevalue", value_2="othervalue") # switch between 2 values
wm.context_cycle_enum(path="scene.tool_settings.some_enum", reverse=False)

the path value is taken from the context so the full path is 
context.scene.tool_settings...

This means in keymaps you can cycle draw modes, change PET- anything with rna access.
If its not so nice to map keys to operators like wm.context_set we could use macro's to wrap it and have its own name

Use this for PET and setting pivot options

- Made userpref key shortcut Ctrl+Alt+U since its not used in 2.4x
- added pivot_point_align (Alt+Comma)
- added PET wasnt rna wrapped correctly.
2009-10-13 15:30:19 +00:00
bdbae46519 Armature Ghosting Bugfix:
I noticed that armature drawing seemed to be using the wrong colours for ghosting in some situations (in particular, Cessen's biped rig for 2.5). Commented out what appears to be the offending code for now. 

Not totally sure why this broke yet, but as possible bonus of this, we sometimes get coloured ghosted controls (if bone groups were in use).
2009-10-13 12:09:11 +00:00
d3ebd62139 Animation Editors: Filtering buttons Cleanup
The filtering buttons for datatypes will now only be shown if there is data of that type present in the current file. They will still be shown in the same order, but by hiding the ones that won't be of any relevance, the presentation of the views should be cleaner (I hope ;)
2009-10-13 11:32:03 +00:00
de818dace5 DopeSheet: DopeSheet Summary Channel
Added a summary channel that appears as the first channel in the DopeSheet. For now, this is disabled by default, but can be enabled using the 'Summary' toggle in the header between the mode selector and the standard filtering options. This has been done, since there is a possibility that it will make the DopeSheet run a bit slower.

In this channel you can do everything that you can normally do with DopeSheet channels (i.e. select, transform, edit, etc). It might be worth noting though that care probably needs to be taken when trying to use Copy/Paste, since that is still a bit fidgety...

In the process, I've fixed a few bugs, mostly with selection:
- Selecting keyframes in scene summaries wouldn't work
- Border select only worked in F-Curve and Group channels
2009-10-13 11:21:02 +00:00
f4d2926986 Fix [#19602] Rayshadow that goes through transparent plane disappears
(some bugs may show on other places if some of the code isnt prepared to handle non-normalized is->vec)
2009-10-13 10:52:18 +00:00
8f25c0a799 moving textures up and down didnt move the material flag, made editmesh skin Ctrl+Alt+F 2009-10-13 08:55:11 +00:00
4063c230af fix for warnings, wkey menu wasnt registered 2009-10-13 07:39:08 +00:00
4b593ce328 * Fixing crash on mingw when entering world buttons
* Changing hotkey in text editor for 'jumping' to a particular line to Ctrl-G, since this appears to be more standard (and is easier to hit).
2009-10-13 06:15:41 +00:00
f8ab477f45 2.5 Bugfixes:
* Reverting some changes I made to try and get Action Groups with no viewable F-Curves, but were collapsed to get hidden. These were causing buggy behaviour

* Move bones to armature layers, and change armature layer operators now use the new automatic properties drawing invoke callback. This allows changing the buttons there immediately affect the bones in the viewport

* #19581: Text Editor: "Jump To" (go to line) not working
Made this use the automatic operator props invoke callback, and fixed an RNA properties bug for this (the default value and range values were swapped).

* PoseLib rename pose operator now works again. Once again, this uses the auto-props popup. Also, improved the code here while I was at it.

* Disabled non-functional/old entry in Select Linked operator ("IPO's")
2009-10-13 05:50:26 +00:00
7171c5928e Changing the animation editor filters should now result in the editors updating in realtime afterwards again. 2009-10-13 02:21:18 +00:00
1aeb98a3c2 * ui fix for texture influences 2009-10-13 02:04:08 +00:00
3a1216a2f2 Project option for snap to faces.
This is similar to the old retopo all option but uses the snapping code and not the openGL depth buffer (it's thus more precise).

Not sure if making it available as a snap option is sensible, this is up for discussion.

NOTE: it will get slow fast on large meshes, we need to plug in an acceleration structure into snapping.

This will need an icon too.
2009-10-12 22:33:32 +00:00
1fc616351b updated to work with 2.5x, currently no UI options. 2009-10-12 21:12:30 +00:00
565622dac3 skin tool from 2.4, am loathed to do this but durian artists want. 2009-10-12 21:11:31 +00:00
d2e1e0d2a9 remove C specials menus, reuse python ones from the header menu instead. 2009-10-12 21:06:03 +00:00
10198e99ff Deep Shadow Buffer
Since the deep shadow buffer summer of code project is not actively under
development anymore, I decided to build my own DSM implementation from
scratch, based on reusing as much existing shadow buffer code as possible.
It's not very advanced, but implements the basic algorithm. Just enough so
we can do shading tests with it, optimizations and other improvements can
be done later.

Supported:
* Classical shadow buffer options: filter, soft, bias, ..
* Multiple sample buffers, merged into one.
* Halfway trick to support lower bias.
* Compression with user defined threshold.
* Non-textured alpha transparency, using Casting Alpha value.
* Strand render.

Not Supported:
* Tiling disk cache, so can use a lot of memory.
* Per part rendering for lower memory usage during creation.
* Colored shadow.
* Textured color/alpha shadow.
* Mipmaps for faster filtering.
* Volume shadows.

Usage Hints:
* Use sample buffers + smaller size rather than large size.
* For example 512 size x 9 sample buffers instead of 2048 x 1.
* Compression threshold 0.05 works, but is on the conservative side.
2009-10-12 19:41:40 +00:00
b5f820cd87 added rna api MVert,MFace & MEdge index properties
eg.
 for v in me.verts: print(v.index)

added calc_edges as an option eg.
  mesh.update(calc_edges=True)

This is needed when adding faces to an existing mesh which create new edges.
2009-10-12 19:34:58 +00:00
0696cf23e5 Fix #19631: soft size setting for lamps was not RNA wrapped correct. 2009-10-12 19:19:29 +00:00
d2551d1bb1 Bugfix: crash in assigning automatic vertex weights from armature. 2009-10-12 17:16:44 +00:00
6b03b4285c *Moved the texture reordering buttons to the side
*Use same icons for reordering in constraints, modifiers.
2009-10-12 17:00:38 +00:00
9c7fe13a57 Cocoa : fix secondary window display bug issue 2009-10-12 16:51:36 +00:00
9cefe50e1f *Added ability to enable GLSL display in the 3D Views View panel (n key).
*Commented out the Quad View options since they don't work yet.
2009-10-12 16:34:55 +00:00
fbde77ce80 texture slots up/down back 2009-10-12 16:00:39 +00:00
50fd4f967f minor changes to texture ui, not user visible 2009-10-12 14:38:35 +00:00
0eab183a66 Following up on revision 23783
Transform saves back tool settings only when they weren't set as operator argument (and only when running modal).
2009-10-12 13:37:07 +00:00
f1a0df22df Bugfix: texture nodes header was still showing wrong texture
when using node materials.
2009-10-12 13:12:45 +00:00
e36003e8e7 macro's can set options for the operators they execute
changed extrude, rip and duplicate to disable proportional editing however this gives a different problem now.
Commented in transform.c
 // XXX If modal, save settings back in scene

this changes disables the option whenever the macro used used.
2009-10-12 12:54:08 +00:00
715f682f22 Fixed [#19624] Small typo in Network Render. 2009-10-12 12:39:05 +00:00
600fcd98f3 Fix some mem leaks 2009-10-12 11:41:20 +00:00
237cd688aa Animation Editors: 'Only Selected' filtering option now works on Pose Channels too
* Only F-Curves and Drivers that affect selected bones will be visible when this happens. 
* Moved the function to grab text within a pair of "" following some prefix to blenlib.
2009-10-12 11:27:34 +00:00
b4a113669d Cocoa : Fullscreen mode improvement (Bugfix# 16682)
Instead of capturing the display and all user input (video game mode), the mechanism is now to hide dock & menu bar, and enlarge the window made borderless to cover the whole screen surface.

Thus all OS X window management features remains available (other windows,multi screens compatible, process switching, expose, spaces, ..)
2009-10-12 09:53:28 +00:00
829bbda7f5 Bugfix #19616: vertex group select as IK target cause crash in Blender2.5
Thanks to Masahito Takahashi (mato)  for the report and patch to fix this!
2009-10-12 09:39:57 +00:00
eaadc0685b fix for own typo r23771, reported as [19621] Weight Paint crashes in rev. 23775 2009-10-12 06:45:55 +00:00
0c0aa79cb9 * crash fix in volume render, less reliance on global R 2009-10-11 23:04:01 +00:00
94d81336f1 Update MSVC project files 2009-10-11 21:13:32 +00:00
6b652ca543 realized some parts of the code might use screen/vert projection on instance objects which dont use the object matrix normally.
moved functions outside *_foreachScreen' funcs into their callers (mainly selection tools)
2009-10-11 20:32:25 +00:00
84172b31b5 remove OB_RADIO, added function by mistake 2009-10-11 20:03:55 +00:00
dff1738765 bugfix for exitmode verts being unselectable. caused by view3d_project_short_clip/noclip being used by selecton code outside of object drawing (which isnt supposed to happen according to view3d_project_short_* comments).
Deal with this by adding ED_view3d_init_mats_rv3d(ob, r3d) which initialized the region mat's and is used in mesh_foreachScreenVert, mesh_foreachScreenEdge etc.
2009-10-11 19:57:56 +00:00
efed73598f Use OB_MODE_EDIT as a flag everywhere, also fixed a typo which made drawing the set-scene not work right. 2009-10-11 19:06:38 +00:00
7ac1c7c899 fixed the code that updates normals of quads when sculpting 2009-10-11 12:09:14 +00:00
4081f33687 EditMesh was using VBO's even when off in the user preferences causing glMapBufferARB to return an invalid array, however setDrawOptions was (incorrectly) disabling VBO's in almost all cases so it didnt crash except for entering editmode on an object used as a custom bone shape.
Changed to allow setDrawOptions (since it works fine), but only to use VBO's when its enabled in the userprefs.
2009-10-11 11:21:51 +00:00
77bfc417ff Bugfix #19612: Incorrect ranges for frame range properties broke playback. I'm still not exactly sure which commit did this evil deed, but at least it's fixed now... 2009-10-11 07:29:53 +00:00
ac441cecd0 bugfix - [#19563] Select camera+ctrl alt 0 crash 2009-10-10 23:50:15 +00:00
fc44a97b73 adding a cone didnt work 2009-10-10 23:15:52 +00:00
a3f6b0ed00 - add torus back from 2.4x as an operator
bpy.ops.mesh.primitive_torus_add(major_radius=1, minor_radius=0.25, major_segments=48, minor_segments=16)

- experemental dynamic menus, used for INFO_MT_file, INFO_MT_file_import, INFO_MT_file_export and INFO_MT_mesh_add. these can have items added from python.
eg.

- removed OBJECT_OT_mesh_add, use the python add menu instead.

- made mesh primitive ops -  MESH_OT_primitive_plane_add, ...cube_add, etc. work in object mode.

- RNA scene.active_object wrapped

- bugfix [#19466] 2.5: Tweak menu only available for mesh objects added within Edit Mode
  ED_object_exit_editmode was always doing an undo push, made this optional using the existing flag - EM_DO_UNDO, called everywhere except when adding primitives.
2009-10-10 21:23:20 +00:00
deb30e8f9e Fix #19571 (reported by Markus Ilmola):
Added missing callbacks. Was leading to crashs when the raytree was empty.
2009-10-10 18:42:20 +00:00
622ffe263a Bringing back the transform orientations panel.
Orientations enum in view3d. Full list of custom orientation (RNAified) in scene.
2009-10-10 17:40:56 +00:00
811a767827 Add operator and operator type flag for GRAB_POINTER, don't coopt the OPTYPE_BLOCKING flag for that.
It will check if either the operator or operator type flags are set on top of the user preference before grabbing the pointer.

I've set that flag for 3d view navigation operators, others should be set too (no transform, I'll deal with that one).
2009-10-10 17:19:49 +00:00
f716f22d1f changed limits for some rna values, added object.scale_linked_x/y/z 2009-10-10 16:17:33 +00:00
85ebea5838 When in localview, MKey moves objects out of localview, added redraw notifiers 2009-10-10 12:29:11 +00:00
5621848629 - added redraw notifier.
- removed custom invoke function, use generic names (was misleading since conversion is done on selection, not just active).
- made convert mesh to curve use the 'keep_original' option.
2009-10-10 10:49:17 +00:00
331a58d44c * Added the new Render Icons to the menu as well.
* Added Tooltips for Help Scripts.
* Minor tweak to Continuous Grab Tooltip, as it now works on Mac too.
2009-10-10 09:34:22 +00:00
d30be46ad8 * icon set updates, thanks jendryzch 2009-10-10 08:40:44 +00:00
1cc79c1a95 Fixing mixed code and declaration.
PEOPLE, PLEASE CHECK YOUR WARNINGS BEFORE COMMIT
2009-10-10 03:29:03 +00:00
f9bb4e3195 * Added Grease Pencil Operator buttons to the Toolshelf
* Cancelling loopcuts with EscKey or RMB now works again.
2009-10-09 23:34:52 +00:00
fb561fb4c8 added mesh to curve conversion (edge loops only)
like the script in 2.4x
2009-10-09 22:09:48 +00:00
0b23e65e86 * more small raytrace fixes 2009-10-09 22:06:23 +00:00
578bb93ada Add reload button for image textures. 2009-10-09 22:00:33 +00:00
ca77d6dabb Animation playback can now also be cancelled with ESC key. 2009-10-09 21:50:33 +00:00
e5d61c7f41 Bugfix: separate mesh did not preserve UV/Color layers. 2009-10-09 21:45:14 +00:00
a5b30906ad Bugfix: texture nodes render without OSA was using uninitialized
variables, giving incorrect results.
2009-10-09 20:59:44 +00:00
7d07342c09 -f argument uses MINFRAME instead of 1 (makes it possible to render negative frames on command line). Not that useful, but it's good to use the same limit everywhere. 2009-10-09 20:44:50 +00:00
1234f4709b Cocoa : Bug fix for continuous grab feature implementation 2009-10-09 17:42:31 +00:00
638ed7d0a8 Fix background image sometimes drawing into depth buffer, causing
wireframes to be occluded.
2009-10-09 15:47:35 +00:00
9bf20b5ec0 UI scripts:
* Fix AAO showing Distance property even though it is not supported.
* Fix texture buttons not displaying texture stack from the node material.
* Small visual tweak to particle mode options.
2009-10-09 15:25:19 +00:00
dfbe2f9974 Fix for crash when saving a render result image, then rendering
again. The saved image would still point to the render buffer,
which was freed again on render. This is not a real solution but
avoids the crash for now.
2009-10-09 15:09:21 +00:00
8f57b368ca Cocoa :
Implement OS X support for Campbell's new continuous grab feature
2009-10-09 14:42:36 +00:00
8c96e2f4d2 - added ramp diffuse & spec factor rna props
- made 3dspace camera editable
- convert in object menu
2009-10-09 14:35:54 +00:00
cbd5117432 * Show Smoke Field Weights only for Domains. 2009-10-09 13:56:35 +00:00
105a53a29d Bugfix for crash when clicking on "View->Properties". Was accessing unused memory here (uiBlock *block is uninitialized).
If there is the need of uiBlockEndAlign() please get the valid uiBlock pointer from somewhere!
2009-10-09 13:34:24 +00:00
3b8925c655 Particle Edit Mode:
* Fix crash trying to enter particle mode when the particle modifier
  is disabled in the stack.
* Fix redraw being very slow due to the draw function causing the
  object to be recalculated on each redraw (through PE_draw_object).

* Removed the system where PE_get_current would automatically create
  the particle edit, this would run from poll() functions, which gave
  all kinds of issues, now it only creates the data on enter/exit
  and switching active particle system.
2009-10-09 13:25:54 +00:00
ca3e778134 Cocoa port :
- Fullscreen mode is back!
- Cleaner fix for tablet events handling
2009-10-09 12:48:28 +00:00
ae6c08ac5e Wrong Tooltip for Continuous Grab. 2009-10-09 12:47:25 +00:00
3d771d88d8 wm menu freeing was using freed memory, bone-parent names were being set to "" on menu draw WHY??? - r23247, you know who you are ;) 2009-10-09 12:34:37 +00:00
2cf7d4867d (Untested) String Replacement Function in blenlib
Currently this hasn't been tested yet, but committing this first before I potentially use it for fixing RNA-paths...
2009-10-09 12:18:32 +00:00
9f7038c5a7 * Warning fixes for previous commit for Modifier renaming.
* Removed some old code (depsgraph) that was already commented out
2009-10-09 12:16:58 +00:00
488c06d182 Cessen Request:
In Animation Editors, F-Curves for Pose Channel Constraints now include the Pose Channel and Constraint names in the 'owner' part of the name displayed, making it easier to identify which Pose Channel some constraint F-Curve belonged to.

e.g. The influence setting for an IK Constraint on bone "Boney"
Old Version:  Influence (IK)
New Version:  Influence (Boney : IK)

We can experiment with different representations of this later (maybe '>' instead of ':' ?)
2009-10-09 12:15:46 +00:00
be3da5dfff 3D View panels now show object and bone name again, not sure it
belongs here still, but this came up often, it avoids having to
switch tabs a lot when creating things.

Also renamed uiLayoutFreeBlock to uiLayoutAbsoluteBlock.
2009-10-09 10:45:11 +00:00
2226a5139a Fix some issues with showing the current textures when using
material nodes and texture nodes. Made it all use the same
give_current_*_texture functions now.
2009-10-09 09:50:49 +00:00
9ebcd9c5e4 A few bugfixes:
* #19583: Keying Sets list issues
Deleting a Keying Set (or a Keying Set Path) set the active index to 0, but that would mean that the first item would be selected but not visible.

* #19590: Keyframing properties of a modifier with more than one of it's type the property will highlight in all
- Modifiers now always have a unique name, so renaming a modifier should check that the name is unique. Most of the files changed in this commit were just to make sure that modifiers got unique names when they were created
- Modifiers path getter was wrapped a bit wrong (missing the "s around the name)

* Constraints Bugs
- Constraints renaming now also makes sure the names stay unique
- Fixed (or attempted to fix) compiler warnings about some enum declaration for distance constraint
2009-10-09 09:48:04 +00:00
cc4dd3f04e netrender
Support for fluid files and better support for point cache (including external cache for particles)

This also fixes a couple of bugs with frame based dependencies and with file transfer.

NOTE: With external point cache and fluids, the path needs to be relative or relative to the file (starting with //) if the files are not on a shared drive. It should eventually warn if that is not the case, but doesn't right now, so be careful.
2009-10-09 01:52:57 +00:00
1b6a09847a Partial revert of rev 23723
BRECHT, CHECK THIS

The change made it return RNA python properties with null data pointer instead of None.

That would make the particles and physics properties crash like this:

1. A valid property instead of None makes is seem like smoke (or other) modifier data is in context when it is Null.
2. UI code would try to access RNA properties of the (Null) modifier, which would crash
2009-10-09 01:34:46 +00:00
dadd8466d5 scons - ignore removing _tkinter.so when its not there 2009-10-08 19:32:06 +00:00
5c867406aa menus are now global (like operators), so for eg, the info add menu and the 3D add menu can be shared. 2009-10-08 19:06:32 +00:00
3ebd58673f Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.

There's actually 3 levels now:

* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
  or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
  to .py files as well to make creating distributable configurations
  easier.

Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.


Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
  keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
  added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
Ken Hughes
e0c5e48473 Scripts
-------

Port of MDD export script to Blender 2.5.
2009-10-08 17:32:51 +00:00
d01c737283 Cocoa port :
Quick&dirty bug fix to catch ad discard tablet induced exceptions.

I'll make a clean fix upon getting a tablet to debug.
2009-10-08 17:13:57 +00:00
ff07676b40 bring back automerge - [#19538] automerge editing doesn't work 2009-10-08 15:50:42 +00:00
66634e2be4 toggle buttons for texture channels (hardcoded like UV layer buttons) 2009-10-08 15:29:43 +00:00
88613b9184 Cocoa port :
Bug fix : newly created window not seen as activated by WM

Added more conservative memory management (may need to optimize later)
2009-10-08 15:28:31 +00:00
e936c80985 Smoke:
* Bugfix for non initialized arrays (reported by nudelZ)
2009-10-08 15:19:57 +00:00
248de36c63 netrender: bugfix by matd on irc. unbound var when broadcast is off 2009-10-08 15:02:01 +00:00
b8354a2da8 unselected group color was too hard to see in the 3D view, made darker 2009-10-08 14:11:06 +00:00
8056d27bac Alt+A in the sequencer now redraws other sequencer views, not ideal but ok for now. 2009-10-08 12:33:51 +00:00
ab287786b1 2.5 MSVC projectfiles_vc9
eek, forgot to add file in last commit
2009-10-08 12:13:23 +00:00
5ce33cf2bd A few fixes:
* Loading old files didn't initialise the new rotation variables properly
* Fixed some errors with the newly added operator for copying RNA-paths for properties
* Auto-keyframing now correctly refreshes animation editors after adding keyframes. Made the keyingsets code send notifiers again, but now using the newly added WM_main_event_add()  (thanks Brecht)
* A few UI tweaks again for animation stuff (timeline, keyingsets UI)
2009-10-08 11:29:27 +00:00
208d57323e Fixed #19571
(was crashing when building a raytree from a scene withouth any geometry)
2009-10-08 11:24:06 +00:00
c1302cfa95 2.5 MSVC9 projectfiles
Quick update:
* added new raytrace lib
* added gpu_buffer.c
2009-10-08 11:12:03 +00:00
14f62c1321 Smoke:
* Enable external forces like e.g. wind
2009-10-08 10:18:14 +00:00
8f154364f2 separate material lost all materials for the new mesh 2009-10-08 09:22:39 +00:00
5a7db36b1d missed this in last commit comments,
Pattern Select operator, access from the object select menu

Glob strings like "Lear*.brown" and "Tree.0?", option for case sensitive and extend the existing selection.

currently the default string is "*" which needs to be edited in the redo-panel in the toolbox since there is no way to get a text input for python.
This replaces 2.4x's data browser Shift+F4, pattern select.
2009-10-08 08:01:51 +00:00
df6c18e963 - object.selected is now editable (uses update function to flag the scene base)
- editing properties from python wasnt running their update function.
- missing commas made dir(context) give joined strings.
- added __undo__ as an operator class attribute so python ops can be set as undoable. (like existing __register__)
2009-10-08 07:54:20 +00:00
da698657ce Keying Sets - Bugfixes + Auto-Keyframing
* Added a new option for Auto-Keyframing which makes it only insert keyframes for the items included in the active Keying Set. 
This only works for Transform Auto-Keyframing so far (other tools will get it added later). The option is disabled by default.

* Fixed bug where adding an 'entire' array to some KeyingSet would only start from the index of the button that the mouse was over at the time

* Made some UI tweaks for Keying Sets buttons (still heaps of missing options there).
2009-10-08 06:39:45 +00:00
6e43a69a8d Bugfix #19576: Auto keyframing does not record rotations on object level animation
The hardcoded paths for rotation keyframes on objects got broken by my commits to rename the rotation properties. I've taken this opportunity to recode the auto-keyframing code here to use the builtin keyingsets instead of going through and manually calling insert_keyframe(), thus preventing this problem in future.
2009-10-08 05:53:26 +00:00
b4b031eae7 Fixed remaining bugs with animating rotation modes:
* Removed the hack-functions to set euler rotations from the values set in the other rotation representations, even when euler rotations weren't being used. I pressume that this was added for being able to represent quats in terms of eulers for the UI, but really it would break animation evaluation (i.e. euler curves after quaternion curves would always block the quaternion curves).

* Object rotation values in the transform properties panel now take into account rotation modes, so the appropriate rotations will get converted to quaternions before being drawn.

* Fixed a few bugs with some of the conversion code (minor stuff left out).
2009-10-08 05:02:04 +00:00
475ab5ceb4 Rotation Modes Bugfix:
Animating rotations using different rotation modes should now work more often than before. 

Previously, quaternion and axis-angle values were stored in the same variable in DNA, but that was causing problems with other animation curves overwriting the values and causing the rotations to not work as expected. 

There are still some issues, but I'll track those down later tonight
2009-10-08 00:57:00 +00:00
fd511eb984 Node Bugfixes:
* Compo node backdrop works again.
* Compo node previews and backdrop now get correct color management
  float to byte conversion.
* Compo nodes got unecessarily recalculated while moving nodes.
* Fix compo node viewer nodes not getting activated correctly.
* Main compo node preview render computations are now outside of
  mutex lock, so better for multithreading.
* Tex node outputs did not work in some files loaded from 2.4.
* Change RNA updates to take into account groups that may be shared
  between multiple node trees.
2009-10-07 22:05:30 +00:00
1b7e5b9abe WM: test with context-less add notifier. Notifiers are one
of the main reasons for passing along context, while actually
they don't need much context at all. Might be removed again,
but would like to have this especially for RNA API functions.
2009-10-07 21:39:24 +00:00
0c857a4f14 - made ungrab a second function - WM_cursor_ungrab
- ungrab can restore the position of the mouse clamped to the window bounds (much nicer for transform)
2009-10-07 21:19:35 +00:00
a4e36f24c7 [#19354] Second press of axis key didn't do local orientation when global was selected as user orientation (frankly, I don't like it much to have an exception for that, but backward compatibility is ok, unless someone else has a strong argument against). 2009-10-07 20:55:14 +00:00
ef13a40fed Makefile: Add missing raytrace directory. 2009-10-07 19:29:39 +00:00
763358fe91 copy icon in the material buttons list view so you can copy the current set of materials to other selected objects, (like Ctrl+L, Materials in 2.4x) 2009-10-07 16:32:55 +00:00
df63ccd904 Transform Mirror:
* Make Ctrl+M key work for mirror in 3D view.
* Fix mirror along global axis, was mirroring around all axes when
  the object was rotated, due to wrong matrix order, was also not
  working in 2.4.
* Pressing e.g. X twice still doesn't go to local mode, would fix
  but don't know how the code is intended to work.
2009-10-07 16:10:06 +00:00
93b5375ca1 Making new faces (fkey, scanfill etc) didnt create faces with the active material.
Keep the editmesh material and active material in sync
2009-10-07 15:16:08 +00:00
cf4f00b2fa Preview Render:
* Fixes for texture and material nodes.
* Texture node previews now work more like materials.
2009-10-07 14:48:29 +00:00
17c083a38f 'Add Group' back in the add object menu 2009-10-07 14:40:27 +00:00
568be17326 Option to copy the data path of an RNA button 2009-10-07 13:22:56 +00:00
9cf78144f1 Updated descriptions from Ron Walker 2009-10-07 12:19:47 +00:00
f5a9f420fb * More fixes post-raytrace commit 2009-10-07 12:17:29 +00:00
a899e9dd18 Check if the object is in editmode with (ob->mode==OB_MODE_EDIT) rather then (ob==scene->obedit)
Was trying to fix a hard to redo crash with custom bone shapes in editmode but cant redo. still, will help with future multi-editmode.
2009-10-07 11:36:29 +00:00
efe3858000 Bugfix: move to layer was not assigned to M key yet. 2009-10-07 10:54:43 +00:00
395e61e77c own mistake in last commit 2009-10-07 09:55:18 +00:00
60e75845fb Fix compile warning, function does not return anything (void function). 2009-10-07 09:49:37 +00:00
dfe7cde9f1 - rna path lookup crashed if the string was null (reported by Cessen with an empty driver)
- added TexMesh access ([#19505] Missing option : TexMesh)
- Ctrl+Tab works again, not-so-nice workaround, disallow switching to paint modes from editmode, but would be nicer to manage this with keymaps.
2009-10-07 09:23:29 +00:00
77476b294f Experimental option to allow moving the mouse outside the view, "Continuous Grab" in the user-prefs.
- Useful for dragging buttons to the far right when theyd otherwise hit the screen edge.
- Useful for transform though probably NOT what you want when using the transform manipulator (should make an option).
- When enabled, number buttons use this as well as a different conversion of mouse movement
  float numbuts: mouse 1px == 1-clickstep
  int numbuts: 2px == 1 (tried 1:1 but its too jitter prone)

details...
- access as an option to GHOST_SetCursorGrab(grab, warp)
- Currently all operators that grab use this, could be made an operator flag
- only Ghost/X11 supported currently
2009-10-07 07:11:10 +00:00
828395744a own warnings added last commit 2009-10-07 05:26:13 +00:00
e22b5fb271 * Add numpad enter as an alternative key to confirm/execute file browser 2009-10-07 05:13:31 +00:00
a8b82a49ad * notifier fix to redraw upon changing lamp shadow type 2009-10-06 23:37:11 +00:00
f413091dfa * Fix for previous 'set object as camera' operator - now properly sets the scene active camera too, plus better notifier. 2009-10-06 23:13:07 +00:00
91400d9da8 * Fix for crash with new raytree 2009-10-06 23:05:53 +00:00
46402ccddc netrender: use TEMP env var if available to set default temporary path 2009-10-06 21:28:45 +00:00
041ce137e2 mistake in last commit 2009-10-06 20:00:23 +00:00
88ab193a21 Bugfix: IK constraint pole angle range was not correct. 2009-10-06 17:15:10 +00:00
9e38ec2506 Add raytrace subdir to Makefiles.
The makefile is a copy of the source one, not tuned, just to unbreak build.
This raises some questions: why separate dirs? why each build system takes
a different approach (different libs vs all source files into one)?
2009-10-06 17:01:00 +00:00
07aba4f933 Cocoa port : First pure Cocoa version !
(Mostly for very early testers)

Cocoa uses coordinates with y=0 at bottom : updated wm_window.c and wm_event_system.c for COCOA build to avoid double conversions in response to mouse move events and GHOST_getCursorPosition

Known limitations:
No fullscreen support
Font issue in preference panel
libSDL uses some Carbon functions
2009-10-06 16:56:22 +00:00
8d54982f37 Material buttons now view the active node material shading settings.
Selecting a material in the node tree sets this as the active material and the buttons view redraws.

Added rna prop material.active_node_material

Currently its not clear what settings are used by the node material and the base material (needs some tedious research) so I made most panels use the node material with the exceptions of volumetrics, physics and halo settings.

We'll probably need to split the panels up to do this properly.
2009-10-06 15:31:25 +00:00
Nathan Letwory
86307b58c0 == SCons ==
* Unzip of python31.zip now works also for Python 2.5. Patch by b333rt (thanks again!)
2009-10-06 15:01:46 +00:00
Nathan Letwory
6282b7998b * copying of python31.zip and zlip.pyd is not necessary anymore, since the zip is unpacked by default to .blender/python/lib 2009-10-06 14:25:55 +00:00
Nathan Letwory
76019d5fb9 * Remember, C-style declarations at the *beginning* of a scope, not C++ style wherever one pleases (before first usage). 2009-10-06 14:09:40 +00:00
dd8e2897ba new operator - bpy.ops.wm.call_menu(name="SOME_MT_menu")
This calls a registered menu as a popup so we can reuse header menus , currently used for Node editor and Sequencer add menu (Shift+A), can be used for toolbox too.
2009-10-06 13:04:31 +00:00
2011ba50c8 Last fix still failed to link under mingw.
This time it works! (gcc and mingw can handle compile and link)
2009-10-06 12:23:25 +00:00
22605ec759 Bone Selections: Ability to set bones as unselectable
In the Outliner, it is now possible to toggle per bone the selectability of the bone in the viewport, as for Objects using the restriction columns. This can also be set using the RNA-api.

I've tested all commonly used tools IMO, but there may still be a few which I've missed. Please report those cases.

PS. For some reason, the define was already there, but not connected up to anything. Can't remember why anymore, but here it is...
2009-10-06 11:33:58 +00:00
c12cb02c56 sculpt was checking if multires was the last modifier,
instead check if its the last displayed modifier
2009-10-06 11:21:57 +00:00
ba3ec58d01 *Added memset's to make sure counters start on zero
*Disabled ray counter (can be enabled on render/extern/include/RE_raytrace.h by commenting out the define)
*marked bvh_node_merge() as static inline (hopping it now compiles on gcc and mingw)
2009-10-06 10:52:14 +00:00
08deeee455 One last try - this should fix the remaining issues:
* Made bvh_node_merge() in svbvh.h static (fix suggested by jaguarandi). This makes mingw link again.

* Also, patched my previous fix for  ... = {}; since mingw didn't like the other fix (which was for msvc).
2009-10-06 10:32:07 +00:00
c93127d06f Some more compile fixes for jaguarandi's commit, this time for msvc+scons
* Replaced ... = {}; with ... = {0}; 

* Solved problem with logf(), where msvc couldn't figure out which version of log() to call (solved by casting the int argument to a float, but could also have been to double)...

* The cflags and cxxflags for scons when compiling the rendering module were only valid for gcc compiles. These will still need to get added for msvc sometime, but for now, there are no more warnings about unknown options...
2009-10-06 10:23:25 +00:00
58557ea737 * Cmake fix for raytrace accel, still not 100% but getting there... 2009-10-06 04:37:25 +00:00
2936d791a2 * missed this in last commit 2009-10-06 04:37:01 +00:00
1c940d7677 Attempts at some compile fixes for jaguarandi's code:
* mingw almost compiles again cleanly, except for a linking error when linking blender http://www.pasteall.org/8297
* win64 should compile again too to a similar degree?
* silenced warnings about no newlines...
2009-10-06 03:40:50 +00:00
3fe274b072 Several fixes:
* Code for generating 'Object' summary of Keyframes for DopeSheet (which is also used by the TimeLine for getting keyframes to draw) now considers materials, object data, and particles too.

* Rearranged the way that keyframing-related settings were presented in the User Preferences. The way the settings were grouped was plain confusing, and based on biased views from the old system. For the record, 'needed'+'visual' are always considered when inserting keyframes, 'always' is for autokeyframing, and default interpolation is only used for newly created F-Curves.

* Fixed bug #19472 - Scroll wheel scrolls in the wrong direction for enum-menus that were flipped (i.e. window type menu and 3d-view mode selector).
2009-10-06 03:05:20 +00:00
04b60b4324 Merged Soc 2009 - raytrace optimization [0]
from branch [1] at rev 23647

[0] - http://wiki.blender.org/index.php/User:Jaguarandi/SummerOfCode2009/
[1] - https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-jaguarandi
2009-10-06 02:56:11 +00:00
d28d3194f4 * Added 'set object as camera' operator
3D View: View -> Cameras -> Set Object as Camera  (Ctrl Numpad 0)
2009-10-06 02:45:42 +00:00
63a88075b5 svn merge -r 23528:23646 https://svn.blender.org/svnroot/bf-blender/trunk/blender 2009-10-06 01:58:22 +00:00
11bdf6ea10 Added #ifdef __SSE__ so it can still build when SSE is disabled at compile time 2009-10-06 00:28:07 +00:00
a62e37bfbe blibvh safe for 64bits 2009-10-05 23:30:00 +00:00
69a2432574 Small fix for some old files crashing in particle drawing. 2009-10-05 23:04:40 +00:00
1f0ee67579 [#19535]
Save back proportional editing size to toolsettings after transform.
2009-10-05 20:31:41 +00:00
4e60007102 [#19542]
Correct spacing with snapping buttons in 3d view header.
2009-10-05 20:30:47 +00:00
a0d8d7afe0 edge loop delete, should be a c macro but they cant do settings atm 2009-10-05 19:42:48 +00:00
2072e7c6c7 VBO:
* Disable use of EditMeshDerivedMesh for VBO drawing in editmode.
  This is crashed when using e.g. subsurf in editmode, as the DM
  is not an EditMeshDerivedMesh.
2009-10-05 17:29:56 +00:00
e61e1c5ca8 VBO:
* Fix slowdown/freeze entering editmode on a high poly mesh,
  dm->getNumFaces can be slow, don't call it in a loop.
* Fix 64bit pointer casting warnings.
2009-10-05 16:48:52 +00:00
5f1b4334e2 VBO: disable VBO's by default. Not sure why this was not done, we
agreed on this as a condition for the project to be merged.
2009-10-05 16:40:13 +00:00
4211e1a58a Raytrace Acceleration: small tweak to RNA and UI, hiding buttons
when they are not applicable.
2009-10-05 16:18:08 +00:00
4df1e40006 Fixed [#19539] Texture > RGB Factor property doesn't appear in the UI 2009-10-05 15:59:12 +00:00
77b8be6e13 Cocoa port : Fix bugs in clipboard operations 2009-10-05 15:00:07 +00:00
3816554cbc General particle bug fixes + few small goodies
The goodies:
* Curves can be used as normal dynamic effectors too with 
  the new "curve" field shape.
* Group visualization has optional duplication counts for
  each object in the specified group.
* Object & group visualizations, which are done without
  taking the dupliobject's global position into account
  (unless the whole group is used). This is much nicer than
  the previous behavior, but I added a "Use Global Location"
  option for those who want to use it the old way.
* The active particle system's particles are now drawn a 
  with theme coloured outline instead of pure white.
* Added object aligned velocity factors (buttons categorized
  and re-organized too).

Bug fixes:
* Absorption didn't work as the ui toggle button was forgotten.
* Some other force field ui tweaks.
* Crash after adding children and changing trails count.
* Display types "cross" and "axis" crashed.
* Particles weren't drawn with correct coloring.
* Billboards didn't update properly in viewport to camera
  location changes.
* Particle rotation wasn't recreated correctly from point cache.
* Changing particles amount crashed sometimes.
* Some files with child hair crashed on loading.
* Compiler warning fixes.
* Adding boids crashed on frame 1;
2009-10-05 13:25:56 +00:00
a344977147 Cocoa port :
- Window creation at preferred size
  Implement in Ghost the use of Cocoa functions to get the maximum visible rect (size and position) for the window contents (all screen excluding dock, top menu, and window title bar)
  Thus Apple specific code in window creation (wm_window.c & wm_apple.c) is no more needed => removed in case of Cocoa build

- Alert on exiting despite unsaved changes
  Add to GHOST method to maintain an all platforms (not apple specific anymore) status on unsaved changes
  Update GHOST_SystemCocoa to use this for asking or not user to confirm exit without saving changes
2009-10-05 12:55:16 +00:00
3ec79d79e9 normals were updated incorrectly in buffers when sculpting. Still not perfect. 2009-10-05 09:03:35 +00:00
0f07bea06b remove unused defines, cant check every case but from grepping the souece it should go ok. 2009-10-05 07:08:59 +00:00
af522abf33 * changes/additions to volume lighting
Volumes can now receive shadows from external objects, either raytraced shadows or shadow maps.

To use external shadows, enable 'external shadows' in volume material 'lighting' panel. This an extra toggle since it causes a performance hit, but this can probably be revisited/optimised when the new raytrace accelerator is integrated. For shadow maps at least, it's still very quick.

Renamed 'scattering mode' to 'lighting mode' (a bit simpler to understand), and the options inside. Now there's:

- Shadeless
  takes light contribution, but without shadowing or self-shading (fast)
  good for fog-like volumes, such as mist, or underwater effects
  
- Shadowed (new)
  takes light contribution with shadows, but no self-shading. (medium)
  good for mist etc. with directional light sources
  eg. http://vimeo.com/6901636
  
- Shaded
  takes light contribution with internal/external shadows, and self shading (slower)
  good for thicker/textured volumes like smoke
  
- Multiple scattering etc (still doesn't work properly, on the todo).
2009-10-05 02:59:47 +00:00
Nathan Letwory
89df4a46fc * Unzip python bundle at the end of the build process. Patch by b333rt, thanks!
* remove /ARCH setting - is used only when building x86
2009-10-04 20:11:55 +00:00
Nathan Letwory
729a63bbb6 * update default physics settings for jahka 2009-10-04 19:53:06 +00:00
55541d8a81 Added some test_break during the build process.
(Maybe later this should be done with some thread_cancel function instead of doing variable/callbacks tests)
2009-10-04 16:56:00 +00:00
f82847687e VBOs weren't fully turned off in edit mode. Fixed that 2009-10-03 22:14:19 +00:00
Dalai Felinto
78d9891dfe mathutils: bugfix for matrix * vector
- terrible typo was making the multiplication to run in an infinite loop.
- Any matrix * vector multiplication would crash Blender.
eg
####
import Mathutils
from Mathutils import *

vec_ray = Vector(0.0, 0.0, 1.0)
tilt_mat = RotationMatrix(0.0, 3, "y")
vec_ray = tilt_mat * vec_ray
####
2009-10-03 21:48:15 +00:00
14c1dd941c Cocoa port : added standard menu in OSX menu bar 2009-10-03 18:25:54 +00:00
74e1093007 SVN maintenance. 2009-10-03 16:21:47 +00:00
853f8212ca sculpt mode crash fix when VBOs disabled 2009-10-03 16:21:35 +00:00
e80d2cc426 imbusy GSoC'09 branch merge (Vertex Buffer Object support) 2009-10-03 15:35:01 +00:00
8204dffe8a UI: Bugfixes
* #19529: Saving in edit mode causes problems in mode buttons when reopening
* Fixed compiler warning in writefile for mingw
* AnimData for Lamp data was not recognised by RNA
2009-10-03 11:23:31 +00:00
2cbf21b582 UI tweaks
*Fixed some spacing issues in 3D View and Outliner headers
*Made the Bone properties layout consistent with Object properties
*Put Rotation Mode menus below transformation channels, being less important.
*Tiny layout tweak for area lamps
2009-10-03 11:19:14 +00:00
f4c697cf7f Keying Sets UI:
Added a way to view and edit Keying Sets via the Scene Buttons. These are still some tweaks needed to make this really workable, but should still work well enough for simply viewing and tweaking existing Keying Sets created using other means.

Additional bugfixes:
* Adjusted the size of labels on properties that had a 'label' for their name. Now it uses 1/3 of the total width instead, which looks much better for most cases.
* Added missing entries for adding Force Fields from the Info-header 'Add' menu. At some point we should unify this menu with the popup operator's one, since this is exactly the kind of situation we had hoped in avoid with new UI architectures.
* Moved all the operator defines for keyframing stuff to the 'intern' anim header instead
2009-10-03 04:21:38 +00:00
97d8839ad5 F-Modifiers: Fix for Function Generator's "type" field not working
The field in RNA got renamed, but the UI code didn't get corrected, so the field for this wasn't working
2009-10-02 23:36:02 +00:00
72554c5dbb Quick Animation Editors Bugfix:
The settings for expanding the set of materials and/or particles on Objects were inverted, resulting in the wrong icon being shown.
2009-10-02 23:28:58 +00:00
44b74fa0ac Fixed [#19506] Missing buttons : Curve Guide.
Jahka: please check on the Kink type and axis RNA Wrapping. 
Todo: Make Curve Guide Field only available for Curve Objects.
2009-10-02 20:15:25 +00:00
Nathan Letwory
ca54ea078e * due to the setup of headers in mingw 4.4.0, includes could mess up. Making sure that windows.h isn't included where it shouln't (outside of __cplusplus) 2009-10-02 15:51:25 +00:00
9ac8a1368f Fix for [#19524] Lamp icons are not updated in outliner. 2009-10-02 15:27:26 +00:00
625da05e3a Smoke:
* Fix loading issue of blend files with smoke collision objects (was disabled on purpose since it will be subject of change, but can be solved using do_versions() later)
2009-10-02 14:40:51 +00:00
0a374e6679 Anim Bugfixes:
* Add F-Modifiers (for Graph Editor) was using a buggy poll() method. Silly typo.
* Bone groups now get duplicated when duplicating an armature object
2009-10-02 11:15:24 +00:00
fbb47e8604 Smoke:
* Dissolve is back
* Obstacles coming back (some bugs left i think)
2009-10-02 11:09:05 +00:00
aa2cd95c1b Cocoa port : first Cocoa version of GHOST_DisplayManagerCocoa 2009-10-02 07:20:33 +00:00
14619ec98d Move Inverse Kinematics panel to Constraint context. Make iTaSC parameter panel more readable. 2009-10-02 07:20:07 +00:00
ba2f052a37 projection painting changes from 2.4x r23600 2009-10-02 07:03:58 +00:00
624d26e0a8 fix for [#19013] Projection Paint Mask is failing (for campbell)
- flush face selection to the derived mesh where possible (if CD_ORIGINDEX is available).

- fixed border-select while painting which rarely worked.
- painting on a mesh with no UV's didn't free the derived mesh.
2009-10-02 06:06:09 +00:00
a9ef985b32 win32 was using iconv even when international was disabled. 2009-10-02 03:09:17 +00:00
b26ef33b8e Fix #19311: adding/opening datablocks did not always make the right
one active. Now there's a function to get the pointer + property from
the UI, just like for the animation operators.

Also two fixes for fileselect events, regions are now preserved so that
context is restored to the old region, and the cancel callback is called
when the operator is cancelled.
2009-10-01 23:32:57 +00:00
bc942eceac netrender: first draft for process jobs, to be able to run arbitrary commands on slaves. This could be used to bake physics on network or whatnot. 2009-10-01 18:57:22 +00:00
8da55763b5 *Updated UI options and added UI options to:
control whether instances are used or not
	control whether vertexs are stored localy or not

*Removed unsused code
2009-10-01 18:30:59 +00:00
57cf7d2d4a Bug fix
Snapping: transform snap in editmode couldn't snap to data in the same mesh.
2009-10-01 18:00:00 +00:00
606e609f5d Fix cmake compilation on Windows, adding pthread includes,
patch by Guillaume, thanks!
2009-10-01 17:24:24 +00:00
022a343223 Texture stack influences are now all separate values, and negative
mapped values now have their influence negated instead. Also a few
RNA changes for TextureSlot.

Bumped subversion for the version patch.
2009-10-01 17:15:23 +00:00
1525ed42c9 Brought back mousewheel multicut to Ctrl-R loopcut tool that was recently added. Tweak still doesn't work for the loopcut op, but it didn't before, so at least we're advancing. 2009-10-01 16:37:08 +00:00
15d81b21f6 Fixing scons compile on windows.
Since bli_threads.h now includes pthreads directly, we need to had instructions in SConscripts everywhere for proper include path.

Frankly, I feel like this should be done in a global manner and not in a per lib fashion, but that is for another day.

This commit also fixes more missing properties
2009-10-01 16:32:33 +00:00
37a729cb1d Fix crashes with .blend files saved in particle mode, derivedmesh
can't be assumed to be made yet then.
2009-10-01 16:30:05 +00:00
1c3faa97ff Fixed a part of [#19494]. Transform Lock Options didn't updated 3D View's Transform manipulator.
* Minor Code tweak in material RNA.
2009-10-01 14:41:45 +00:00
988e9132b8 Fix #19513: scroll wheel did not work when over disabled buttons. 2009-10-01 12:33:35 +00:00
492c545e05 only link against python when its enabled
remove duplicate linking flags (looks like a copy/paste error)
2009-10-01 11:21:40 +00:00
3f3c2d0204 Cocoa port, events WIP:
- Fix keyboard keymap
- NSAutoReleasePool now drained at every cycle
- Tablet events combined with mouse events now handled
2009-10-01 08:58:09 +00:00
0901eafa8f * Added proper update/conversions for changing between degrees and "mm" in camera 2009-10-01 04:14:43 +00:00
bf3374426a Use curve twist for the CurveDeform modifier and bones (anything that uses curve_deform_verts() and curve_deform_vector()).
So means minimum twist and twist smoothing are now used.

the Z up quaternion from the path is rotated to match the up axis given.

There was no logical rule for the up vector, some cases flipped the normals when used with the CurveDeform modifier.
Use the default X-Up behavior and match other settings with this. (comments explain this in detail).



- Interpolating quaternions didn't work in some cases, disabled for now.
- 'no_rot_axis' is different from in 2.4x since it now removes rotation from the tilt whereas before it edited the axis before calculating the tilt.
2009-09-30 23:31:10 +00:00
bff893a420 Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons) 
  instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group 
  setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
	- "Point" is most like the old effectors and uses the 
	  effector location as the effector point.
	- "Plane" uses the closest point on effectors local xy-plane 
	  as the effector point.
	- "Surface" uses the closest point on an effector object's 
	  surface as the effector point.
	- "Every Point" uses every point in a mesh effector object 
	  as an effector point.
	- The falloff is calculated from this point, so for example 
	  with "surface" shape and "use only negative z axis" it's 
	  possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer 
  just spherical.
* New effector parameter "flow", which makes the effector act as 
  surrounding air velocity, so the resulting force is 
  proportional to the velocity difference of the point and "air 
  velocity". For example a wind field with flow=1.0 results in 
  proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random 
  flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force 
  (note. the z-axis is the surface normal in the case of 
  effector shape "surface")
* New "force field" submenu in add menu, which adds an empty 
  with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector 
  system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for 
  particles, softbody & cloth, since their final effect depends on many external 
  factors, like for example the surface area of the effected faces.

Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through 
  DAG_id_flush_update(..).
  
Known issues
* Curve guides don't yet have all ui buttons in place, but they 
  should work none the less.
* Hair dynamics don't yet respect force fields.

Other changes
* Particle emission defaults now to frames 1-200 with life of 50 
  frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to 
  free pidlists after use :).
2009-09-30 22:10:14 +00:00
7d9bfdc31a building without bullet didnt work 2009-09-30 21:31:08 +00:00
e136f4f2bd Update MSVC project files 2009-09-30 19:51:12 +00:00
9f23a0c081 Bugfix for curve deform, would result in applying curve modifier inverting the normals for -Z.
Incorrect comparison with the 'axis' and OB_NEG#, the axis matches MOD_CURVE_NEG# which is from 1-6, not 0-5.
2009-09-30 18:55:59 +00:00
b466286c3e Render & Compositing Thread Fixes
* Rendering twice or more could crash layer/pass buttons.
* Compositing would crash while drawing the image.
* Rendering animations could also crash drawing the image.
* Compositing could crash 
* Starting to rendering while preview render / compo was
  still running could crash.
* Exiting while rendering an animation would not abort the
  renderer properly, making Blender seemingly freeze.
* Fixes theoretically possible issue with setting malloc
  lock with nested threads.
* Drawing previews inside nodes could crash when those nodes
  were being rendered at the same time.

There's more crashes, manipulating the scene data or undo can
still crash, this commit only focuses on making sure the image
buffer and render result access is thread safe.


Implementation:
* Rather than assuming the render result does not get freed
  during render, which seems to be quite difficult to do given
  that e.g. the compositor is allowed to change the size of
  the buffer or output different passes, the render result is
  now protected with a read/write mutex.
* The read/write mutex allows multiple readers (and pixel
  writers) at the same time, but only allows one writer to
  manipulate the data structure.
* Added BKE_image_acquire_ibuf/BKE_image_release_ibuf to access
  images being rendered, cases where this is not needed (most
  code) can still use BKE_image_get_ibuf.
* The job manager now allows only one rendering job at the same
  time, rather than the G.rendering check which was not reliable.
2009-09-30 18:18:32 +00:00
727745bd49 SVN maintenance. 2009-09-30 17:13:57 +00:00
c3ff4b09be svn merge https://svn.blender.org/svnroot/bf-blender/branches/blender2.4 -r23566:23567 2009-09-30 13:58:21 +00:00
db430c7c4f comparing float values with the property sensor didnt work 2009-09-30 13:19:42 +00:00
570c187ba1 Cocoa port start:
GHOST*Cocoa.mm & .h files creation
First Cocoa version of GHOST_SystemCocoa.mm
CMake files update to allow optional (WITH_COCOA option) Cocoa version build - disabled by default
SCons files are not updated to allow Cocoa build (the ghost .mm files)
2009-09-30 08:47:39 +00:00
2a21c1acbe Animato: Bugfixes
* #19501: Only the first user of multi-user IPO's were getting converted to AnimData. 
Now, this AnimData gets converted multiple times - once for each user. This will mean that multi-user actions will no longer be multi-user after conversion though, although this could be fixed manually if there really is such a need.

* #19503: Nasty memory leaks when duplicating objects with AnimData
Fixed a few little oversights made when coding the copying code for NLA-data (which resulted in exponential copying-loops of doom), and sanitised the AnimData copying code for ID-blocks to be simpler to manage.
2009-09-30 04:59:14 +00:00
8b6f5c171d - rather then passing the python namespace dictionary to the controller function get the namespace from the converter.
- renamed SetPythonDictionary() to SetPyNamespace()
- remove IsLight(), GetGameObjectType() existed before this but wasnt used for lights.
2009-09-29 22:49:33 +00:00
71b3088596 Rework of volume shading
After code review and experimentation, this commit makes some changes to the way that volumes are shaded. Previously, there were problems with the 'scattering' component, in that it wasn't physically correct - it didn't conserve energy and was just acting as a brightness multiplier. This has been changed to be more correct, so that as the light is scattered out of the volume, there is less remaining to penetrate through.

Since this behaviour is very similar to absorption but more useful, absorption has been removed and has been replaced by a 'transmission colour' - controlling the colour of light penetrating through the volume after it has been scattered/absorbed. As well as this, there's now 'reflection', a non-physically correct RGB multiplier for out-scattered light. This is handy for tweaking the overall colour of the volume, without having to worry about wavelength dependent absorption, and its effects on transmitted light. Now at least, even though there is the ability to tweak things non-physically, volume shading is physically based by default, and has a better combination of correctness and ease of use.

There's more detailed information and example images here:
http://wiki.blender.org/index.php/User:Broken/VolumeRendering

Also did some tweaks/optimisation:
* Removed shading step size (was a bit annoying, if it comes back, it will be in a different form)
* Removed phase function options, now just one asymmetry slider controls the range between back-scattering, isotropic scattering, and forward scattering. (note, more extreme values gives artifacts with light cache, will fix...)
* Disabled the extra 'bounce lights' from the preview render for volumes, speeds updates significantly
* Enabled voxeldata texture in preview render
* Fixed volume shadows (they were too dark, fixed by avoiding using the shadfac/AddAlphaLight stuff)

More revisions to come later...
2009-09-29 22:01:32 +00:00
98ee2a781d option to build the BGE without python, uses existing python check (cmake and scons)
when python is disabled videotextures are not built.
2009-09-29 21:42:40 +00:00
53f0c3b018 Fix link problem: Rename libed_preview -> libed_render 2009-09-29 20:26:06 +00:00
15d07720e5 Sorry, three commits in one, became difficult to untangle..
Editors Modules

* render/ module added in editors, moved the preview render code there and
  also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
  making a single physics_ops.c for operators and keymaps. Also move all
  particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
  specificially.

Updates & Notifiers

* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
  which will go back to a callback in editors. Eventually these should
  be in the depsgraph itself, but for now this gives a unified call for
  doing updates.
* GLSL materials are now refreshed on changes. There's still various
  cases missing, 
* Preview icons now hook into this system, solving various update cases
  that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
  problem is avoided in the new system.

Icon Rendering

* On systems with support for non-power of two textures, an OpenGL texture
  is now used instead of glDrawPixels. This avoids problems with icons get
  clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
  and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
  with the default setup. The glDrawPixels implementation on Mac seems to
  have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
  you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
  be used with threads reliably.
2009-09-29 19:12:12 +00:00
7f5dc4644f adding back changes from soc-2009-kaz branch. 2009-09-29 15:27:00 +00:00
f93ca02443 Copying scripts from 2.4x without 2.5x changes 2009-09-29 15:16:22 +00:00
1bebe4f901 history for these files was lost, will use "svn cp ....." to get the scripts from 2.4x and apply kazanbas's updates. 2009-09-29 15:08:23 +00:00
5443844cf6 Fixed import scripts: OBJ, 3DS. 2 bugs still perist though: imported meshes appear upside-down (foreach_set?) and materials don't import. 2009-09-29 12:34:05 +00:00
0c3288eb35 Fixed export scripts: 3DS, OBJ, X3D, FBX. These need testing now. 2009-09-29 12:16:58 +00:00
704a677498 Fix for CMake/OS X, would fail to copy files to bundle sometimes,
doing make twice would avoid this, but that's not very convenient.
2009-09-29 09:48:30 +00:00
c8b7384c4b remove ray sensors own logic manager (now stored in parent class) + other minor changes. 2009-09-29 07:51:54 +00:00
Dalai Felinto
64a093ea77 bge player - stubs update
*note in order to build blenderplayer with cmake+msvc one needs to comment all smoke references in stubs.c
- scons + msvc is building fine (raising some warnings for the smole references though)
- cmake in linux should be building as well (the smoke references were inserted in stubs to please this building environment IIRC)
2009-09-29 05:22:44 +00:00
3198ff876b Bugfix #19490: Adding UV texture, adds Vertex color instead
Seems to have been a copy+paste error (code for Vertex Color adding was pasted in place of texture paint). Restored the code from an earlier revision (from another file).
2009-09-29 02:19:27 +00:00
52b28fddec Removed the termporary defines added to make the Game Engine compile. Hopefully this fixes all of the cases which broke. 2009-09-29 01:52:54 +00:00
be3000773b Adding back more functionalities for transform orientations.
Create new orientation is now Ctrl-Alt-Space (Alt-Space is select orientation and the old ctrl-shift-c is taken by add constraints).

New orientation panel in 3d view sidebar (nkey) has operator buttons for select, create and delete. Eventually, this should become a list.

Note that orientation operators are missing notifiers to properly redraw the 3d view and its header properly.
2009-09-28 19:49:36 +00:00
31b77420ea Preview icon rendering for menus now runs in a separate thread, to avoid
blocking the user when opening a menu. Material and texture buttons now
display these icons in the list. Also fixes #19387, icon and full preview
render at the same time would crash.

I'm not really convinced this is thread-safe, but on the other hand also
not sure regular preview render is really thread-safe yet.
2009-09-28 18:33:45 +00:00
0e1cf15523 Fix python error in boids panel, missing variable psys. 2009-09-28 16:13:23 +00:00
34f87795a2 Fix #19483: error using FBX export script, diffuse_reflection
changed to diffuse_intensity.
2009-09-28 16:11:55 +00:00
e6078c7417 Fix potential crash for file operators that don't define
a "path" property, now it will just give a warning.
2009-09-28 16:11:06 +00:00
fde83cb75b Fix compile problem on OS X Snow Leopard. The Mac code for dynamic
library loading was using some non-public OS X functions, which give
linking issues for me. Since OS X 10.3 standard unix dlopen() is
supported, so I just removed this code, we don't support earlier
versions anyway.
2009-09-28 16:05:34 +00:00
ba7fb3f969 Fix drawing of MENU buttons with only an icon, was not aligned right
and showing unneeded triangles (+ buttons in Boids Brain).
2009-09-28 15:59:09 +00:00
Nathan Letwory
edfb47ffb4 * Copy() -> Clone() (even though these hopefully will be obliterated from extern/ soon)
* remove reference to docs SConscript
* python dbg commit - somehow this one was left uncommitted when I was working on r23465 and r23464
2009-09-28 15:49:26 +00:00
801d8b600f File paths: use release/ for scripts if possible again, this got
changed with the file path changes, the reason to check this first
is that it allows to edit py scripts without having to run the
build system for each change.
2009-09-28 15:47:05 +00:00
ea41a343c0 Fix #19479: ctrl+N could temporarily freeze the window when user
preferences were saved from a separate window. Missing transfor of
active window state to the new window.
2009-09-28 15:34:15 +00:00
45aedba8e4 Fix #19477: transform manipulator did not work correct with
quad view, got wrong context.
2009-09-28 15:14:52 +00:00
d143627b62 Fix #19468: particle mode crash in transform, when there are
no editable particles.
2009-09-28 14:51:42 +00:00
56e6338d81 Fix #19453: rendering with mesh in edit mode would put the object
partially back in object mode, disabling e.g. X delete.
2009-09-28 14:40:37 +00:00
c1b32e850f Fix #19351: items in outliner disappear prematurely. Note icons
still disappear too soon, but this is an issue in the icon system,
same happens on all buttons, will have a fix for this later.
2009-09-28 14:33:38 +00:00
8563115e8c RNA
* Move mesh API functions to mesh_data.c, would like to keep
  RNA layer fairly thin, any non-trivial functions shoud be
  in their modules.
* Replace mesh.create_copy by generic id.copy.
* Fix #19250: Mesh.add_geometry() in editmode fails silently,
  now gives an error.
2009-09-28 14:28:45 +00:00
04fdec2017 svn merge -r 23207:23528 https://svn.blender.org/svnroot/bf-blender/trunk/blender 2009-09-28 13:05:03 +00:00
18e54b1ee8 missing Del key in the keymaps where Xkey was used 2009-09-28 12:33:52 +00:00
8f07d27de7 add temp defines to keep the game engine building, should be fixed properly.
fix implicit declaration too.
2009-09-28 12:20:56 +00:00
0356b92d46 File Browser fixes:
* The code to draw only visible items was not working, giving slow
  performance with many files (bug #19469).
* Fix detailed list display on non-windows, would give overlapping text.
* Fix folders with many files not displaying all items, changed short to
  int in various places, was overflowing.
* Recreate layout on area resizes, file view gets out of sync otherwise.
* Workaround for v2d height not being correct with image display due to
  scrollers.
* Fix view2d code to compute minimum scroller size, this would make the
  scroller go outside of its bounds.
2009-09-28 12:10:23 +00:00
996c767071 jpeg2000 presets were broken. 2009-09-28 12:10:13 +00:00
ff780c36e1 Compile fix for GameEngine 2009-09-28 11:29:07 +00:00
82198721d6 Raycounters fix 2009-09-28 10:25:12 +00:00
7d2fd5449e Durian Feature Request: Rotation Modes for Objects
This (biggish) commit generalises the rotation modes functionality added for Bones, allowing Objects to use the various Euler Rotation orders, Axis-Angle, and Quaternion rotation representations.

I've also cleaned up the nomenclature of the rotation-related settings so that the naming styles are more consistent with each other. Unfortunately, this will break all files involving object or bone rotation animation made in 2.5 versions (2.4x will still get correctly converted).

General Notes:
* By default, Objects still default to using Eulers, while Bones will use Quaternions by default still.
* I've fixed all areas that I'm currently aware of to work with these changes. However, there are probably a few places where I've missed a few changes (i.e. auto-keyframing will need attention later).
* Removed the old "IPO-Keys" stuff from Transform code. I'm unlikely to restore this in the near future, and trying to fix that to include support for this commit would have been too much work.
2009-09-28 10:19:20 +00:00
273544fbf0 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r23427:23428
[#8358] Performance regression with raytraced refraction (from Matt Ebb)
2009-09-28 09:59:21 +00:00
981afef08e Fix #19470: displaying depth pass could crash, conversion from
float to byte was not working correct.
2009-09-28 09:06:28 +00:00
ea187e54a8 Fix #19482: setting cursor position in uv editor was not correct
zoomed in, needed to make view2d offset for pixel rounding dependent
on zoom level.
2009-09-28 08:52:02 +00:00
92ee7ca946 remove warnings, print errors if bpy_ops.py or bpy_sys.py fail to import 2009-09-28 05:02:09 +00:00
dab61acd45 Added "scripts/modules" as permanent module search path.
- added bpy.sys as a python module - with bpy.sys.expandpath()
- moved bpy.ops into scripts/modules
- moved autocomplete into its own module from space_console.py
2009-09-28 04:29:01 +00:00
8ea2904693 added missing notifyer/depsgraph call to loopcut, fixed tweaking the edge slide operator in the last operator panel, and uncommented a line in the remove doubles op that was making it not work (and tweaked the rna limits a bit there, too). 2009-09-28 03:28:28 +00:00
2d797f35d8 - removed 2.4x release/scripts
- moved release/io and release/ui into release/scripts/io, ui
- updated scons, cmake, make

When porting 2.4x scripts back, use a command like this so as not to loose the commit history...
 
 svn cp https://svn.blender.org/svnroot/bf-blender/branches/blender2.4/release/scripts/raw_import.py release/scripts/io/import_raw.py
2009-09-28 03:19:52 +00:00
0cbc87b428 Speed optimization in itasc when with armature with many bones and few targets. Thanks to Brecht who pointed out a simple but efficient optimization in SVD decomposition. 2009-09-27 16:20:42 +00:00
2fef3dbaa3 2.5 Layout Files:
* Some Code and Whitespace Cleanup.
2009-09-27 11:00:35 +00:00
6e0c1cd4e5 RNA + Animation:
* Added missing RNA wrapping for Scene -> AnimData
* Fixed bug (with temp-fix) where sequence strips with no names couldn't be animated properly. Currently, this will just use the index of the strip, although that is likely to be mutable (adding/removing strips will change it).

* Removed some old unused code from action.c
2009-09-27 09:38:13 +00:00
4363132788 Added Image.get_abs_filename() and updated scripts to use it. This removes the necessity of bpy.sys.expandpath().
Added missing Object.dupli_list.
2009-09-27 09:19:29 +00:00
bd7dc77884 Bugfix: Shapekey NLA Tracks were shown mixed with the ones for Objects 2009-09-27 06:27:45 +00:00
8a6d6a33f8 Animation Editors - Moved the code for drawing the filtering toggles into a single function. 2009-09-27 06:14:42 +00:00
fbfa8d2f81 2.5 - Assorted Animation UI/Editing Tweaks
Main Feature:
* It is now possible to choose which AnimData block is the 'active' one for editing, and/or select them too. AnimData blocks are generally the dark blue and lighter-blue expanders (i.e. Scene, Object, Camera, Lamp, Curve, Armature, etc.)

* Objects are no longer selected/deselected when AKEY is used to toggle selection of channels. This was getting a bit annoying. 

* Following on from selection of AnimData blocks, it is now possible to select/make active an AnimData block in the animation editors, and change the active action for that block via the 'Animation Data' panel in NLA Editor's properties region.
--> Be aware that user-counts are not totally handled correctly there yet, so some funky behaviour might be seen...
--> It is possible to assign a new action, or to assign an existing one, allowing to switch between actions as in the past with Actions/IPO Editors...

Other tweaks:
* Some code tweaks towards making the 'Euler Filter' feature for Graph Editor working sometime soon
* Added some backend code for snapping the values of keyframes to a single value. Still need to work out some UI for it though.
* Shuffled the code for ACT_OT_new() around, and removed the poll() callback so that it worked in NLA too.
* Fixed some more notifier bugs with deleting bones and a few other editmode operations for Armatures.
2009-09-27 04:22:04 +00:00
69995bb1b3 Sound:
* Threading buxfix letting MSVC Debug builds crash because of corrupted std::lists
* Adopted two property ranges
* Changed the mixdown volume to set the device volume instead of the volume of every sound.

I also removed the private redefinition of m_logicmgr in SCA_BasicEventManager, which was already defined protected in the parent class SCA_EventManager and thus caused a bug letting GE crash here because of an uninitialized pointer.
2009-09-26 20:03:01 +00:00
7af92d6eff netrender: split off job settings in their own panel. Add button to open up web interface in a browser. 2009-09-26 19:50:59 +00:00
128dba3329 Assorted tiny UI tweaks 2009-09-26 16:43:20 +00:00
903d8231d9 netrender: fix some bugs with job cancellation, remove credits system, add more status report on server, cleanup server error management 2009-09-26 16:22:52 +00:00
da5ff2ca98 Add directives to support multi dir lib. 2009-09-25 22:38:15 +00:00
72c4c9da7a Fixing up Makefiles, its not fully working but its closer...
Kent
2009-09-25 18:47:43 +00:00
aa989c1e83 almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
9f6566c0a5 removed double library entries without realizing I had the BGE disabled, these are needed. 2009-09-25 16:27:12 +00:00
69e47fcb0e WITH_CXX_GUARDEDALLOC was broken since BL_ArmatureObject become a PyObject 2009-09-25 14:26:00 +00:00
38ae41f94e fix for buildinfo on mac's 2009-09-25 13:09:18 +00:00
f49a18f30b Graph Editor: F-Modifiers can now be added to multiple selected F-Curves at once with the Ctrl-Shift-M hotkey.
* All the selected F-Curves will get the same type of F-Modifier added.
* The button in the properties region will still only added the F-Modifier to the active F-Curve though
* For now, there must be an active F-Curve in either case, otherwise the poll() callback fails.
2009-09-25 12:20:31 +00:00
ff7157d6f8 Graph Editor: Drawing + Selection Tweaks
* Deselect all now selects/deselects F-Curves too

* Tangents of unselected F-Curves now draw 'faded' like the curves they belong to. This experimental change is quite subtle, but can be made stronger still if people want.

* Cleaned up some old comments in the code too...
2009-09-25 10:52:29 +00:00
40c175f8f6 modal kaymaps for view3d rotate/move/zoom removed redundant 'view' prefix from these operators. 2009-09-25 10:24:42 +00:00
5eecb2ab48 Warning fixes for ITASC. Also, use <stdlib.h> instead of <malloc.h>,
it works everywhere.
2009-09-25 09:33:46 +00:00
7c9bb3c40a Fix OSX compilation problem with malloc.h in itasc 2009-09-25 07:44:29 +00:00
b8c7910be1 - use pythons time module rather then bpy.sys.time()
- comment poll functions, maybe could check for editable scene later
- importing OBJs imports triangle meshes.
2009-09-25 05:25:44 +00:00
2d22ea1f92 Drivers: Copy/Paste tools for the RMB Menu
Drivers can now be copied/pasted for single properties, allowing drivers set up on one property to be added to a few other properties relatively easily. 

Also, added description strings for the other driver-button operators.
2009-09-25 04:51:04 +00:00
0aa08fce72 still doesn't work but this fixes make clean 2009-09-25 04:25:40 +00:00
314d460eb8 options WITH_LZO and WITH_LZMA for cmake and scons (default to true) pointcache.c also needed to have checks for these defines. 2009-09-25 02:40:10 +00:00
b4f235adc0 Shell script exit values should be non-negative.
Exact error with dash as sh "exit: 12: Illegal number: -1".
The rest are just changes to whitespace and polishing.
2009-09-25 01:59:43 +00:00
5fdb839865 needed for linking with cmake on unix 2009-09-25 01:49:06 +00:00
83c3780d8c Quick tweaks to commonly debated mesh-editing hotkeys:
* Loopcut is now just Ctrl-R. 
The preview will be activated when you do this, and you can just click to confirm as in 2.4x and also like when this was activated from the toolshelf. This is less error prone than having to click at the same time as picking the loop as with the previous hotkey.

* Knife is now just: hold k-key and lmb click+drag to draw a cut line and cut the mesh.
This is more direct than the (rather arcane) Ctrl-X-LMB-drag, and is quite similar to what's done for Grease Pencil now.
2009-09-25 01:43:34 +00:00
558626714e Bugfixes:
* #19459: Shape Keys not Animateable
Shape Keys were missing the appropriate 'path' callbacks.

* #19458: 3D Viewport doesn't refresh when adding new bone in editmode (using Shift-A)
The 'wrong' notifier was being sent. Currently, Armature EditMode only responds to NC_OBJECT|ND_TRANSFORM, which isn't strictly that correct for all cases.

* Alignment code for constraints headers (i.e. enable/disable lumped with the delete constraint button) was causing the delete button to not work anymore. Removed the offending code (it shouldn't have been there to start off with). 

* When object's don't have their own AnimData (i.e. if you only animate the values of some shapekeys), a space is no longer left beside the object's name for a visibility toggle in the Graph Editor.
2009-09-25 01:30:32 +00:00
2060127e1f missing includes 2009-09-25 01:29:30 +00:00
5eb2b4b40d SVN maintenance. 2009-09-25 01:13:07 +00:00
1305715d2d *Added VlakPrimitive (this rayobject rimitive only stores ObjectRenderInstance and VlakRen pointers)
- it difers from RayFace that localy stored the vertex coordinates.
- basicaly this reduces memory usage
2009-09-24 22:55:57 +00:00
Nathan Letwory
ee6cf88d4d * some fixes to have scons/mingw compile the sources too, even with BF_DEBUG=1 and WITH_BF_GAMEENGINE=1 2009-09-24 22:11:35 +00:00
1483fafd13 Merge of itasc branch. Project files, scons and cmake should be working. Makefile updated but not tested. Comes with Eigen2 2.0.6 C++ matrix library. 2009-09-24 21:22:24 +00:00
c995c605f6 netrender: usage based balancer. more useful than credits 2009-09-24 21:05:54 +00:00
Nathan Letwory
ebfc93de21 * explicit cast needed for mingw. 2009-09-24 20:20:43 +00:00
ddb46e12f9 netrender: draft code for cluster usage per job calculations. Eventually, this will be used for load balancing 2009-09-24 19:52:32 +00:00
Nathan Letwory
2a63c4ab7b * fix snprintf error with mingw
* move header guards to the right place.
2009-09-24 19:50:15 +00:00
22d027dcb2 fixed some indentation, and removed
declaration of index in a couple of places because it was
already defined and safe to use the old def.

Kent
2009-09-24 16:18:17 +00:00
a8bb313629 add buildinfo to cmake (no win32 support) 2009-09-24 15:36:00 +00:00
b078503058 imagewrap was using uninitialized vars from do_material_tex
found while looking into a different bug.
2009-09-24 12:27:20 +00:00
be380138f1 Fix for panorama backwards compatibility not working correct. 2009-09-24 12:15:17 +00:00
24128d2e86 mingw - silencing the warnings about '#pragma' warnings being unrecognised or being ignored. This should still work fine for msvc, and other platforms though. 2009-09-24 11:46:17 +00:00
4aade8ad7e fix for [#19437] Console (Python): first run doesn't have the ">>>" 2009-09-24 11:37:33 +00:00
300df49060 Fix #19446: merge operator needs to be undone twice, interface
was still doing undo pushes in cases it was not needed.
2009-09-24 10:46:52 +00:00
813f292fc9 3rd attempt to fix ssize_t problem in MSVC and mingw 2009-09-24 10:41:28 +00:00
f16d2b7eaa fix for middle mouse up events not working with modal keymaps (used for fly mode).
With mouse events event->val started as 0/1 for press/release but later the tweak function made LMB and RMB zero value into KM_RELEASE, somehow MMB didnt get used by the tweak function so was left at 0 and the modal keymap function failed when comparing MMB Mouse ups.

now initialize event->val as KM_PRESS/KM_RELEASE
2009-09-24 10:35:04 +00:00
71027be7f6 Fix more problem with mingw this time 2009-09-24 10:04:43 +00:00
3e59a88450 Fix compilation problem in Windows and update project files 2009-09-24 09:29:59 +00:00
b94ed5d7e4 - cmake/make/scons didnt define INTERNATIONAL when buidling blenfont
- BLF_lang_init used confusing IFDEF's, unlikely this was well tested. Split this into 3 functions for Apple/Win32/Unix, Unix uses BLI_gethome_folder(), cant test others, ideally they should use BLI_gethome_folder too but needs testing.
Possibly each os cant be made to use BLI_gethome_folder and the separate func's can be removed (please test).

- units, hectometers were displayed wrong.
2009-09-24 07:03:18 +00:00
20998fdcfa Use Shift+F for fly-mode (like 2.4x) rather then Any+F 2009-09-24 06:48:03 +00:00
0c68fe3a61 brush curve - use clamped values (0-1) for everything except sculpt which can have positive and negative values. 2009-09-24 01:32:23 +00:00
b82b50417c netrender: load balancer fixes, cancel all jobs button and small html interface changes 2009-09-23 21:46:29 +00:00
6c79d757ac Initial sketch of file access wrappers.
It compiles but does nothing useful yet. The "//" comments are notes to 
remember what to do in each block.
2009-09-23 21:26:24 +00:00
6e941a728a 2 Anim Bugfixes:
* Loading old (2.4x) files with keyframes now inits them properly so that keyframes are tagged as normal keyframes not breakdowns

* TrackTo consraint was flagged wrongly for adding it with a target. This meant that the target didn't get set when using the Ctrl-Shift-C hotkey.
2009-09-23 13:09:09 +00:00
Nathan Letwory
ebbb4ad753 * fixes for compiling with scons/mingw when BF_DEBUG=1. Needs svn up in lib/windows, where I added necessary mingw libs. 2009-09-23 12:10:56 +00:00
762d3ad145 Some UI tweaks as listed by William
(http://wiki.blender.org/index.php/BlenderDev/Blender2.5/Todo/UserInterface)

* Removed panel docking. "It is too easy to do by accident when reordering panels, is very hard to control and use, and has no real benefit."

* Scoll bars have minimum size now, so that the 'thumb' doesn't disappear in long lists.
2009-09-23 11:49:12 +00:00
e2a7168e96 fly mode back as a modal operator view3d.fly
- access with the F key, Ctrl+Alt+F in editmode, View->Navigation menu
- camera, perspective & 4split (perspective view only)
- uses modal keymap, (same as 2.4x).
- bugfix since 2.4x, when flying upside down, turning left/right was inverted.
- bugfix for "Align Camera To View", was using deprecated v3d->ofs rather then rv3d->ofs, fixed for NDof fly too. checked v3d->ofs is only used in readfile.c

Todo
- Warping the cursor removed in 2.5, no way to place the cursor in the middle of the view.
- Adding keyframes while in flymode to record the path is missing.
- Not getting MMB mouse release events (used for pan). need to look into why.
2009-09-23 11:26:16 +00:00
9e110a6d00 A few quick bugfixes:
* Vertex Groups list now has a more normal length (2 rows by default)

* Copy vertex groups button now has an icon

* Pose Sliding tools now allow events which it doesn't process to pass through (i.e. zooming the view now works, and also moving around using the numpad works too)
2009-09-23 07:28:26 +00:00
efa757fd8d netrender. first draft of html master details. Just point a browser at the master's address and port, et voila. Gives a list of jobs and slaves and well as per frame status for each job and access to slave output logs per frame 2009-09-23 01:59:57 +00:00
d987003608 remove rna function convert_to_triface because it uses an internal editmesh function and only the OBJ exporter called this.
Converting to tri's on export isnt very important.
2009-09-23 01:35:45 +00:00
7b1e5f4d8e * Tweak to fix:
[#8358] Performance regression with raytraced refraction

Now shadows are only sampled once in reflections/refractions. For cases where this would be a problem (perfect specular reflection/refraction), the full OSA takes care of it.
2009-09-23 00:53:30 +00:00
930542540a Make edge slide a proper operator
Clean up a couple of things in transform (PET settings, custom data, ...)
2009-09-22 20:16:56 +00:00
986f8a9ea3 SVN maintenance. 2009-09-22 19:09:04 +00:00
a2b3650e92 fixed some edge slide issues 2009-09-22 18:47:28 +00:00
b4ef0c7d8d minor fixes for merge of soc-2009-kazanbas, rev23422
- Use CTX_data_main(C) over G.main
- no need to define object_type_items inline.
- rna_mesh.c - dynamic length array was commented out, not sure why this was needed. Povray and PLY scripts rely on faces having 3/4 verts rather then checking the 4th index is 0 (ok in C, not nice in py).
2009-09-22 17:50:29 +00:00
abb49829ef Manual merge of soc-2009-kazanbas branch:
* copied I/O scripts
* copied, modified rna_*_api.c and rna_*.c

I/O scripts not working yet due to slight BPY differences and RNA changes. Will fix them later.

Not merged changes:

* C unit testing integration, because it is clumsy
* scons cross-compiling, can be merged easily later
2009-09-22 16:35:07 +00:00
d86864027d PyConsole improvements
- Commands from the history wont get modified in-place when you cycle back and re-use them.
- Ctrl Left/Right skip words.
- Autocompletion on a variable that has no alternatives adds a '.'
  'bpy' -> 'bpy.', generally more useful since autocomp again will give the members of bpy

also moved text_check_* functions into BKE_text.h for the console to access.
2009-09-22 16:23:46 +00:00
87f5f194bc 2.5 - Animation Tweaks
* delta-transforms for objects should work again. These were basically extra transforms that could get added on top of the values calculated from animation values.

* Added some skeleton code for fixing paths when some data needs to be renamed.
2009-09-22 11:45:30 +00:00
92145d5950 Changes to allow python to do redraws through the timer operator, a reliable way to test the overhead of the python api (printed to the consoel on exit).
- rename WM_OT_ten_timer to WM_OT_redraw_timer
- added iterations argument to run more then 10 times (10 is default still)
- use report api rather then always calling a popup directly.
- added a new test that draws every region without swapping.
- dont show the info popup when operators are called from python.
- operators called from python now print reports, useful with the interactive console.

 eg. 
>>> bpy.ops.wm.redraw_timer(type='DRAW_WIN', iterations=300)
Info: 300 x Draw Window: 4168.56 ms,  average: 13.8952
2009-09-22 09:12:39 +00:00
3c8d34b94e fixed a crash in edge slide 2009-09-22 09:04:43 +00:00
Nathan Letwory
cea8e6b6ed * ensure mingw toolset is recognised properly for python debug when doing BF_DEBUG=1 2009-09-22 08:57:00 +00:00
b1d4d75aab brought back edge slide. 2009-09-22 08:41:03 +00:00
7ead925ce4 - removed View3D->localview since it wasnt set on entering localview (making many tools fail, add objects for eg.), check localvd instead.
- Accent (`) key now sets all layers (like in 2.4x)
- added Alt+C keybinding for converting object types.
2009-09-22 04:40:16 +00:00
b55919069e 2.5 - Keyframe types are now preserved after inserting keyframes which would overwrite the existing keyframes 2009-09-22 01:27:48 +00:00
9182dc3b8f Fix #19391: quiting BGE could give drawing errors. Blender now restores
the default OpenGL state after exiting the game engine, and also removed
settings the default state on start, since the game engine already does
this.
2009-09-21 21:37:19 +00:00
345169d1fb Updated some colors in node space and file browser to better match the color theme in 2.5. 2009-09-21 21:28:48 +00:00
3448f675cb Fix #19427, problem in blenfont not computing the width of text correct,
particularly text including spaces. This gave some problems with placing
the cursor and selection, and clipping text inside buttons.
2009-09-21 21:26:04 +00:00
d601a51e03 RNA: added a "factor" subtype next to "percentage", and only display
% sign for percentage assuming it is between 0-100, while factor is
for values 0-1.

Move collision setting absorption from modifier to collision settings,
was inconsistent to have it there as the only one, and made it have
range 0.0-1.0 instead of 0-100.
2009-09-21 21:19:58 +00:00
862ddcc0c4 Fix part of #19307: modifier cage button not working as a toggle button. 2009-09-21 21:03:50 +00:00
aae4335b9f Fix part of #19309: editing node vector input in a popup did
not keep it open after changing one of the buttons.
2009-09-21 20:50:11 +00:00
a15ba4f35d * Wrong Property Range for Blur Size_Y. 2009-09-21 19:26:27 +00:00
c8a977db78 Fix #19426: loop select with occlude background geometry did not
work after subdivide operator, needed a check for valid backbuf.
2009-09-21 17:32:25 +00:00
fe27bb6dd4 Fix #19384: missing redraw when changing transform orientation. 2009-09-21 17:00:22 +00:00
b49e4e7bcf Fix #19378: border render coordinates were not RNA wrapped. 2009-09-21 16:51:04 +00:00
6117d9c6e2 Fix #19361: BGE keyboard sensor allowed to set mouse events
too, should only be keyboard events.
2009-09-21 16:39:07 +00:00
04ec0ea190 2.5 Nodes:
* Wrapped Color Key and Blur Node.
* Nodes using RNA properties can be animated. You can now choose if the Nodes Window should be updated while animation playback too. (Timeline>Playback Menu)
2009-09-21 16:21:54 +00:00
8141725342 Fix #19382: crash on uv edit stitch, tweaking limit property in tool area. 2009-09-21 16:08:38 +00:00
34a9f423f8 netrender: more load balancing rules 2009-09-21 16:01:31 +00:00
1e63545a3b Second attempt at fixing #19335: holding down backspace in the
text editor creates squares on some systems. Based on info from
Martin, it appears the keymodifier is being set when it shouldn't.
I think this is happening become some systems may be generating
KM_PRESS events without a matching KM_RELEASE?

Also ignore ascii values 1-32 now instead of 14-32, not sure why
they were included now in 2.5 because they were not in 2.4, but
I don't see a reason to do it. This fixes squares when pressing
e.g. ctrl+b or ctrl+n.
2009-09-21 15:51:29 +00:00
4453dc330f remove OS checks to use BLENDERPATH, apple or win32 should be easy to add now. 2009-09-21 15:47:41 +00:00
b037d280d3 * Removed an unused context callback. 2009-09-21 14:45:28 +00:00
6fc4e2d37f Fix #19425: crash with long filename and rendering full sample. 2009-09-21 14:30:59 +00:00
e2ebb5d9e4 autocomplete poll function wasn't working, added autocomplete in the console header
operator docstrings with newlines and tabs show up as junk in tooltips so just use a single line.
2009-09-21 13:43:11 +00:00
3c5630a63d Fix #19418: file browse button for strip filename did not work,
sequence RNA now also splits up directory and filename automatic.
2009-09-21 13:23:47 +00:00
cdc5fd64e5 2.5 - Keyframes can now be marked as 'extremes' in addition to 'breakdowns'
* Extremes are shown as red/pink diamonds
* I've changed the order of extremes and breakdowns in the code to make for nicer sizing/ordering. This might break a couple of files out there, but it shouldn't be too many.

TODO:
Still on my todo is to make these tags more useful (i.e. less likely to be overwritten by keyframing)
2009-09-21 12:29:53 +00:00
e9ffd12133 bugfix [#19392] Typing help() in the console window freezes Blender
for now set the sys.stdin to None, this gives an error on input() or help() but better then locking up blender.
Would be nice to support for the blender console to be used as a stdin but this isnt so simple.

also quiet some warnings.
2009-09-21 12:23:56 +00:00
d2639e732b 2.5 - Partial Bugfixes for Parenting Objects to Curves (Ctrl-P)
* Path Constraint option (i.e. this creates a follow-path constraint but doesn't actually parent the object to the curve) works now. Fixed a crash here too.

* Follow Path option (i.e. parent the object to the curve, and follow it), is not working correctly yet. Some matrix seems to get set wrongly.
2009-09-21 12:09:00 +00:00
61c79adb8b colorbands could display with no items in the colorband array, letting you set 0 and -1 colorband index. 2009-09-21 10:57:46 +00:00
551ddd1002 Fix #19389: add lamp had no submenu to choose the type. 2009-09-21 10:54:15 +00:00
2379af27d1 tested running the cheat-sheet, found a number of segfaults
pressing escape in the outliner was also crashing (somehow it tried to exit the file selector)
2009-09-21 09:17:14 +00:00
e2e0a864a8 * Added Armature data filter buttons in Dopesheet/Graph editor headers
* Fixed an RNA typo to fix ranges in action constraint
2009-09-21 07:25:48 +00:00
fcab32fa20 * Added AnimData for Armature data, for animating armature/bone settings.
This allows you to do funky things like animating the number of segments in a b-bone.
2009-09-21 06:43:20 +00:00
ad7fab49d4 5 button mouse support from b333rt in IRC with some edits for X11.
Tested in X11 where its fairly confusing.
buttons 4 and 5 are used for the wheel which is well known, but it seems 6 and 7 are used for horizontal scrolling, my mouse assigns the extra 2 buttons to events 8 & 9.

So the X11 events used for buttons called 4&5 in blender are 8&9 in X11.

The mouse buttons can be re-ordered like this once xorg starts (swaps 6,7 with 8,9)
  xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"

Couldn't test Win32, Apple not supported.
If someone wants to add horizontal scrolling its quite easy.
2009-09-21 05:56:43 +00:00
e7abdd7d56 Better unix filesystem integration as documented here
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/Unix_FHS

for scons WITH_BF_FHS enabled an alternative layout eg.
scons WITH_BF_FHS=1 BF_INSTALLDIR="/usr/local"

for CMake just run "make install" after make (CMAKE_INSTALL_PREFIX is used for the base path)

Currently only scripts use both the system and user path correctly, other areas of blender have their own path code inline with lots of ifdefs, needs to be carefully updated.
2009-09-21 03:16:26 +00:00
6c655aa2a7 * Testing removing the click-region-edge-to-minimise functionality
It was getting very annoying, hitting it by accident and having the region disappear. Now, you can still hide the region by resizing it down to zero, or by using the hotkeys (i.e. N, or T in the 3D View).

Perhaps this minimising would be better done in a RMB menu on sub-regions (i.e. like previous Header: top/bottom/hide stuff)
2009-09-21 01:32:37 +00:00
f560eb0c46 New transform input function for joeedh, to be used for edge slide.
Like Vertical or Horizontal ratio input, but along a line defined by two points on screen.
2009-09-21 00:48:36 +00:00
76447ef615 Update condition checks to match user definable CC and CCC.
Also make faster to notice which FIX_NAN_WARN as not been replaced.
2009-09-20 20:21:01 +00:00
b11acc659b Add audaspace search path. 2009-09-20 20:14:34 +00:00
6d4fb84c4e 2.5 filebrowser
* fix crash in autocomplete for very long paths
* allow longer paths in directory button
* added some TODO comments for G.lib
2009-09-20 19:10:12 +00:00
85294c6d7e 2.5 Game Sound:
* Added Sound Buttons for Game in the Scene Buttons.
2009-09-20 18:49:46 +00:00
1de250014d Sound:
* 3D listener now working in GE
2009-09-20 18:35:14 +00:00
3b4410367f 2.5 filebrowser
more bugfixes:
* removed refreshing code at file_init again, causes issues when resizing
* free library in the filelist after use
* make sure directory exists when library file for append/link doesn't exist, so browsing can continue from valid dir.
2009-09-20 18:26:02 +00:00
189263e1d9 Sound:
* Fixed mixdown volume being int instead of float
* Fixed audio muting for sequencer not working
* Added 3D listener settings with RNA (not working in GE yet)
2009-09-20 17:55:03 +00:00
4f6ea2b683 Ghost/Compiz bug:
Sometimes, events for window size or move are sent even when the window hasn't changed. This triggers unneeded refreshes.

As a precaution, we now ignore all such events (eventually, it should be done in Ghost X11, but I don't know that code well enough).
2009-09-20 17:24:56 +00:00
e4a50e3f47 2.5 filebrowser
* fix crash when filebrowser tried to invoke the file_exec or file_cancel in cases no operator was set.
2009-09-20 17:23:57 +00:00
d3e88cb3e0 *fix bone weighting
forgot to call RE_rayobject_done
2009-09-20 16:49:05 +00:00
4b6c61e0a7 2.5 filebrowser
* changed filebrowser operator property "filename" to "path" - fixed two missing operators.
* small cleanup in init of filebrowser
2009-09-20 15:30:52 +00:00
85e529433b 2.5 filebrowser
* fix selection related bugs:
** selection outside filelist would select first item
** border select would enter directory even if more than one is selected
2009-09-20 15:02:14 +00:00
ec8c47f0c0 * UI for recent sound commit. 2009-09-20 14:14:40 +00:00
1185be4355 Sound:
* Moved AudioData back to Scene
* Updated RNA stuff
* Added mixdown volume
2009-09-20 14:00:00 +00:00
7d86e92df9 2.5:
* Wrapped Invert, PremulKey Levels Node, Distance Key, Difference Key and Color Spill.
* Added RNA for Levels Node.
* Small RNA fixes.
2009-09-20 13:34:54 +00:00
2f71b49484 2.5 - Yet another round of bugfixes
* Copy Rotation constraint "should" work ok for custom rotation orders now. It now converts both rotations to the form used by the owner. So far, this doesn't seem to have broken any of the test rigs in my test-suite, though new specimens for the hall of flakiness are always welcome.

* Fixed many RNA wrapping bugs for Armature data. 
- Fixed a few wrong tooltips
- Made proper refreshes for restpose/posed, etc.

* Started converting special quaternion interpolation for Pose Sliding tools (push/relax/breakdown), though this doesn't seem to be working correctly yet. 
-->> Help to get these working right is welcome :)
2009-09-20 12:54:30 +00:00
ad25fc829e 2.5 - More animation/rigging bugfixes
* #19419: PoseLib rename/remove tools could crash when an invalid 
(However, now care is needed when touching that index field, since the warnings can keep piling up)

* Added Browse Poses for PoseLib to the toolbar

* Removing constraints from bones now properly updates. A DAG rebuild is now forced, and the constraint flags are cleared.

* Attempting to improve the situation with Copy Rotation constraint and rotation orders other than xyz. Unforunately, it looks like a different method is required...
2009-09-20 11:21:44 +00:00
2c871f722d 2.5 MSVC projectfiles
* maintenance (added poseSlide.c)
2009-09-20 11:13:57 +00:00
22995e9c45 2.5 - Pose Relax/Push improvements
* Relax and Push are now interactive. Moving the mouse left<->right decreases/increases (respectively) the number of times the pose is relaxed or pushed. The sensitivity on this could be tweaked as necessary.

* Cancelling these 'pose sliding' tools now correctly restores the initial pose
* Autokeyframing is now only done when the operator is confirmed.

--

Also, made 'View persp/ortho' <-> 'View Persp/Ortho' to be more in line with other operator names, but to also make it easier to read.
2009-09-20 05:05:16 +00:00
f4b9ec0e37 2.5 - 2 Armature Related Crash Fixes
* #19397: Properties panel (transform panel in 3D-View) crashed when there was no active posechannel. 

* Breakdown/Push/Relax Pose tools crashed when auto-keyframing was enabled. There where 2 main causes here: 1) laziness to try and avoid having to clear some data everytime, 2) a typo for one of the KeyingSet names
2009-09-20 01:36:11 +00:00
b28109b442 netrender: first draft for job balancer + some minor fixes 2009-09-19 22:11:26 +00:00
8b4ad3584c A few smaller adjustments to armature and bone properties. 2009-09-19 21:40:37 +00:00
f7d8275ddb More Nodes wrapped to Layout Engine:
* Map Value, Alpha Over, Hue Saturation, Dilate/Erode
* RNA fixes and additions.
2009-09-19 19:57:30 +00:00
45089af1b2 Bone constraints are now in a separate tab. It's more consistent
since object constraints also have their own tab, and I didn't
want to break context going from left to right.
2009-09-19 19:40:38 +00:00
01ef3301a8 Fix drawing of armature bone axes, these were not showing labels.
Also unified drawing code for object & particle text, was almost
the same function duplicated, and now also used for bones.
2009-09-19 18:45:31 +00:00
fcbfd29796 Fix combined pose + weight paint mode, was using wrong object
in a few places, missing some checks.
2009-09-19 15:48:47 +00:00
d25ab89ac0 RNA: for last commit, fix paths_location and paths_type enums,
these had wrong DNA variable name already before this change.
2009-09-19 14:16:02 +00:00
645ca520a3 Armature UI
Added the new pose tools in the toolbar.
Changed a few armature values to enums. 

Brecht: The Heads/Tails enum seems to also enable armature.draw_axis, and the paths_type enum affects armature.draw_names
2009-09-19 13:50:24 +00:00
7eb436a6b8 2.5 - More Animation Bugfixes
* Updating Preview Range settings results in correct updates for Animation Editors

* Compositing nodes now correctly animate when the values were set by IKEY/RMB on suitable node parameters. Beware that these nodes are not relinkable node-trees, hence the standard code not working.

* Ctrl-P to parent objects to bones now works in Pose Mode too. I needed to add a special keymap entry for this, though I thought this would have been better to be automatically inherited/present from Object keymap already?
* Ctrl-P -> Parent to Bone option now works correctly again. 1.5 lines of code missing here...

* Breakdowns tool now shows custom cursor during 'modal' phase so that it's not that confusing what's going on.
2009-09-19 12:36:22 +00:00
9710673192 2.5 - Animation Bugfixes:
* Breakdown tool for Poses (Shift-E in PoseMode) now works. Now this works as a modal operator when invoked, with the horizontal movement of the mouse (left to right) corresponding the placement of the breakdown relative to the endpoint keyframes.

* Moving bones between armature layers in Edit Mode didn't work (wrong variable name used)
* Fixed several notifier-related bugs regarding editing armature settings and the 3d-view not refreshing
* Duplicating bones preserves the rotation mode

* Animation Data for Nodes is now show in Datablocks viewer (i.e. AnimData for NodeTrees has now been wrapped)
2009-09-19 11:59:23 +00:00
1ec44f3bb2 compile fix 2009-09-19 01:05:16 +00:00
8ab24bb2c2 2.5 - Pose Enhancement Tools
This commit restores the 'Relax Pose' tool, and also introduces two others: 'Push Pose' and 'Pose Breakdowner'.
Be aware that this commit is just the initial starting point, with some parts yet to be done.

A short description of these tools follows:
* Relax Pose (Alt-E) - makes the current pose more like the poses on either side of it
* Push Pose (Ctrl-E) - exaggerates the current pose
* Breakdowner (Shift-E)[not working yet] - when this works, it will allow for interactive selection of a good in-between pose to act as a breakdown. 

Todo's:
* Connect up the 'percentage' slider in the operator settings to allow these effects to be dialed in/out, exaggerating/relaxing/moveing-between-keyframes by varying degrees until the desired effect is reached.
* Allow these effects to be interactively dialed in/out. The idea is to use the mouse to interactively set the percentage slider value initially, then use the percentage slider to tweak later.
* Figure out why breakdown breaks down
2009-09-19 00:18:42 +00:00
ad07133e53 Add path to find SYS_System.h (which is only included with gameengine).
Reported by Jasper Mine.

Fixed comment, it was away from the directive it explained.
2009-09-18 22:12:29 +00:00
6114de09b5 2.5 Nodes:
More Nodes are wrapped to the layout engine. +a bit code cleanup.

Brecht: please check on greying out, it doesn't look correct. :)
2009-09-18 21:04:54 +00:00
c388244be4 Move some static math functions out of paint_image.c into arithb.c
* VecLerp3f and Vec2Lerp3f - interpolate 3 2d/3d vectors from 3 weights
* AngleToLength(angle) - useful for making even width shell/walls based on the angles of the surrounding geometry from each point. (same method used in 2.4x python solidify script).

also quiet some warnings.
2009-09-18 16:39:45 +00:00
9787a2e55a UI: fix some python errors in sculpt/paint modes when there is no brush. 2009-09-18 15:52:28 +00:00
9435727712 Handlers/keymaps, some tweaks for previous commits:
* Screen keymap is now split up in two, some of the area/region
  manipulation operators here need to be handled before others.
* Moved paint/sculpt/sketch out of the 3d view keymap, these were
  there as a workaround, now with keymap poll no longer needed.
* Also fixes #19297, 3d cursor moves when combing in particle mode.
2009-09-18 15:48:49 +00:00
474378a0e8 VecAngle3_2D, VecAngle2 and VecAngle3 returned degrees, in arithb.c degrees are most common.
- These now return radians
- added macro RAD2DEG(rad)
- renamed VecAngle3_2D to Vec2Angle3 since Vec2* is used in arithb.c for 2D vector functions.
2009-09-18 15:47:00 +00:00
0f25d9bb54 Fix #19381: Switching from sculpt to object mode does not update toolbar. 2009-09-18 13:17:33 +00:00
c67db42e3e Fix #19383: crash pressing image open in texture buttons. 2009-09-18 13:13:28 +00:00
26836bf44f 2.5: Python operators now have a working poll() function,
solved by wrapping all polling in WM_operator_poll and
adding a special callback for python.
2009-09-18 13:02:20 +00:00
854ea35a24 2.5: Handlers are now evaluated in a different order, fixing some
issues like Shift+R (repeat last) not giving capital R in the text
editor. There is also new modal handler list at the window level,
and the API call will always add it to that one now, since modal
handlers were not used in other levels.

The order used to be:
* window modal + keymap
* area modal + keymap
* region modal + keymap

Now it is:
* window modal
* region keymap
* area keymap
* window keymap
2009-09-18 12:43:36 +00:00
ab518939b5 - jitter for painting (image and projection painting, others can be added)
- remove falloff setting now the curve is used.
- bugfix for airbrush & tablet, with no movement it would assume 1.0 pressure.
- rna, use the use_* prefix for brush options.
2009-09-18 11:25:52 +00:00
d56e23afc0 Changed a few mutually exclusive options in preferences to radio buttons (enums) 2009-09-18 07:44:52 +00:00
2a21669e65 curve could return values lower then zero, making a brush add and subtract the color in different parts. (cool but not useful!) 2009-09-18 04:07:41 +00:00
292e695a35 * fix for previous commit, didn't take brush strength into account 2009-09-18 03:47:17 +00:00
fd6654d4ef remove brush_sample_falloff, #if 0, unused function is_tablet_cursor 2009-09-18 03:41:37 +00:00
985031c235 netrender: only one log file for each chunk 2009-09-18 03:29:50 +00:00
bf6f23ff5f * Added notifiers/redraws for brush edits in 3d view and image editor (so using radial control updates tool properties)
* Changed the non-projection paint code to use the brush falloff curve, rather than a predefined falloff. This makes non-projection painting in the 3d view, and image editor painting much more consistent with other brush usage.
2009-09-18 03:11:17 +00:00
a393a9c6f0 same as r23322 in 2.4x
--- 2.4x log
use functions to detect stylus and eraser from the wine project, supposed to work with non-wacom tablets too (searches for wizardpen & acecad as well as 'stylus').
2.4x did an exact check on the name, 2.5 does a case insensitive search on the type.

This does a case insensitive check on both the name and type.

close the devices on exit too.
2009-09-18 02:38:38 +00:00
6a14408664 use functions to detect stylus and eraser from the wine project, supposed to work with non-wacom tablets too (searches for wizardpen & acecad as well as 'stylus').
2.4x did an exact check on the name, 2.5 does a case insensitive search on the type.

This does a case insensitive check on both the name and type.

close the devices on exit too.
2009-09-18 02:36:23 +00:00
b75d2c56c8 * Made image editor paint use predefined left/right mouse buttons rather than action/select, consistent with 3d view painting (and better for tablets!)
* Fixed a small bug in project paint tool ui
2009-09-18 02:19:27 +00:00
08e2da590f Particles cleanup, optimizations and some small new stuff.
New stuff
- Bending springs for hair dynamics.

Code cleanup & optimization
- Disabled reactor particles temporarily for cleanup, it's a clumsy system that will be replaced with something better.
- Removed child seams, something better will come here too :)
- Normal particle drawing data is now saved between redraws if the particles don't move between redraws.
	* For example rotating the 3d view is now realtime even with 1M particles.
- Many random values for particles now come from a lookup table making things much faster.
- Most accessed small point cache functions are now much faster as macros.
- Lot's of general code cleanup.
- Nothing big should have changed so if something doesn't work like it used to it's probably just a typo somewhere :)
2009-09-17 22:00:49 +00:00
69e919530e Keymaps now have a poll() function, rather than adding/removing
their handlers based on notifiers, which is simpler and more
reliable.

This fixes for example editmode or uv edit keymaps not working
when creating a new 3dview or image space.
2009-09-17 21:36:02 +00:00
b572ae2a8b netrender:
Disable windows' blocking crash reports in child process. (windows only)
Get server port as well as ip address from master broadcast (broadcast is on a fixed port).
2009-09-17 18:40:37 +00:00
bf34328634 Forgot to delete unused code. 2009-09-17 17:44:54 +00:00
a133907c92 -Shuffled some user prefs around to make better use of the available space in Preferences.
-Temporarily disabled the Themes tab until we figure out how to manage themes properly.
2009-09-17 17:42:08 +00:00
a08b16436d 2.5: Adding a crop node caused crash, wrong layout deceleration was used. 2009-09-17 17:31:50 +00:00
613a034b45 -Added Loop Cut to toolbar
-Adjusted some UV Editor panels slightly
-Made a few nodes clearer. The Crop node was especially confusing.
2009-09-17 16:47:04 +00:00
77446c59e9 backport Nicholas Bishop's 2.5 commit from r22581, stylus fails on ubuntu 9.10 without this. 2009-09-17 16:17:32 +00:00
064569c52e building scons blenderlite would fail when building the player 2009-09-17 15:35:25 +00:00
91e5ac872e Wrapped some more Nodes:
* Composite: Flip, Crop, Map UV, Lens Distortion.
2009-09-17 15:06:03 +00:00
fbbda4c06e Warning fixes for blenkernel and editors.
Note sure what to do with this one, and personally think
we should avoid using macros for this kind of thing:

V_GROW(edges);
source/blender/editors/mesh/loopcut.c:232: warning: value computed is not used
2009-09-17 14:46:22 +00:00
09652d8c05 Fix #19371: vertex group dropdown crash, own fault in commit yesterday. 2009-09-17 14:37:08 +00:00
7783c286b9 UI: fix display of shape key list to show with no items,
list template should also accept None.
2009-09-17 14:35:08 +00:00
5e609c9c52 * converted raytrace visibility test on meshlaplacian.c to new raytrace API
I need test scenes and test instructions to make sure this is ok, since i have no idea how to test this feature.
2009-09-17 12:56:16 +00:00
a911fd88af Update MSVC project files. 2009-09-17 11:17:49 +00:00
68f4465cdc 2.5 - Animation Utility Function
Added a utility function to check which transforms for an object or bone are animated, returning these as bitflags and/or optionally retrieving the relevant F-Curves too. Beware that this method may not be working correctly yet, but it shouldn't hurt anyone in the meantime :)

Also, split RNA-path building function up into a version which only creates the path up to the given struct, with the other parts being added later.
2009-09-17 10:14:56 +00:00
1934ee422a rna function api was overwriting useful errors with keyword errors.
fix some missing checks in the python interface.
2009-09-17 00:14:47 +00:00
4a15b40c37 * fix compilation on osx 2009-09-16 22:27:27 +00:00
00f9bf51d6 bugfix for LineIntersectLine()
- was imperfect calculation for points marking shortest distance for non-crossing lines in 3d
2009-09-16 22:13:48 +00:00
591a30dab0 bugfix for LineIntersectLine()
- was imperfect calculation for points marking shortest distance for non-crossing lines in 3d
2009-09-16 22:12:23 +00:00
90d8088e53 2.5:
Test Commit, converted Filter Composite Node to use layout engine. :)
Will do other Nodes in the next few days.
2009-09-16 20:07:05 +00:00
f26ac206c9 *Changed image field order property to enum, making it consistent with the corresponding render option
*Tiny edit to image panel.
2009-09-16 19:58:01 +00:00
6e4d4a8a12 fix bugs with file transfer 2009-09-16 19:47:58 +00:00
b6c6610630 UI
* Removed some legacy code which is not needed anymore now.
* Move some test_*poin_but functions to logic space code,
  since that's the only place using it still.
* uiIconFromID now uses RNA info to lookup the icon, to avoid
  code duplication, and means it works for more ID types.
2009-09-16 19:36:17 +00:00
21e2f27532 Tiny fix for mistake in toolbar. 2009-09-16 19:27:23 +00:00
f8abfce7ce Image Panels
* The image panels in the image editor and texture buttons
  should be more complete now, with working new/open,
  refreshes, and using the layout engine.
* Paint panels in image editor are now consistent with the
  ones in the 3d view toolbar.
* Curves panel also uses layout engine, and doesn't look
  squashed anymore.
2009-09-16 19:27:08 +00:00
5129b08064 UI
* Node buttons can now use the layout engine. a few simple
  ones are converted. We'll keep this code in C for now,
  python wouldn't help much here.
* For node buttons not using the layout engine, manually
  computing the button height is not longer needed.
* Node inputs are still not RNA wrapped, would be good to
  have these available as well for keying, but makesrna does
  not have access to the bNodeTypes.
2009-09-16 18:59:13 +00:00
3a6bf17b3e UI
* Fix problem with curve mapping / color ramps not updating
  things like previews propertly. Now it uses the RNA update
  of the pointer from the material/texture/.. so each of those
  can define their own update, but still share the RNA struct.
* Code for these templates is now in interface_templates.c
* Fix exception for "axis" property, now it always shows normal
  widget with the PROP_DIRECTION subtype.
* Remove context from uiBlockLayoutResolve, no longer needed.
2009-09-16 18:47:42 +00:00
de59f34be0 UI: action editor header now also uses template for browsing action
datablocks, was last place using deprecated uiDefIDPoinButs.
2009-09-16 18:32:10 +00:00
6b5ce9366d Fixed Resolution and Aspect Ratio Notifier for camera mode in 3D View.
NC_OBJECT, won't do it alone, added ND_DRAW.
2009-09-16 18:32:03 +00:00
e0d36b73a1 #19317:
Some more missing notifiers for the "2 open properties windows" scenario. Scene Buttons should be fine now.
2009-09-16 18:22:53 +00:00
4596f0ee5e File Browser
* Fix warning for non-existing "relative_paths" property.
* Fix problem where the image browser would keep trying to
  load images it failed opening.
2009-09-16 18:07:49 +00:00
6156248051 UI: fix region edges cursor to show the right direction,
was always vertical now.
2009-09-16 18:05:28 +00:00
feff78170d RNA
* PROP_NEVER_NULL is now a flag instead of a subtype.
* It works for function parameters too now, so setting
  this flag can help avoid NULL checks in the function.
* Renamed LocalLamp to PointLamp, making it consistent
  with the UI name.
* Set icons for the different lamp struct types.
2009-09-16 18:04:01 +00:00
6b5ba70059 2.5 Ghost Compile Fix for windows. Patch by b333rt. Thanks! 2009-09-16 17:13:03 +00:00
7c5695c801 - bpy.data.sounds was a collection of ID's rather then Sounds
- last commit, missed include for rna_object_api.c & bad args to find_basis_mball
- use enum for GHOST tablet type None/Stylus/Eraser, had duplicate definition for these in C. Only tested X11, may need to cast to an int for other OS's.
2009-09-16 15:55:00 +00:00
b5b0a62c97 netrender: default temp path on windows to something more useful 2009-09-16 15:00:35 +00:00
9fea9d065d 2.5: fix bug in Levels node, giving NULL pointer free warnings. 2009-09-16 14:45:10 +00:00
42af96ed42 use platform.uname instead of os.uname (suggested by Carsten on the ml), it's more portable 2009-09-16 14:02:01 +00:00
103e11359d - rna/python api object.create_render_mesh(...) support for getting a mesh from metaballs and curves (bevel, surface, text etc).
- povray converts curves to meshes on export, (metaballs don't need meshing).
- use 'extend' bool rather then 'seltype' enum for object_select operators for consistency.
2009-09-16 10:09:57 +00:00
e03b8b7be7 loopcut tool. hold down ctrl-r, then leftclick. due to current limitations on operator design, there isn't any built-in edge sliding to this tool. 2009-09-16 09:55:06 +00:00
cc100eadc5 Operator cheat sheet (from the help menu)
writes all operators (including PyOperators) and their default values into a textblock.
Useful for an overview and checking consistancy.

eg. http://www.pasteall.org/7918/python

added rna functions text.clear() and text.write(str)
2009-09-16 06:02:56 +00:00
8df1bb99f9 * enable high res smoke rendering in voxeldata texture 2009-09-16 03:10:25 +00:00
51f1e82290 Object mode Selection options brought back for view3d.select
- 'center', while Ctrl is held select objects from their center location
- 'enumerate', while Alt is held, give a list of objects under the mouse
- Object selection menu now uses icons with names
- operator object.select_name(name, extend=False)
- keybindings so combinations of Ctrl/Alt/Shift can be used (like in 2.4x)
- logic text input field was using deprecated ID_SCRIPT rather then ID_TXT

details
- added comments to DNA_ID.h ID types
- removed unused ID types Sector and Life
- added uiIconFromID() to get an icon from the object.
- using name for selection is weak but currently there isnt a really good way to do this.
2009-09-16 01:15:30 +00:00
be613fd9dd OSX should use libsndfile in /lib, not /usr 2009-09-16 00:59:55 +00:00
0befb9b01d Sync names with real content. 2009-09-15 23:37:20 +00:00
581cb64f2c Make verification of committed .mo files optional. 2009-09-15 22:34:10 +00:00
063d806f15 2.5 filebrowser
bugfix #1: SpaceFile->files needs to be deleted on exec and cancel of the filebrowser and in init to ensure correct setting of the read function.
bugfix #2: SpaceFile->params needs to be set in file_init otherwise Python can't access params in header ui.
2009-09-15 20:47:34 +00:00
22274d3807 More automatic stuff.
Server can now be set to broadcast on local network (every 10s, approximately 20 bytes of data) where client and slave can pick up its existence. This is on by default.

Default ip address is now "[default]", which means for the master that it will listen to all interface and for the clients and slave that they will automatically work out the master's address from its broadcast.
2009-09-15 19:53:18 +00:00
816377cc02 Undo revision 23130 which was a merge with 2.5, a messy one because I did something wrong (svn status output: http://www.pasteall.org/7887).
The command: svn merge -r 23130:23129 https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-kazanbas
2009-09-15 18:01:18 +00:00
fd664970f1 Completely move freeing flag to report, operator flag is uneeded.
Also bugfix for py operators. Reports need to be kept alive when operator is registered.
2009-09-15 16:25:53 +00:00
0a8fa9ff70 Smoke:
* This should make low res bake too if high res gets baked
2009-09-15 16:05:59 +00:00
c8dfa6071d svn merge -r 22571:22800 https://svn.blender.org/svnroot/bf-blender/trunk/blender
svn merge -r 22800:23207 https://svn.blender.org/svnroot/bf-blender/trunk/blender

Merged volumetric with new raytrace code (it compiles and rendered volume-cube.blend withouth problems)

Part 2:
	everything except source/blender (merged on part1)
2009-09-15 15:34:00 +00:00
f7c686d0ae svn merge -r 22571:22800 https://svn.blender.org/svnroot/bf-blender/trunk/blender
svn merge -r 22800:23207 https://svn.blender.org/svnroot/bf-blender/trunk/blender

Merged volumetric with new raytrace code (it compiles and rendered volume-cube.blend withouth problems)

Part1:
	source/blender
2009-09-15 15:15:43 +00:00
971e984b08 Update MSVC project files 2009-09-15 13:28:36 +00:00
e6b5a2e99e UI tweaks
*Cleaned up Transform panel in n-key area. It's now single column so that this view can be nice and slim, while you can still access everything. 
This is especially important in edit mode where you cannot change the transform values numerically from the Properties. 
Transform properties don't seem to work for Metaball edit yet, so wasn't able to test this

*Removed some lingering tools in curve transform and put them in the toolbar instead.

*Improved alignment in toolbar

*Made Image Properties use regular checkmark toggle buttons

*Added Delete as an alternative to X key, as it was in 2.4x
2009-09-15 12:45:05 +00:00
499e6f0067 2.5: node group/ungroup/edit operators, patch by Michal Ziulek,
with some small changes.
2009-09-15 11:35:10 +00:00
8513ab471c didnt change all filename's to path's 2009-09-15 10:59:42 +00:00
daa968df22 - opening the file selector was freeing a NULL pointer
- some warnings in last commit.
2009-09-15 10:52:36 +00:00
c8618348e0 Smoke:
* Less verbose
* More OpenGL error messages (on blender -d)
2009-09-15 10:26:36 +00:00
9a2cd02ae4 UI: renamed 3dview menus to be lower case, not too important now,
but once these become extensible we need consistent names.
2009-09-15 10:23:44 +00:00
689b77ba9d - new property attribute - default_array, which returns a variable size array useful to get the defaults for operator & function arrays.
- updated python api to check for array types rather then the length since a variable length array can be 1 or 0 length.
- python docgen added .0 to the end of floats which messed up values like 1e-05
2009-09-15 10:01:20 +00:00
223bc8aee1 * Added RNA path functionality to fluidsim modifier settings, to allow keying of fluidsim settings properties.
Note: Although the properties can be animated with the RNA system, the values are not exported to the actual fluid sim yet, that can come later.
2009-09-15 03:54:13 +00:00
aa8163e399 Revert endianess test to 2.49 style.
Reported by jms.
2009-09-14 23:00:58 +00:00
41ed712ea3 Smoke:
* Bugfix for non working 3dview

Credits: Thanks to Wahooney, jesterKing and a big thanks to Matt/broken for hunting this down!
2009-09-14 22:27:10 +00:00
524a8e32b1 Smoke:
* Fixing compile warning
2009-09-14 21:55:48 +00:00
be69305d85 2.5 Bugfixes
#19302: the spin operator did not redo correct when changing properties.
Actually the problem was somewhere else, the search menu always did an
unnecessary undo push, which conflicted with an operator undo push with
the same name. Only in the case of "Spin" was this noticed, because it's
name is so short and you actually type it completely.
#19328: swapping areas could crash when dragging mouse outside the window.

Attempted fix for #19331, #19335 as well, where backspace and some other
keys give square characters instead of working as expected. Couldn't
reproducable here, so please test.
2009-09-14 20:48:05 +00:00
1b2344a1f1 Also set utf8 encoded hint for window title. 2009-09-14 20:17:56 +00:00
f302ebeb67 2.5 Bugfixes
#19343: vertex paint blur was not working. shared vcol was disabled
for speed, but blurring still needs it. Also fixed brushes with
size > 64 not working correct.
#19314: non-zbuffer selection did not work with background image,
drawing it made the WM matrix go out of sync.

Forgot to mention these in previous commit:
* Manipulator type was not properly initialized, .B.blend update helps,
  but still needed version patch & correct setting for new space.
* Added a utility function for the toggling region hide, instead of
  duplicating the code.
* SSS preview render preprocessing pass now also uses multiple threads.
* Added version patch for unit scale, was still 0.0.
2009-09-14 19:49:40 +00:00
725c30f606 2.5 Bugfixes
#19345: can't get out of grayed out pointer field.
#19342: item_pointerR fields can't be cleared with one item.
#19341: fix hanging tooltips when manipulating regions.
#19339: context panel still allowed tabbing, but it has no header.
#19334: editing SSS settings crashed previewrender.
#19330: object mode could not be switched on from the header menu.
2009-09-14 19:12:29 +00:00
c6107e0c76 Smoke:
* Only simulate smoke when starting from startframe
2009-09-14 17:22:51 +00:00
bee18c57d4 fix warning 2009-09-14 17:13:58 +00:00
ba5df38d66 use static functions where possible for some local functions. 2009-09-14 16:52:06 +00:00
131c713fc1 Smoke:
* Fixing some gcc warnings
2009-09-14 16:46:34 +00:00
cd211af417 Smoke:
* Introduce a better check for fragment support
2009-09-14 16:43:13 +00:00
b3c4952178 netrender: add "Animation on network" button to send job to master and gather the results in one step. 2009-09-14 16:30:53 +00:00
a3ce413f44 Bugfix with py operator api and modal operators. Modal operators would keep a reference to Reports locally allocated in the api functions, which would crash and burn later when the operator would actually stop.
This commit introduces a flag at the Reports level that can be used to indicate that it needs to be freed (on top of the flag already existing in the operator, which I guess could be removed).

Reports for operators called through python are only persisted if they indicate that they are running modal.
2009-09-14 16:00:42 +00:00
c8af263e5d Reverted Mesh.verts from dynamic array since it breaks foreach_set used by import scripts.
Did a few fixes in scripts to reflect recent RNA changes.
2009-09-14 14:55:49 +00:00
733b20f695 *Changed texture blend property Flip XY to a proper enum.
*Minor adjustments to lamp UI

*Fixed issue #19319 (missing notifier)
2009-09-14 13:31:58 +00:00
4539bb9a98 Link/Append, small changes:
* Added separate menu items for Link and Append.
* Change some OPERATOR_FINISHED to OPERATOR_CANCELLED.
* Remove some IPO specific hacks, these are no longer ID blocks,
  so not necessary to take into account.
* Some comment and code formatting tweaks.
2009-09-14 12:30:49 +00:00
6cee5201ec Third widget commit ;)
Thanks to Broken for finding the bug.
2009-09-14 12:28:59 +00:00
8d3955c28d Depsgraph:
* Move function to compute visible screen layers to BKE.
* Use this now in the depsgraph, was still using this all layers
  to flush. Still missing a way to get the current scene in
  background mode..
* Also two more function to not require a scene pointer anymore:
	* DAG_object_update_flags is now DAG_id_update_flags.
	* DAG_ids_flush_update is now available next to DAG_scene_flush_update.
2009-09-14 12:26:34 +00:00
75d4a836b8 UI: don't hide Object menu in 3d view header when there is no
active object, to avoid buttons jumping too much. Also small
change in collision panel code.
2009-09-14 12:16:35 +00:00
d0aa03737e * Fix for typo in icon_only commit, causing RNA property buttons text to be doubled up
brecht: I think this is right now...? :)
2009-09-14 11:25:33 +00:00
e838af4d57 Bugfix #19337: Crash when tweaking knife operator
Knife operator now doesn't crash, but repeat operator for this won't work now since the appropriate 3D-View context info is not set when the mouse is in the Tools region (i.e. when using repeat operator in the tools panels).
2009-09-14 11:12:44 +00:00
f896b905ac Bugfixes:
* #19338: Crash when using Convert operator
Uninitialised var (basact)

* Spacebar when in 3D-View EditMode for Text gets overridden by Search Menu. I've tried adding a fix there, but it doesn't seem to work. Woraround for now is shift-space for entering text.

* Fixed some compiled warnings in wm_operators.c about naming of var named 'main'
2009-09-14 10:56:40 +00:00
b0a3224d89 Smoke:
* put another drawing method in to test for broken
2009-09-14 10:37:13 +00:00
ce70ed260b Smoke:
* Bugifx for no shadow on startframe when loaded from cache
2009-09-14 10:21:41 +00:00
0338b05a64 Three node selection operators added, patch by Michał Ziułek, thanks!
* Select all
* Select linked to
* Select linked from
2009-09-14 08:47:13 +00:00
cbb9815b0d updated .b.blend; show toolbar by default now, made the view3d clip start saner, and turend on grab manipulator 2009-09-14 08:38:04 +00:00
48732cf017 knife 'mode' is now leftclick with ctrl-x held down, instead of ctrl-alt 2009-09-14 07:33:00 +00:00
1b446d2902 to sphere transform hotkey is now alt-shift-s, since ctrl-shift-s was taken by save as. 2009-09-14 06:59:37 +00:00
84e17862cd * boundbox display option was missing from object properties 2009-09-14 06:31:20 +00:00
894c1e98ad remove doubles uses an operator property for the merge distance. it no longer reports number of merged verts to the user, as this violates operator nonmodality and messes up last operator panel workflow. 2009-09-14 06:06:01 +00:00
a11ef8030a 2.5 mesh cleanup: merge tools all work again 2009-09-14 05:00:03 +00:00
9f5e42ff76 Smoke:
* Totally new try to get cache running
* Didn't try "bake" and such things yet

Hint
* Very verbose yet
* Please do only test new blend files, not old ones!

Please give me feedback on my blog about the old crashers.
2009-09-14 00:01:08 +00:00
cf20399993 Pointcache:
* reset on object transformations
2009-09-13 23:58:03 +00:00
ccf847585d Make compiler easily to override (CC & CCC) and clean up whitespace. 2009-09-13 22:34:47 +00:00
492f6589c4 New 'icon_only' wasn't actually exposed in the ui api, causing errors in the py scripts, so I added it to ItemR. Also reverted Joshua's temporary fix, which didn't seem to help much and was making the render engine menu too small. 2009-09-13 22:33:47 +00:00
a4532b202b Prepare for removal of FFMPEG from extern.
make clean and full rebuild recommended.
2009-09-13 22:08:27 +00:00
7e7a6a193e *Changed some userpref options to enums.
*Tweaked curve UI slightly.
2009-09-13 21:36:24 +00:00
f8657be654 *Ray counters (number of BB/primitive tests/hits and other raytrace counters) can now be enabled/disabled at compile-time.
#define RE_RAYCOUNTER (/source/blender/render/extern/include/RE_raytrace.h)

*Some other small organization on code

(will be disable as this only matters for testing and developping)
2009-09-13 20:59:25 +00:00
529e021a1f BGE bug #19294: applying torque on a dynamic object turns it into a rigid body. 2009-09-13 19:39:04 +00:00
be7eeb888a Sculpt UI
*Changed Sculpt Modes Flip Direction to an enum so that you can explicitly choose Add or Subtract.
*Expanded the sculpt tool list. I realize Nicolas has a longer term plan for the brush tools, but at least now it's useable again.
2009-09-13 19:37:51 +00:00
334fefc12a == FFMPEG ==
fixes 2.4-branch according to trunk:

update anim->curposition even if video frame decoding failed.
Fixes nasty issues with DV-decoding on broken frames.

Also: cleans up color conversion a little bit.
2009-09-13 19:22:36 +00:00
8c6176b846 use Py_SetPythonHome rather then setting environment vars PYTHONHOME and PYTHONPATH 2009-09-13 18:09:13 +00:00
d47e1fee32 == FFMPEG ==
This fixes the underlying problem of the DV crashings - within blender
code. 

Problem was, that we tried to seek on decode errors. (Unintentionally,
curposition wasn't advanced in that case). That triggered a bug within
ffmpeg, that made blender crash. My workaround fix for 2.49 actually only
prevented the crash, but didn't stop ffmpeg from only decoding black frames
after that point...

(The patch also cleans up the color conversion a little bit, by using
PIX_FMT_RGBA (still need to find a way to make it work with video files
that actually *have* an alpha channel. At least, latest FFMPEG-SVN swscaler
has the ability to use alpha.)

Looks like we can remove extern/ffmpeg now...
2009-09-13 17:52:36 +00:00
5c6eb9c4fa replace curve.curve_2d True/False with curve.dimensions (2D/3D) enum suggested by William. 2009-09-13 17:38:43 +00:00
e903632c10 after some discussion, this is the replacement for the old loopcut tool: edge ring select displays a preview of the edge ring, and you can move the mouse with ctrl-alt held down and change the edge ring selection. 2009-09-13 16:15:26 +00:00
4c92ca02f7 Update project files 2009-09-13 15:23:50 +00:00
cfc8d66ab0 Smoke:
* Report console error if gfx card does not support smoke drawing
2009-09-13 13:39:06 +00:00
716953f0c1 Pointcache / Smoke:
* Disable "step" setting for smoke on GUI
2009-09-13 13:38:23 +00:00
06a2ee4afe Smoke:
* Making edge and vertex arrays local to avoid problems
2009-09-13 12:35:35 +00:00
ca986a6874 2 Animation Fixes:
* Auto-keyframing for Paste Poses and PoseLib works again. Unfortunately, it doesn't take into account whether the transforms were changed or not...

* 'Stick to View' setting for Grease Pencil has now been inverted, since the old order was confusing.
2009-09-13 12:34:00 +00:00
16a7fe1314 Smoke:
* Bugfix for drawing issues when having the domain transformed (editmode + object mode, both were buggy)
2009-09-13 12:32:57 +00:00
78bb6ce034 2.5 filebrowser
* Fix for space init when loading with pupmenu (without operator) - parameters now get reset
* experimental: made new director operator jump directly into renaming
2009-09-13 09:41:00 +00:00
f9694287d9 svn merge https://svn.blender.org/svnroot/bf-blender/branches/blender2.4 -r23172:HEAD
merging now to save confusion later since the changes between last merge and 23172 shouldn't be merged.

brings 2.4 and trunk in sync aside from sequencer edits from Peter.
2009-09-13 08:50:54 +00:00
a917abee89 [#19290] Blender.Load(filename) -> FILE_MAXDIR to FILE_MAXDIR + FILE_MAXFILE and unused argument removed
only changed the FILE_MAXDIR -> FILE_MAXDIR + FILE_MAXFILE part
since its possible scripts use this undocumented arg.
2009-09-13 08:41:13 +00:00
3a62892a95 Patch [#19293] NearSensor: Changing distance and resetDistance from Python did not take effect immediately
from Frank Papenmeier (hodka)
 --- from the submission
Changing the distance and resetDistance Properties of a NearSensor from Python did only take effect, once there was
a collision within the old radius.

Reason:
The radius of the PHY_IPhysicsController was not set to the new values.

Solution:
It is set at the end of the CheckResetDistance function. I moved the relevant code snippet from the Evaluate function
into a new function called SetPhysCtrlRadius in order to avoid duplicating code doing the same thing.
2009-09-13 08:17:22 +00:00
7eea0b647c 2.5 filebrowser
Fix crash when loading old files with filebrowser UI
Partial Fix for invoking filebrowser via spacetype pupmenu: reset directory in filelist
Make paths relative in 'path' return when requested by 'relative_paths' property in operator
2009-09-13 08:08:50 +00:00
2951a845b1 Patch [#19315], Fix for Jpeg2000 alpha channel bug [#19280]
thanks to Albertas Vyšniauskas (thezbyg)
2009-09-13 08:07:15 +00:00
90ea3964fd remove minimal twist from 2.4x, is too much in development which changed in 2.5, better keep in 2.5x then try have them in sync. 2009-09-13 07:35:31 +00:00
b1e418db20 2.5 filebrowser
fix operator property name 'type' was used by sequencer for strip effect type. Changed to 'filemode' for file browser.
2009-09-13 07:00:44 +00:00
69496abf1d Crash Fix: Sequencer Add->Effects->... menu crashed.
Unfortunately, this menu is now empty, but this shows that the sequencer code is probably doing something funky...

http://dpaste.com/92865/
2009-09-13 03:56:30 +00:00
82a7b73d5a 2.5 - UI Bugfixes
* Loading newly saved files (where linked-libs were used) crashed. 
However, libraries still don't get loaded correctly yet for some reason...

* Pointer layout-items now draw without their UI text if their name is set to "" (i.e. text=""), making the ones with icons appear normal. This is kindof a hack, since it would be better to expose icon_only, but this way is less work.
2009-09-13 03:30:51 +00:00
896ada37ac * Gave the region icons a bit more padding for the clickable area 2009-09-13 03:08:46 +00:00
57ec59fb85 Compile fix: silencing warning due to /*.../* in a header
(It's strange seeing/making commits in trunk again after ignoring it as 'inferior' stuff for over a year now XD)
2009-09-13 02:14:41 +00:00
fb599348d3 * Removed the grey overlapping 'region manipulation' triangles.
- They were causing unnecessary visual noise, breaking up the lines of the region edges
- Now you can just drag anywhere on a region edge to resize it, like existing area edges
- To minimise a region, click once on the region edge, or resize it down to nothing. For minimised regions, a (+) icon will appear, which you can click to restore it to the size it was before it was minimised.
2009-09-12 23:56:30 +00:00
26942cd789 Pointcache:
* Flagging object caches as outdated and use PTCACHE_RESET_OUTDATED as reset event
2009-09-12 20:47:53 +00:00
5ac5988448 Bugfix: Append crashed because of wrong parameters passed. 2009-09-12 20:18:54 +00:00
9a25d22326 2.5 filebrowser
Appending and Linking 
* Linking Operator, invokes filebrowser for Append/Link
* Separated the append/link function into three parts:
** BLO_library_append_begin finds main for appending
** BLO_library_append_named_part appends one Object,Group, Material, ...
** BLO_library_append_end actually reads and expands the libraries

NOTE 1:
I also changed the returned properties for the filebrowser operators to the following convention:
"path" - the full path to a file or directory, means what is in directory + filename buttons in filebrowser
"directory" - the content of the directory button in filebrowser
"filename" - the content of the filename button in filebrowser
Usually only path should be required, but in some cases it might be more convenient to retrieve the parts separately.

Ton, Brecht: If you have time to take a look, let me know if anything needs to be fixed.
2009-09-12 19:54:39 +00:00
c1e2e3fea2 As discussed with Campbell on IRC:
Made some UI operators not register themselves in the console. This made macro creation a pain because the operator list would have tons of splits and other UI commends mixed in with actual data manipulation.

Moved Repeat Last from Ctrl-R to Shift-R so it doesn't conflict with loop cut, whenever it is added.
2009-09-12 19:11:34 +00:00
0fb9380b03 - adding nurbs sufraces messed up when adding with both editmode and align to view disabled.
- Vkey was being caught by the vertex paint mode, blocking it for curve edit where it sets the handle type. Now mode keys pass through if they dont apply to the object type.
- set handles had invalid default
2009-09-12 18:52:26 +00:00
5392a90e28 - adding curves didnt work if EnterEditmode option was off.
- adding a curve in editmode now is 3D, if the curve its added in is 3D.
2009-09-12 18:09:59 +00:00
f9eb93bc7b many docstrings from Ron Walker and Luca (mindrones on IRC),
only did a spot check on these, may need adjusting later.
2009-09-12 17:16:12 +00:00
f130f16fef Use curve radius for paths
- use_radius option, off by default for 2.4x files, on by default on new curves.
- curve deform modifiers (think tentacles)
- follow path (parent mode and constraint)
- curve guides
- added back Alt+S to scale point radius
- Mat3Scale and Mat4Scale arithb.c functions to make a new uniform scale matrix.

- TODO, effectors, looks like they have no way to scale from the radius yet.
2009-09-12 16:25:49 +00:00
d16bde417f new struct PathPoint for each path element (replaces float[4]), Paths now store radius and quaternion
Added optional quat and radius args to anim.c's where_on_path(...), currently unused.

also cleanup some warnings.
2009-09-12 14:12:37 +00:00
3f9d3b2a0b commit of mempool 64-bit fix for 2.5-er, trunk as well 2009-09-12 13:27:26 +00:00
e271b03340 simple error in recent arithb.c commit, have Mathutils.RotationMatrix use AxisAngleToMat3 2009-09-12 13:25:38 +00:00
4654520a9f copying 2.5 over to trunk 2009-09-12 12:58:52 +00:00
9f893cbe9c moving trunk to branch 2009-09-12 12:58:01 +00:00
3b2ad838e8 Merge with -r 22620:23107.
Next: update scripts and merge in 2.5.
2009-09-11 18:09:58 +00:00
732bf328c5 Bug fix (layers and some other checks were disabled)
*bug found and isolated by ZanQdo (Daniel Salazar)
2009-09-07 00:58:17 +00:00
64af3a2618 *introduced new method for packing/optimizing trees after building
(this is a generalization of some of the experimental stuff i tried during SoC,
 but only had time to improve a few days ago)
 - it should yield slightly better results
 - the cost model can somehow be tweaked to optimize for diferent trees.

*cleaned up some code
*added counters for number of SIMD BB tests
*added GPL license block on missing files
2009-09-06 19:14:06 +00:00
ea18c6ef0a Code reorganization
-separated vbvh, svbvh, qbvh in diferent files (before the only way to switch between them was at compile time)
2009-08-29 17:24:45 +00:00
aec7f2f2c4 *Changed RayObject_ calls to RE_rayobject to keep consistency on calls
*Moved part of counters code to a separated file (rayobject_raycounter.c)
2009-08-25 20:26:50 +00:00
7220792f18 Various fixes in rna_*_api.c files to remove compiler warnings. 2009-08-19 09:52:13 +00:00
7c786e28c4 Merge with 2.5 -r 22173:22620. 2009-08-19 09:04:49 +00:00
950b770c1e svn merge -r 22371:22571 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-08-17 17:43:49 +00:00
0e3acbaa38 fix raycounters 2009-08-17 17:04:58 +00:00
09042ce9a5 Ported X3D exporter. 2009-08-17 14:29:29 +00:00
cc0dafa627 Addition of some fake nodes to use SIMD even when theres only 3 nodes 2009-08-13 20:35:53 +00:00
cb40f0ff80 Another tree pass during build to increase the number of nodes that have multipe of 4childs 2009-08-13 15:56:24 +00:00
7050a4a6a2 *Bug fix on finding hit on neighbour face (think this is the last know bug)
This bug fix makes the "non-smoothed" faces appear again (just like they do in 2.49 and blender2.5)
Meaning the "detect neighbour faces" isn't working 100%.
2009-08-13 12:23:21 +00:00
44ddff5c51 - 3ds importer working (without the "scale to size" option)
- changing object.matrix now updates object.loc/rot/scale
- added bpy.data.add_lamp()
2009-08-13 11:14:06 +00:00
6a056e4717 - converted 3ds exporter to 2.5 API
- added Object.is_visible() RNA function to determine if an object is on the visible layer of active scene
2009-08-12 16:37:05 +00:00
c101d58d42 *Instance support is only enabled if target mesh uses more than 4 faces
if theres very few faces its not worth it to create a separated tree for beinng reused.
	should speedup some particle renders.

This "fixes" a bug relationed with a arithmetic precision on instances and raytrace of very close objects
which usually happens on rendering (almost) overlapping alpha-enabled leafs/feathers
2009-08-12 02:00:44 +00:00
eff93b099d Fix ray_trace_shadow_tra 2009-08-11 18:43:55 +00:00
495ef8a6a2 fix instance support when using SIMD 2009-08-11 17:28:58 +00:00
27da1ec383 svn merge -r 22364:22371 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-08-11 13:26:31 +00:00
f88eb78baf svn merge -r 22138:22364 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-08-11 12:55:50 +00:00
5d40c1b597 *Added a tree structure with a variable number of childs per node, but with groupped childs (for SIMD)
*SIMD support for the first 4*N childs of each node
*Some bvh code organized
2009-08-11 00:33:51 +00:00
4ce316ee0f Ability to disable hints at compile time 2009-08-10 21:37:16 +00:00
675936b42c - ran 2to3 on export_3ds.py, import_3ds.py and export_x3d.py
- added operators and menu items for ^
2009-08-10 13:49:55 +00:00
d1f22f6ce3 Copied 3DS, X3D scripts to release/io naming them after [import|export]_[format].py scheme. 2009-08-08 11:44:56 +00:00
8fa528cef8 Added Object.find_armature() to find armature connected to object. Previously this was BPyObject.getObjectArmature() 2009-08-08 11:33:34 +00:00
b7a696e2ad Made -O3 and -msse2 default flags for bf_render_raytrace 2009-08-07 15:57:02 +00:00
51cad12120 *BLI_memarena support for any power of two alignment
*some simd stuff on bvh
2009-08-07 13:49:15 +00:00
3c3f8c3018 bpyrna: interpret a tuple of enum items (e1, e2, ...) as a bitmask (e1 | e2 | ...). 2009-08-07 13:00:39 +00:00
20c9f2e8ab Fix _MM_SHUFFLE_ order 2009-08-07 01:42:51 +00:00
3ef7c28402 improved SIMD on raytrace (up to the moment support of SIMD is done at dfs and on any type of tree)
(it only shows worth on -O3 -msse2)
because it seems gcc makes horrible asm code on -O2
2009-08-07 00:51:41 +00:00
4bc9ebd61f usage of simd on bb tests 2009-08-06 20:20:40 +00:00
f16df034c3 *Process leafs as soon as found instead of pushing them on stack for later evaluation (leads to early exits)
(this is mixed with some simd code commit, althouth no simd is being used up to the moment)
2009-08-06 17:45:51 +00:00
01eedc5046 - OBJ importer now reads most of the test files. Had to copy BPyMesh.ngon function to OBJ import code
- added MeshEdge.fgon property, not using it yet
- fixed in bpy_rna.c to correctly read arrays returned from RNA functions
2009-08-06 12:22:50 +00:00
f7179efde3 no need to calculate the exact nearest distance if we are not using any heuristic based on that 2009-08-05 21:09:41 +00:00
9565ef3087 #define to store coordinates at VlakRen and not at VlakFace
adds some additional cost retrieving coords during ray-primitive tests, but reduces some memory usage (4*3floats per face)
2009-08-05 15:50:57 +00:00
e4e9b569e1 experiences with memory organization (store the vertexs coords on RayFace) 2009-08-05 14:40:38 +00:00
bbdba89d06 generic hints for raytracer
for now only BB hint (i am  hoping to find a decent frustum-test)
2009-08-05 12:44:11 +00:00
59abddc202 - added Mesh.add_material function
- tweaked OBJ importer. It reads primitive files (cube, cone, etc.)
2009-08-05 12:01:42 +00:00
bf90970eca - OBJ exporter now copies images
- added OBJ, FBX scripts to File -> Export, File -> Import menus
2009-08-05 09:49:59 +00:00
7586990ace - modified BKE_get_image_export_path so that it writes relative path if src file = dest file returning 2 in this case
- modified unit tests for ^ firstly
- incorporated Image.get_export_path into FBX exporter script
2009-08-05 07:59:49 +00:00
2160f36fea Fix point-hint 2009-08-04 18:03:04 +00:00
7e9dc51cd1 Skip BB tests on primitives
the efficiency of this depends on ray-bb and ray-triangle functions efficiency
2009-08-04 17:24:49 +00:00
5e21e68f83 (fix) 2009-08-04 00:00:05 +00:00
eaf232cad9 single tree (by default)
now that build is nlogn (it should be worth to the tree of trees)
2009-08-03 23:25:38 +00:00
29530beb90 NlogN building:
sort once
	select subsets and kept the order (on X, Y and Z)
2009-08-03 17:56:38 +00:00
2065c5cf60 Merge with 2.5 -r 21756:22173. 2009-08-03 14:06:47 +00:00
4086ca58e2 - re-wrote image exporting function renaming it from BKE_export_image to BKE_get_image_export_path because now it doesn't copy
files but only manipulates paths. It produces both ablsolute and relative paths. COLLADA exporter can now use it.
- re-wrote unit test for it, this is now more compact and readable
- RNA API Image.get_export_path takes a boolean arg to indicate whether a relative or absolute path should be returned. Python scripts 
can now use it.
2009-08-03 12:02:40 +00:00
84d86540dd changed to STL sort 2009-08-02 12:11:14 +00:00
bee82a360e Another quick-fix for background mode 2009-08-02 11:32:03 +00:00
f6f2d217b6 svn merge -r 22111:22138 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-08-02 11:11:15 +00:00
c3a4936d9d svn merge -r 21508:22111 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-08-01 10:21:26 +00:00
d1e42cc5f8 Forgot to add rna_image_api.c. 2009-07-24 15:27:59 +00:00
d63d703842 - added operator for OBJ importer plus some python 3 conversions 2009-07-24 14:26:47 +00:00
d8f4ab2d59 API:
- freeing strings returned by RNA struct functions in RNA_parameter_list_free

Unit tests:
- check that BKE_export_image actually creates a file. This test is becoming dangerous: it creates and deletes files under /tmp.

Having written this complicated test function I now realize it's much easier to write tests in a scripted language, which gives more 
freedom in expressions and need not be compiled.
2009-07-23 15:57:30 +00:00
c96041628e API:
- replaced BKE_copy_images with BKE_export_image, now it handles only one image at a time, this is better since for exporters it is 
easier to export one image at a time writing new image path to a file
- exposing BKE_export_image in RNA as Image.export, interestingly, RNA allowed me to define a function with PROP_STRING return type 
although it doesn't free memory, will fix that in the next commit
- removed bpy.util.copy_images

Unit tests:
- re-wrote a test for BKE_export_image, it's more compact now
- moved unit tests to the creator module to avoid another executable, now running tests with `blender --test`
- as before, unit tests are built only if WITH_BF_UNIT_TEST is non 0
2009-07-23 12:55:26 +00:00
00e219d8e9 FBX exporter:
- made an operator with props for UI. UI is still "raw"
- ran 2to3 on export_fbx.py to make it python 3-compatible

Next: testing/fixing.
2009-07-22 13:35:02 +00:00
122d392fef Merge with 2.5 -r 21619:21756. 2009-07-21 12:13:56 +00:00
2830f25ff3 Another try with building better trees (this should never make worst trees)
Expected number of BB tests should reduce a bit (depending on the scene)
2009-07-17 19:09:42 +00:00
122104b3bb FBX exporter conversion almost done.
Unit tests:
- add a check that BKE_copy_images produces NULL filepath for images having type other than IMA_TYPE_IMAGE
- also expect NULL filepath for images having empty filename

Enhanced BKE_copy_images so the tests pass.
2009-07-17 10:09:07 +00:00
140f2b154f Reverted BF_GETTEXT_LIB in config/linuxcross-config.py to previous value.
Cross-compiling works!

Started a wiki page describing the process here: http://wiki.blender.org/index.php/User:Kazanbas/Cross-compiling_Blender_2.5_on_Linux

TODO:
- make scons copy DLLs to install directory
- deal with python: which version, what to install, etc.
- package up into .msi?
2009-07-16 19:07:54 +00:00
aede14d4e0 - replaced Object.create_mesh body with 2.4x API's Mesh.createFromObject code to also support curves, surfaces and metaballs.
- replaced Object.dag_update with Object.make_display_list, which copies old API's Object.makeDisplayList
2009-07-16 13:19:43 +00:00
d381a668be Merge with 2.5 -r 21515:21619. 2009-07-16 09:09:38 +00:00
73ad2d320c More FBX exporter conversion.
Experimenting with cross-compiling my branch with MinGW on Linux:
- tweaked config/linuxcross.py, source/blender/makesdna/intern/SConscript and tools/Blender.py
So far linking fails.
2009-07-16 08:20:15 +00:00
146b54d5e8 *increased stack size (later this should be prepared for dealing with stack size in runtime)
*put cost model back to normal
2009-07-15 17:44:25 +00:00
ef1fcd8ad1 *Added support to "BB hints" (which works like a BB version of LCTS - longest common transversing subtree)
It creates a tree cut after knowing that a given point will pass on a BB.
This tree cut is used to accelarate the rays casted from a given BB, eliminating unnecessary BB tests from root till the tree cut.
2009-07-15 17:38:00 +00:00
e3f7cad32d *fix (was losing childs) 2009-07-14 23:26:00 +00:00
7afffd2950 Just another experimental stuff to optimize the expected number of BB test on bvh trees
*tree pushdowns after the pushsups :P (its still not local optimum)
2009-07-14 23:08:55 +00:00
fb150e12c5 - FBX exporter conversion continued
- added (uncommented actually) PoseChannel.pose_matrix
- added Object.dag_update that calls DAG_object_flush_update. I'm not sure if it's needed, but FBX exporter uses it.
2009-07-13 11:04:18 +00:00
a6b328b825 *Moved rtbuild to bf_render_raytrace
*Added vbvh - Just a experimental tree type :)
Variable Way BVH - there is no hardcoded number of childs per each Tree Node
 - idea is to optimize a tree to reduced the expected number of BB tests even after applying SAH (for that an hardcoded n-way is not enough)
 - for now childs are stored on a linked list
2009-07-12 18:04:10 +00:00
ffa5636a8b Reusing existing blenkernel function calc_action_range for Action.get_frame_range. 2009-07-12 07:20:49 +00:00
11a47a02c7 Added Action.get_frame_range returning a (min, max) pair or (0, 0) if there are no keys. 2009-07-12 06:59:57 +00:00
e264087fad I had applied a patch twice.. code was duplicated 2009-07-11 22:29:53 +00:00
d6aefa6abd Added module bf_render_raytrace (source/blender/render/intern/raytrace)
to be able to use C++ at raytrace code
	C++ used in here is basicly C with templates and function overloads,
	to make it easier to reuse code between structures.

For now BVH was converted in C++ and moved to this module
2009-07-11 22:13:01 +00:00
870a9d6104 RNA functions can now return dynamic arrays (float, int/boolean). RNA handles freeing memory.
Example code: http://pastebin.mozilla.org/662154.
2009-07-11 16:11:26 +00:00
f221d9128d Added Scene.set_frame RNA function to get immediate scene update.
Changing Scene.current_frame doesn't work in this case because it adds 
a notifier.

Also added RNA_property_update call in pyrna_struct_setattro so that 
notifiers are added when a property changes.
2009-07-11 11:58:50 +00:00
3ad64726ee Merge from 2.5 -r 21285:21515. Thanks Joshua! 2009-07-11 09:14:12 +00:00
e56795b4fa svn merge -r 21372:21508 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-07-10 21:49:40 +00:00
9a23287fd8 SUN and HEMI lights back as trunk (i think) 2009-07-10 17:41:49 +00:00
81c3561513 *rtbuild now stores BB
*fix in ray/bb hit tests inside instances
2009-07-10 16:42:51 +00:00
c43fe4cca9 Should improve mirror rays (copy past error: was losing dive first heuristic sometimes) 2009-07-10 15:43:59 +00:00
b60bfd613e Cost of a BVH is calculated using SA(child)/SA(parent)
Although tests didnt showed this to be clearly superior to: cost(bvh) = log(size)
2009-07-10 15:33:35 +00:00
797c6a2295 - RNA-wrapped Bone props: head, armature_head, tail, armature_tail.
- more FBX conversion
2009-07-10 14:46:52 +00:00
2e4b9f3be4 *set cost of transversing a BVH as log(size) 2009-07-08 21:56:24 +00:00
85f6c108ac *Added support for variable cost per RayObject
Suposedly usefull for creating trees of objects (where objects have very diferent size-NumFaces and shape-BB)
Altought the implemented costs maybe not be very correct (for now), as i didnt cared about following a specific "corrected" model
2009-07-08 20:04:40 +00:00
8105454cba Enabled #ifdefs to test LAST_HIT, LAST_HINT
Disable last_hint as it only slow downs
2009-07-08 19:39:37 +00:00
f13d11ab71 Hint support (only for first hiearchic level and shadow rays, lets see if this is useful)
That means each shadow ray tests:
	1st: last hit face
	2nd: last hit object
	3rd: tree of all objects
2009-07-08 15:34:41 +00:00
f90a0b8383 Added local stack during bvh transversal 2009-07-08 10:40:26 +00:00
f7438ff77a - slowly starting FBX exporter conversion
- added Bone.matrix and Bone.armature_matrix
2009-07-07 19:13:05 +00:00
5b75ea38ff made rtbuild object_heuristic_spliter faster
I think its something like:
	old was:  4*nlogn + 3*(n*6)
	new is:  (2*nlogn + 3*(n*6)) * f, with f<1

Still missing changing the sorting function to an introsort instead of qsort
Other options like bucketing sort may be worth trying (for very large trees)
2009-07-07 19:07:53 +00:00
08fa786251 *added Object SAH support to rtbuild:
only for 2childs splits
	with "worse case heuristic" means each child is considered to have a cost linear on the number of leafs
	no termination criteria

number of BB test/hits expected to "reduced" by some factor
tree building is also expected to be slower as previous split was "object mean", which is quite fast to evaluate
2009-07-07 15:42:08 +00:00
ad0b2c87d5 Integrated unit testing framework with scons on Linux.
I needed this to make sure that BKE_copy_images works properly,
probably will be useful in future.

Using Check framework (http://check.sourceforge.net/doc/check.html/index.html).

WITH_BF_UNIT_TEST option builds 'alltest' program under [BUILDDIR]/bin, 
which, when executed, runs unit tests, currently only 1.

Example output:
----------------------------------------------------------------------
Running suite(s): Image
0%: Checks: 1, Failures: 1, Errors: 0
tests/alltest.c:74:F:Core:test_copy_images:0: Expected //bar/image.png to be translated to /tmp/bar/image.png, got /tmp/bar/image.pn.
----------------------------------------------------------------------

Spent lots of time (a couple of days actually :) to figure out how to
link the test program with Blender libraries. As it turned out there
are circular dependencies among Blender libraries. GCC by default
doesn't expect circular dependencies - dependant libs should precede
libs they depend on.

The magical --start-group linker option helped to solve this
(http://stephane.carrez.free.fr/doc/ld_2.html#IDX122).

Also:

- added bpy.util module. bpy.sys.* functions will move here later
- added bpy.util.copy_images that uses BKE_copy_images
- export_obj.py uses bpy.util.copy_images
2009-07-07 08:38:18 +00:00
c65a3e3166 *Added BLI_memarena on bvh
*Median split support on rtbuild
2009-07-06 19:45:00 +00:00
aa12d2153f *fix (forgot to multiply by BB size) 2009-07-06 15:35:46 +00:00
e0e66f6b74 *"Fixed" rayobject_bvh memory organization of BB's
until now rayobject_bvh should be at least as fast as BLIBVH, this seemed to be the missing piece
2009-07-06 14:36:26 +00:00
ba1f3323bf *Added output of BB/primitves test/hits
*"Added" SCE_PASS_RAYHITS to visually see each pixel primitive and BB tests (not-completed for UI)
*Added runtime exchange of tree structure
*Removed FLOAT_EPSILON from BLI_bvhkdop BB's
2009-07-06 13:27:40 +00:00
abc44f720a Set BVH (rayobject_bvh.c) as default tree type 2009-07-05 18:46:23 +00:00
6e1a81bc7a svn merge -r 21301:21372 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-07-05 15:20:19 +00:00
621b37bed6 *Added BIH 2009-07-05 00:38:53 +00:00
3d06a104a4 rayobject_octree fixed 2009-07-03 18:16:59 +00:00
2a23fda9d5 OBJ importer almost converted, except a few features (NURBS, NGON, FGON and sharp edges).
Added to API:
- Main.add_image
- Material.z_transparency
- two temporary properties: Image.depth and Image.has_data
2009-07-03 17:44:20 +00:00
4a72557e6b Fixed memory aligns for 64bits 2009-07-03 17:10:54 +00:00
44ef6c1eac *little fix 2009-07-03 02:56:54 +00:00
8394653ebd *No need of a BB if the underlying structure already has a BB 2009-07-03 02:26:40 +00:00
4b81d44282 *fixed crash 2009-07-02 22:12:26 +00:00
686a426cf0 *fixed rtbuild (there was a sorting bug introduced while adapting code from BLI_bvh)
This bvh should be at least as fast as BLI_kdopbvh now
2009-07-02 21:57:50 +00:00
617851bf21 - added API functions:
- Mesh.calc_normals
 - Object.add_vertex_to_group
 - Main.add_material
 - Main.add_texture
 - Material.add_texture
- OBJ importer conversion in progress
2009-07-02 20:46:35 +00:00
5c207a61f3 *RTBuilder now supports splitting leafs in N leafs
something is wrong on rayobject_bvh as it looks slower than BLI_bvh and code is based on it
2009-07-02 15:45:15 +00:00
b14298f959 svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-07-02 11:28:42 +00:00
2acac0ff99 Reverted incorrect merge (missing files)
svn up -r 21247
svn merge -r 21247:21246 . (<= revert incorrect: merge -r 21041:21243)
svn up
2009-07-02 02:59:43 +00:00
6ede28a05a - started OBJ importer conversion
- added Mesh.add_uv_layer, Object.add_vertex_group
2009-07-01 18:23:11 +00:00
87a7dd3773 Merge from 2.5 r21160 through r21285 2009-07-01 13:37:52 +00:00
1b557a61a5 fixed ray mirror/trans shadow on rayobject_bvh 2009-07-01 12:36:05 +00:00
91226e6807 *Added rayobject_bvh
A bvh structure to use on the raytracer
2009-07-01 11:27:43 +00:00
1deba75110 *Added initial code of rayobject_rtbuild
An helper class to build trees
2009-06-30 22:07:42 +00:00
021e0cc53f *reserved RayObject align offset 0 for private usage inside each structure
point is that other structures like trees can then distiguish between other nodes or rayobject primitives
withouth needing any other variable.
	(Note yet used but will reduce memory by a nice factor (linear to the number of primitives))
2009-06-30 14:05:33 +00:00
e0cfafa629 Measure build time...
*as expected it's a lot faster on BVH
2009-06-30 01:17:50 +00:00
dd7463bd4d svn merge -r 21041:21243 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-06-29 21:50:53 +00:00
1136656bba *forgot this file 2009-06-29 20:15:59 +00:00
f5f6850f23 *make type of acceleration structure changeable at runtime
*added some counter code (test/hits) for primitives and raycasts
2009-06-29 19:48:11 +00:00
1557736756 OBJ exporter working (Python 3.0), but needs testing and fixing.
Current issues:
- NURBS - needs API additions
- "all scenes" export - cannot switch scene in bpy
- normal calculation, disabled
- duplis - need testing, only dupliverts tested
- matrix problem
- UI, 18 options currently don't fit into filesel panel, will do manual lay out once it's available
- probably others...

BPY:
- made operator "execute" method required to avoid crash
- added bpy.sys module which replicates old "sys" module

API:
- replaced create_*_mesh with a single create_mesh accepting type parameter
- added Mesh.create_copy to create a copy of a mesh with 0 users

Ran `dos2unix` on source/blender/python/SConscript
2009-06-28 13:29:03 +00:00
83a5a585e4 Merge from 2.5 r21112 through r21160 2009-06-26 13:00:23 +00:00
acb590e4b0 * OBJ exporter almost converted
* added MeshEdge.loose property
* changed mask used in Object.create_*_mesh to CD_MASK_MESH.
2009-06-26 12:33:07 +00:00
165593931f *another blackdots fixed - had forgoted to enable skip-neighbour faces on ao. 2009-06-26 02:11:08 +00:00
18e7ec8463 - added MeshFace.normal property
- continuing OBJ exporter conversion
2009-06-25 18:04:32 +00:00
e2e139c0ba Added Mesh.active_uv_layer read-only property. 2009-06-25 13:33:21 +00:00
edfb507088 *Fixed handling of HEMI and SUN lights shadows 2009-06-24 19:29:48 +00:00
3f2fef55c2 - added API functions:
* Main.remove_object
  * Scene.add_object
  * Scene.remove_object
  * Object.convert_to_triface
  * Object.create_preview_mesh
  
- a small tweak in set_mesh (blenkernel/inter/mesh.c) to make it work on objects having data == NULL
2009-06-24 19:23:34 +00:00
d2a5bbdc2c Merge from 2.5 r21037 through r21112 2009-06-23 19:17:59 +00:00
3fce2f2826 - added Mesh.transform
- fixed Object.create_dupli_list
- continuing OBJ exporter conversion
2009-06-23 17:52:58 +00:00
10a4338936 *fixs ray_shadow_jitter (area soft shadow)
(detected with test249/render/arealight.blend)
2009-06-21 11:08:30 +00:00
2d68444da5 svn merge -r 20822:21041 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-06-20 21:53:57 +00:00
01da493a0a * Object.create_dupli_list, Object.free_dupli_list tweaking
* Defined custom "get" function for DupliObject.object

Accessing Object.dupli_list[N].object produces a crash.
2009-06-20 20:08:11 +00:00
a8b403db35 Merge from 2.5 r20991 through r21037 2009-06-20 16:48:58 +00:00
705fbec768 * Added Main.add_object(type, name)
* Added optional params to Object.create_render_mesh(apply_matrix, custom_matrix)
  apply_matrix is a boolean, True to transform mesh by ob->obmat or custom_matrix if given
* Fix subtle error in Object.create_dupli_list
* Make RNA struct funcs static, hopefully didn't miss any

Ignore export_obj-2.5.py changes for now ;)
2009-06-20 16:32:52 +00:00
a7f914d25a - tweak Object.create_render_mesh params
- svn merge -r 20124:20998 \
https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender/release/scripts/export_obj.py \
export_obj-2.5.py to make sure I don't miss new OBJ exporter features ;)
2009-06-20 05:52:19 +00:00
f6267e2a26 Moved struct DupliObject to DNA_object_types.h.
Object.create_dupli_list now works ok.
2009-06-19 12:46:51 +00:00
5d78f56c1f - added Object.create_dupli_list, Object.free_dupli_list
- attempted to RNA-wrap DupliObject, Object.create_dupli_list returns a 
collection of these.

Build fails probably because DupliObject is not defined in one of 
DNA_*.h headers.
2009-06-19 10:40:18 +00:00
dc7028cee4 Branch soc-2009-kazanbas
Merge with trunk revision 20991, and update scripts for the changes too.
Reload Scripts and Export OBJ still work for me.
2009-06-18 19:59:20 +00:00
05e7f8c5ac Build failed because with merge I didn't get updates on interface_api.c since I removed it.
So I decided to bring it back with:
 
svn export -r 20966 
https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender/source/blender/editors/interface/interface_api.c

Plus SConscript editing and it builds fine.
2009-06-18 13:13:37 +00:00
8bafa19853 Merge from 2.5 r20855 through r20966
Build fails: http://www.pasteall.org/6201/text
2009-06-18 11:42:30 +00:00
29f5694ab8 API structuring improvements according to design guidelines by Brecht,
for more info see
http://lists.blender.org/pipermail/bf-taskforce25/2009-June/000954.html.

Created *_api.c files in makesrna/intern. Among these only rna_api.c
is compiled on preprocesssing step. It contains code declaring RNA
struct functions, for example RNA_api_mesh declares all functions on
Mesh. The rest *_api.c files contain functions themselves.

Removed interface_api.c and moved its contents to rna_api.c.

Added remove_mesh function on Main.

Replaced copy and copy_mesh on Mesh with make_rendermesh which currently 
does the same as copy_applied did (grasping mesh-related stuff needs 
time).

SConscript tweaking so it builds ok.
2009-06-18 09:50:34 +00:00
419dde7021 Non recursive tree transverse on raycast
*for now proximity-heuristic on tree transverse is disabled
2009-06-17 00:01:27 +00:00
449555315a RNA_property_collection_add should work now for non-ID properties.
Since it's very limited, and has a doubtful interface, I need help on 
how improve and use it. I'll ask on ML.
2009-06-16 18:02:38 +00:00
bbec5c03c9 Updated makesrna to generate correct CollectionPropertyRNAs. 2009-06-16 16:15:19 +00:00
7a54e45ccd Just added another param to RNA_def_property_collection_funcs
and zeroed it in each call.
2009-06-16 13:57:28 +00:00
16d8cc633d WARNING: I'm starting generic RNA collection add ;) 2009-06-16 12:42:14 +00:00
556369fe2f The basic OBJ exporter working. The code is release/io/export_obj.py.
To run it, switch to Scripts Window, click Scripts->Reload Scripts 
menu, it appears under Scripts->Export.
2009-06-16 08:54:38 +00:00
678417b76c Added copy_applied method on Mesh objects. Uses DerivedMesh funcs to
get a mesh with all modifiers applied.
2009-06-15 13:49:02 +00:00
07e1b84ca8 Another fix in BPY_flag_from_seq: unrecognized flag is also an error.
Print operator return value for debugging.
2009-06-15 09:26:31 +00:00
c7cdb9cc38 File selector working. For now it is accessed as
context.add_fileselect(self.__operator__).

To allow file selector, I made the following changes:

- moved property definition funcs (FloatProperty, etc.) to "bpy.props"
to make them accessible from io scripts. Previously they were only
accessible in scripts running from Text Editor.

- added the "__operator__" instance attribute to py operators. The value
  is RNA operator pointer.

Note that "context.add_fileselect" changes were mistakenly committed
with my last merge.
2009-06-15 08:12:28 +00:00
fd893819bc Fix bug in BPY_flag_from_seq: reset the flag before adjusting it.
Otherwise py operators ended up returning something like 
OPERATOR_CANCELLED | OPERATOR_FINISHED.
2009-06-15 07:47:09 +00:00
93d21f36b3 Make release/io dir installable on scons build. 2009-06-14 16:48:19 +00:00
5e15d78bac Merge from 2.5 r20776 through r20855 2009-06-14 14:45:06 +00:00
590f3a43bf Enabled the missing features (not tested)
bug-reports are welcome
2009-06-14 10:56:29 +00:00
23eecb1e6e Import/export operator registration working. Written in python, it
traverses scripts in .blender/io extracting and registering Operator
subclasses, and binding to menu items under Scripts->Export in Scripts
Window.

release/io dir has to be copied to .blender manually for now.
2009-06-12 09:54:28 +00:00
1c9c278fa9 svn merge -r 20651:20822 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-06-12 02:29:38 +00:00
259da22058 svn add source/blender/editors/space_buttons/buttons_context.c
svn export -r 20776 \
https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_context.c                                                       

Old version of this file was sitting in my working copy not under 
version control. How that happened I have no idea.
2009-06-11 22:35:11 +00:00
d198480db8 *ray<->bb hit optimization... just to make it "slightly" faster :P
Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe
[http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9]

*for now it breaks shrinkwrap or other stuff that relies on sphere-raycast of BLI_kdopbvh.
2009-06-11 18:25:29 +00:00
6563e9ff8a Started operator registration with python. This is a piece of cake!
Made space_script header area customizable with python - need Brecht to 
check this.
Added a base for operator registration: a menu in Scripts Window with 
two items "Reload Scripts" and "Export". The former will do guess what?
The latter will be populated with submenu items each corresponding to 
an exporter :)
2009-06-11 18:15:04 +00:00
49479ef910 *Instance support at dupliverts/faces
*Octree works nicely on hierarchic trees
	*the old code was quite destructive at the Isect variable
	 changing isec->start, end, vec..now it only changes isec->labda (and hit results)

Currently rendering a BVH of all objects, where each object has it own octree.
2009-06-11 16:44:01 +00:00
a892799db7 Pass context to the "invoke" operator method.
"invoke" should have three args now: self, context and event respectively.
2009-06-11 15:10:23 +00:00
aaa17a285d Allow defining string property on py operator - a first step towards
interfacing the file selector :)
2009-06-11 11:46:12 +00:00
Chingiz Dyussenov
efcabc5f30 Merge from 2.5 rev 20647 through 20776. 2009-06-10 11:21:17 +00:00
Chingiz Dyussenov
ad503a32d6 - added copy_mesh_data C function which, unlike copy_mesh, copies data
between two existing meshes.
- API's Mesh.copy reflects copy_mesh_data.
2009-06-10 09:56:22 +00:00
Chingiz Dyussenov
b429a65ed6 Added two RNA struct functions - merely wrappers around the C api.
- add_mesh to Main - calls C add_mesh and returns a new mesh
- copy to Mesh - calls C copy_mesh and returns a new copy

Not sure about function placement and naming though.
Put both functions in editmesh.c, mesh editor module. Added prototypes 
to rna_internal.h. Prefixed both with "RNA_api_".

Wanted to code Mesh.copy so that it copies Mesh data from another object 
instead of creating a new Mesh, but this needs CustomData manipulations 
which I should study later.

Maybe we need a separate file for API functions? e.g. mesh_api.c?
2009-06-09 14:53:19 +00:00
cb82ef0d52 Renamed "execu" python operator method back to "exec" - switched to
Python 3.0...
2009-06-06 17:23:06 +00:00
0474acc4cb Small fix: use PyUnicode_FromString instead of PyString_FromString in
Python 3.x builds. PyString_FromString no longer exists in Python 3.x.
2009-06-06 16:22:54 +00:00
f9ee042afb svn merge -r 20486:20651 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-06-05 15:19:13 +00:00
1dcab2c875 Fixed reflections on bvh tree
(its kinda of a hackish-fix.. must be improved later)
2009-06-05 14:44:54 +00:00
00cef90b0d Merge from 2.5 rev 20515 through 20647. 2009-06-05 14:06:29 +00:00
2fad922924 *enabled mirror rays again
*octree is fine
	*bvh tree gives bad results
2009-06-03 23:56:04 +00:00
2e89796438 RayObject to support instances..
its not still plugged in the renderer, as so, it hasn't been tested yet
2009-06-03 14:42:28 +00:00
c09cbacf97 Continuing OBJ exporter conversion.
- export is initiated by an operator, output filepath is hardcoded for now.
- added code in bpy_interface.c to put 'scripts/bpymodules' in sys.path.
- no UI atm, using default option values, don't know how to do it yet
2009-06-02 20:16:33 +00:00
628b06e9c5 Woohoo! Context is now passed to operator's exec. Thanks Brecht and
Campbell!
2009-06-01 19:44:22 +00:00
4b50590945 *Some debug
*Some more integration with bli bvh (just testing stuff)
2009-05-31 02:35:58 +00:00
9d2906e60d svn merge -r 20373:20515 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-05-30 13:47:30 +00:00
92811f0f67 Linked bvhkdop with raytrace api 2009-05-29 22:55:06 +00:00
aab6dfd724 Fixed black dot bug! (it does work for the test case I had)
But I still wonder about its correction because it looks the
oposite of whats documented and of what was used before :S

I also took a long time to find it because I tought blender was feeding the raytrace structure
with quads and triangles but it looks the quads get triangulated before reaching makeraytree (on rayshade.c).
2009-05-29 21:32:52 +00:00
7e12e4e811 svn merge -r 20133:20486 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender
2.5 trunk has a nice bug fix for rendering
2009-05-29 00:54:52 +00:00
ab6ec6be7b In bpy, renamed "exec" operator method to "execu" for compatibility
with py 2.x ("exec" is a keyword in py 2.x).
2009-05-26 17:08:10 +00:00
a5a2d8c871 Start OBJ exporter conversion.
Just copied export_obj.py to export_obj-2.5.py leaving old one for 
reference. Once conversion is done, the new one will replace it.
2009-05-26 16:22:00 +00:00
f91c548b0f Merge with 2.5 rev 20373.
The exact command (for personal reference):
svn merge -r 20103:20373 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender
2009-05-24 07:26:36 +00:00
02ca0c6f75 I think this fix the black dots problem
(ZanQdo machine is just faster than mine.. so he will test :) )
2009-05-13 02:01:04 +00:00
da0c45e7eb Renamed exported functions from render to have the RE_ prefix
RayObject_* => RE_rayobject_*
2009-05-13 01:56:03 +00:00
f5566daa89 Added neighbour test on detected ray hit 2009-05-11 13:56:45 +00:00
562740322f svn merge -r 20018:20133 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender 2009-05-10 22:51:49 +00:00
a5ede43320 *new generic raytrace API
*Adapted octree to a more generic raytrace API
*ray shadow works (other untested stuff disabled atm)

On the scene tested the user-cpu time got from 1:24 to 1:19/20
probably because of removed callbacks or sligtly diferente memory usage
2009-05-10 21:02:58 +00:00
188afe8f08 First merge with 2.5 branch. 2009-05-08 16:02:58 +00:00
71c19dadbe Merge from trunk
svn merge -r 19848:20018 https://svn.blender.org/svnroot/bf-blender/branches/blender2.5/blender
2009-05-01 16:59:27 +00:00
0728878901 branch fron 2.5 for jaguarandi 2009-04-21 13:35:34 +00:00
d096b68a26 branch from 2.5 for kazanbas 2009-04-21 13:29:31 +00:00
1775 changed files with 227217 additions and 170200 deletions

View File

@@ -76,6 +76,11 @@ MACRO(SETUP_LIBDIRS)
IF(WITH_FFTW3)
LINK_DIRECTORIES(${FFTW3_LIBPATH})
ENDIF(WITH_FFTW3)
IF(WITH_OPENCOLLADA)
LINK_DIRECTORIES(${OPENCOLLADA_LIBPATH})
LINK_DIRECTORIES(${PCRE_LIBPATH})
LINK_DIRECTORIES(${EXPAT_LIBPATH})
ENDIF(WITH_OPENCOLLADA)
IF(WIN32)
LINK_DIRECTORIES(${PTHREADS_LIBPATH})
@@ -85,33 +90,32 @@ ENDMACRO(SETUP_LIBDIRS)
MACRO(SETUP_LIBLINKS
target)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ")
#TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIBRARY} ${LLIBS})
TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIBRARY} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS})
TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS})
# since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
ENDIF(WIN32)
IF(WITH_PYTHON)
TARGET_LINK_LIBRARIES(${target} ${PYTHON_LINKFLAGS})
TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${LLIBS})
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
ENDIF(WIN32)
ENDIF(WITH_PYTHON)
TARGET_LINK_LIBRARIES(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB})
TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIBRARY} ${LIBSAMPLERATE_LIB})
# since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
ENDIF(WIN32)
IF(WITH_INTERNATIONAL)
TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB})
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB})
ENDIF(WIN32)
ENDIF(WITH_INTERNATIONAL)
IF(WITH_OPENAL)
TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIBRARY})
ENDIF(WITH_OPENAL)
@@ -127,9 +131,6 @@ MACRO(SETUP_LIBLINKS
IF(WITH_SDL)
TARGET_LINK_LIBRARIES(${target} ${SDL_LIBRARY})
ENDIF(WITH_SDL)
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB})
ENDIF(WIN32)
IF(WITH_QUICKTIME)
TARGET_LINK_LIBRARIES(${target} ${QUICKTIME_LIB})
ENDIF(WITH_QUICKTIME)
@@ -139,6 +140,11 @@ MACRO(SETUP_LIBLINKS
IF(WITH_FFMPEG)
TARGET_LINK_LIBRARIES(${target} ${FFMPEG_LIB})
ENDIF(WITH_FFMPEG)
IF(WITH_OPENCOLLADA)
TARGET_LINK_LIBRARIES(${target} ${OPENCOLLADA_LIB})
TARGET_LINK_LIBRARIES(${target} ${PCRE_LIB})
TARGET_LINK_LIBRARIES(${target} ${EXPAT_LIB})
ENDIF(WITH_OPENCOLLADA)
IF(WIN32)
TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB})
ENDIF(WIN32)

View File

@@ -1,4 +1,4 @@
# $Id$
# $Id$
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
@@ -51,6 +51,10 @@ PROJECT(Blender)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
# Note! - Could create this from the blender version string
# ...but thats quite involved, make sure this matches the blender version.
SET(BLENDER_VERSION 2.5)
#-----------------------------------------------------------------------------
# Set default config options
OPTION(WITH_PLAYER "Build Player" OFF)
@@ -66,14 +70,29 @@ OPTION(WITH_PYTHON "Enable Embedded Python API" ON)
OPTION(WITH_SDL "Enable SDL for sound and joystick support" ON)
OPTION(WITH_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Unix only)" OFF)
OPTION(WITH_FFTW3 "Enable FFTW3 support" OFF)
OPTION(WITH_JACK "Enable Jack Support (http://www.jackaudio.org)" OFF)
OPTION(WITH_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
OPTION(WITH_LZO "Enable fast LZO compression, used for pointcache" ON)
OPTION(WITH_LZMA "Enable best LZMA compression, used for pointcache" ON)
OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation" OFF)
# OPTION(WITH_BUILDINFO "Include extra build details" ON)
OPTION(WITH_BUILDINFO "Include extra build details" ON)
OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON)
OPTION(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org/)" OFF)
# Unix defaults to OpenMP On
IF (UNIX)
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
ELSE(UNIX)
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
ENDIF(UNIX)
IF (APPLE)
OPTION(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON)
OPTION(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
OPTION(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF)
ENDIF (APPLE)
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
@@ -95,6 +114,8 @@ INCLUDE(CMake/macros.cmake)
#Platform specifics
IF(UNIX AND NOT APPLE)
IF(WITH_OPENAL)
FIND_PACKAGE(OpenAL)
IF(OPENAL_FOUND)
@@ -193,6 +214,20 @@ IF(UNIX AND NOT APPLE)
FIND_PACKAGE(ZLIB REQUIRED)
IF (WITH_OPENCOLLADA)
SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa Buffer)
SET(OPENCOLLADA_INC ${OPENCOLLADA})
SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
SET(EXPAT_LIBPATH ${EXPAT}/lib)
SET(EXPAT_LIB expat)
ENDIF (WITH_OPENCOLLADA)
# Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
@@ -208,7 +243,7 @@ IF(UNIX AND NOT APPLE)
ENDIF(WITH_OPENMP)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts")
SET(PLATFORM_LINKFLAGS "-pthread")
@@ -376,6 +411,16 @@ IF(WIN32)
SET(WINTAB_INC ${LIBDIR}/wintab/include)
SET(OPENCOLLADA ${LIBDIR}/opencollada)
SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 )
#pcre is bundled with openCollada
#SET(PCRE ${LIBDIR}/pcre)
#SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
IF(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
ELSE(CMAKE_CL_64)
@@ -386,16 +431,22 @@ IF(WIN32)
ENDIF(WIN32)
IF(APPLE)
IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-6.1-powerpc)
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
IF(WITH_LIBS10.5)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
ELSE(WITH_LIBS10.5)
IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
ENDIF(WITH_LIBS10.5)
IF(WITH_OPENAL)
FIND_PACKAGE(OpenAL)
IF(OPENAL_FOUND)
SET(WITH_OPENAL ON)
SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
ELSE(OPENAL_FOUND)
SET(WITH_OPENAL OFF)
ENDIF(OPENAL_FOUND)
@@ -409,7 +460,7 @@ IF(APPLE)
ENDIF(WITH_JACK)
IF(WITH_SNDFILE)
SET(SNDFILE /usr)
SET(SNDFILE ${LIBDIR}/sndfile)
SET(SNDFILE_INC ${SNDFILE}/include)
SET(SNDFILE_LIB sndfile)
SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
@@ -421,20 +472,20 @@ IF(APPLE)
# we use precompiled libraries for py 3.1 and up by default
SET(PYTHON ${LIBDIR}/python)
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
# SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") # not used yet
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
# SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
SET(PYTHON_LIB python${PYTHON_VERSION})
SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "")
SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
# SET(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
ELSE(PYTHON_VERSION MATCHES 3.1)
# otherwise, use custom system framework
SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
SET(PYTHON_VERSION 2.5)
SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
# SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") # not used yet
SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
# SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
SET(PYTHON_LIB "")
SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
ENDIF(PYTHON_VERSION MATCHES 3.1)
@@ -446,7 +497,7 @@ IF(APPLE)
IF(WITH_FFTW3)
SET(FFTW3 ${LIBDIR}/fftw3)
SET(FFTW3_INC ${FFTW3}/include)
SET(FFTW3_LIB libfftw)
SET(FFTW3_LIB fftw3)
SET(FFTW3_LIBPATH ${FFTW3}/lib)
ENDIF(WITH_FFTW3)
@@ -479,15 +530,45 @@ IF(APPLE)
SET(LLIBS stdc++ SystemStubs)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
IF (WITH_COCOA)
SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
IF(USE_QTKIT)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
#libSDL still needs 32bit carbon quicktime
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
ELSEIF(WITH_QUICKTIME)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
ENDIF(USE_QTKIT)
ELSE (WITH_COCOA)
SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
ENDIF (WITH_COCOA)
IF(WITH_OPENMP)
SET(LLIBS "${LLIBS} -lgomp ")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
SET(LLIBS "${LLIBS} -lgomp")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
ENDIF(WITH_OPENMP)
IF (WITH_OPENCOLLADA)
SET(OPENCOLLADA ${LIBDIR}/opencollada)
SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2" )
#pcre is bundled with openCollada
#SET(PCRE ${LIBDIR}/pcre)
#SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
#libxml2 is used
#SET(EXPAT ${LIBDIR}/expat)
#SET(EXPAT_LIBPATH ${EXPAT}/lib)
SET(EXPAT_LIB)
ENDIF (WITH_OPENCOLLADA)
SET(SDL ${LIBDIR}/sdl)
SET(SDL_INCLUDE_DIR ${SDL}/include)
SET(SDL_LIBRARY SDL)
@@ -505,6 +586,24 @@ IF(APPLE)
SET(TIFF_INC ${TIFF}/include)
SET(EXETYPE MACOSX_BUNDLE)
SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
# Better warnings
SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement")
SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
ENDIF(APPLE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
@@ -513,16 +612,28 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# TODO - buildinfo
# IF(UNIX)
# IF(WITH_BUILDINFO)
# EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
# EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)
# EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV)
# SET(BUILD_TYPE ${CMAKE_BUILD_TYPE})
# ENDIF(WITH_BUILDINFO)
# ENDIF(UNIX)
# buildinfo
IF(WITH_BUILDINFO)
# BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
IF(UNIX)
EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)
EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
IF(BUILD_REV_RETURN)
SET(BUILD_REV "unknown")
ENDIF(BUILD_REV_RETURN)
ENDIF(UNIX)
IF(WIN32)
EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)
EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
IF(BUILD_REV_RETURN)
SET(BUILD_REV "unknown")
ENDIF(BUILD_REV_RETURN)
ENDIF(WIN32)
ENDIF(WITH_BUILDINFO)
#-----------------------------------------------------------------------------
# Common.

View File

@@ -124,7 +124,10 @@ if toolset:
#if env:
# btools.SetupSpawn(env)
else:
env = BlenderEnvironment(ENV = os.environ)
if bitness==64 and platform=='win32':
env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
else:
env = BlenderEnvironment(ENV = os.environ)
if not env:
print "Could not create a build environment"
@@ -186,6 +189,15 @@ if not env['BF_FANCY']:
SetOption('num_jobs', int(env['BF_NUMJOBS']))
print "Build with %d parallel jobs" % (GetOption('num_jobs'))
# BLENDERPATH is a unix only option to enable typical style paths this is
# spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
# because the blender binary is installed in $BF_INSTALLDIR/bin/blender
if env['WITH_BF_FHS']:
BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
else:
BLENDERPATH = env['BF_INSTALLDIR']
# disable elbeem (fluidsim) compilation?
if env['BF_NO_ELBEEM'] == 1:
env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
@@ -198,7 +210,7 @@ if env['WITH_BF_OPENMP'] == 1:
env['CPPFLAGS'].append('/openmp')
env['CXXFLAGS'].append('/openmp')
else:
if env['CC'][-3:] == 'icc': # to be able to handle CC=/opt/bla/icc case
if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
env.Append(LINKFLAGS=['-openmp', '-static-intel'])
env['CCFLAGS'].append('-openmp')
env['CPPFLAGS'].append('-openmp')
@@ -208,6 +220,16 @@ if env['WITH_BF_OPENMP'] == 1:
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(CXXFLAGS=['-fopenmp'])
if env['WITH_GHOST_COCOA'] == True:
env.Append(CFLAGS=['-DGHOST_COCOA'])
env.Append(CXXFLAGS=['-DGHOST_COCOA'])
env.Append(CPPFLAGS=['-DGHOST_COCOA'])
if env['USE_QTKIT'] == True:
env.Append(CFLAGS=['-DUSE_QTKIT'])
env.Append(CXXFLAGS=['-DUSE_QTKIT'])
env.Append(CPPFLAGS=['-DUSE_QTKIT'])
#check for additional debug libnames
if env.has_key('BF_DEBUG_LIBS'):
@@ -301,7 +323,7 @@ if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-min
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
B.root_build_dir = env['BF_BUILDDIR']
B.doc_build_dir = env['BF_DOCDIR']
B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
if not B.root_build_dir[-1]==os.sep:
B.root_build_dir += os.sep
if not B.doc_build_dir[-1]==os.sep:
@@ -426,7 +448,10 @@ if env['OURPLATFORM']=='darwin':
source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source))
else:
blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
if env['WITH_BF_FHS']: dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
else: dir= env['BF_INSTALLDIR']
blenderinstall = env.Install(dir=dir, source=B.program_list)
#-- .blender
#- dont do .blender and scripts for darwin, it is already in the bundle
@@ -450,7 +475,13 @@ if env['OURPLATFORM']!='darwin':
continue
dotblendlist.append(os.path.join(dp, f))
dottargetlist.append(env['BF_INSTALLDIR']+dp[3:]+os.sep+f)
if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:])) # skip bin/.blender
else: dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:])) # skip bin
# print dir+ os.sep + f
print dir
dottargetlist.append(dir + os.sep + f)
dotblenderinstall = []
for targetdir,srcfile in zip(dottargetlist, dotblendlist):
@@ -458,14 +489,18 @@ if env['OURPLATFORM']!='darwin':
dotblenderinstall.append(env.Install(dir=td, source=srcfile))
if env['WITH_BF_PYTHON']:
#-- .blender/scripts, .blender/ui, .blender/io
scriptpaths=['release/scripts', 'release/ui', 'release/io']
#-- .blender/scripts
scriptpaths=['release/scripts']
for scriptpath in scriptpaths:
for dp, dn, df in os.walk(scriptpath):
if '.svn' in dn:
dn.remove('.svn')
dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):]
source=[dp+os.sep+f for f in df]
if env['WITH_BF_FHS']: dir = BLENDERPATH
else: dir = os.path.join(env['BF_INSTALLDIR'], '.blender')
dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
source=[os.path.join(dp, f) for f in df]
scriptinstall.append(env.Install(dir=dir,source=source))
#-- icons
@@ -477,8 +512,8 @@ if env['OURPLATFORM']=='linux2':
if '.svn' in tn:
tn.remove('.svn')
for f in tf:
iconlist.append(tp+os.sep+f)
icontargetlist.append(env['BF_INSTALLDIR']+tp[19:]+os.sep+f)
iconlist.append(os.path.join(tp, f))
icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
iconinstall = []
for targetdir,srcfile in zip(icontargetlist, iconlist):
@@ -499,24 +534,25 @@ for tp, tn, tf in os.walk('release/plugins'):
if '.svn' in tn:
tn.remove('.svn')
for f in tf:
pluglist.append(tp+os.sep+f)
plugtargetlist.append(env['BF_INSTALLDIR']+tp[7:]+os.sep+f)
pluglist.append(os.path.join(tp, f))
plugtargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[1:] + [f])) )
# header files for plugins
pluglist.append('source/blender/blenpluginapi/documentation.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'documentation.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
pluglist.append('source/blender/blenpluginapi/externdef.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'externdef.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
pluglist.append('source/blender/blenpluginapi/floatpatch.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'floatpatch.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
pluglist.append('source/blender/blenpluginapi/iff.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'iff.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
pluglist.append('source/blender/blenpluginapi/plugin.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'plugin.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
pluglist.append('source/blender/blenpluginapi/util.h')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'util.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
pluglist.append('source/blender/blenpluginapi/plugin.DEF')
plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep + 'plugin.def')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
plugininstall = []
for targetdir,srcfile in zip(plugtargetlist, pluglist):
@@ -531,7 +567,7 @@ for tp, tn, tf in os.walk('release/text'):
for f in tf:
textlist.append(tp+os.sep+f)
textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
textinstall = env.Install(dir=BLENDERPATH, source=textlist)
if env['OURPLATFORM']=='darwin':
allinstall = [blenderinstall, plugininstall, textinstall]
@@ -555,14 +591,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'):
else:
dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
if env['WITH_BF_PYTHON']:
ver = env["BF_PYTHON_VERSION"].replace(".", "")
dllsources.append('${LCGDIR}/release/python' + ver + '.zip')
dllsources.append('${LCGDIR}/release/zlib.pyd')
if env['BF_DEBUG']:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_LIB}_d.dll')
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
else:
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_LIB}.dll')
dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
if env['WITH_BF_ICONV']:
if env['OURPLATFORM'] == 'win64-vc':
pass # we link statically to iconv on win64
@@ -620,7 +652,6 @@ if env['WITH_BF_DOCS']:
except: epydoc = None
if epydoc:
SConscript('source/blender/python/api2_2x/doc/SConscript')
SConscript('source/gameengine/PyDoc/SConscript')
else:
print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "

View File

@@ -1,8 +1,22 @@
#
# Note : if you want to alter this file
# copy it as a whole in the upper folder
# as user-config.py
# dont create a new file with only some
# vars changed.
import commands
# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs
USE_SDK=True
#############################################################################
################### Cocoa & architecture settings ##################
#############################################################################
WITH_GHOST_COCOA=True
MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64
cmd = 'uname -p'
MAC_PROC=commands.getoutput(cmd)
cmd = 'uname -r'
@@ -11,28 +25,54 @@ if cmd_res[0]=='7':
MAC_CUR_VER='10.3'
elif cmd_res[0]=='8':
MAC_CUR_VER='10.4'
else:
elif cmd_res[0]=='9':
MAC_CUR_VER='10.5'
if MAC_PROC == 'powerpc':
LCGDIR = '#../lib/darwin-6.1-powerpc'
else :
LCGDIR = '#../lib/darwin-8.x.i386'
LIBDIR = '${LCGDIR}'
elif cmd_res[0]=='10':
MAC_CUR_VER='10.6'
BF_PYTHON_VERSION = '3.1'
if MAC_PROC== 'powerpc' and BF_PYTHON_VERSION == '2.3':
MAC_MIN_VERS = '10.3'
MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
else:
if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
USE_QTKIT=True # Carbon quicktime is not available for 64bit
# Default target OSX settings per architecture
# Can be customized
if MACOSX_ARCHITECTURE == 'ppc':
# ppc release are now made for 10.4
# MAC_MIN_VERS = '10.3'
# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
# LCGDIR = '#../lib/darwin-6.1-powerpc'
# CC = 'gcc-3.3'
# CXX = 'g++-3.3'
MAC_MIN_VERS = '10.4'
MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
LCGDIR = '#../lib/darwin-8.0.0-powerpc'
CC = 'gcc-4.0'
CXX = 'g++-4.0'
elif MACOSX_ARCHITECTURE == 'i386':
MAC_MIN_VERS = '10.4'
MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
LCGDIR = '#../lib/darwin-8.x.i386'
CC = 'gcc-4.0'
CXX = 'g++-4.0'
else :
MAC_MIN_VERS = '10.5'
MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
LCGDIR = '#../lib/darwin-9.x.universal'
CC = 'gcc-4.2'
CXX = 'g++-4.2'
LIBDIR = '${LCGDIR}'
#############################################################################
################### Dependency settings ##################
#############################################################################
# enable ffmpeg support
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
FFMPEG_PRECOMPILED = False
FFMPEG_PRECOMPILED = True
if FFMPEG_PRECOMPILED:
# use precompiled ffmpeg in /lib
BF_FFMPEG = LIBDIR + '/ffmpeg'
@@ -45,8 +85,8 @@ else:
BF_FFMPEG_INC = '${BF_FFMPEG}'
if USE_SDK==True:
BF_FFMPEG_EXTRA = '-isysroot '+MACOSX_SDK+' -mmacosx-version-min='+MAC_MIN_VERS
BF_XVIDCORE_CONFIG = '--disable-assembly' # currently causes errors, even with yasm installed
BF_X264_CONFIG = '--disable-pthread'
BF_XVIDCORE_CONFIG = '--disable-assembly --disable-mmx' # currently causes errors, even with yasm installed
BF_X264_CONFIG = '--disable-pthread --disable-asm'
if BF_PYTHON_VERSION=='3.1':
# python 3.1 uses precompiled libraries in bf svn /lib by default
@@ -75,10 +115,11 @@ else:
BF_PYTHON_LINKFLAGS = ['-u','_PyMac_Error','-framework','System','-framework','Python']
if MAC_CUR_VER=='10.3' or MAC_CUR_VER=='10.4':
BF_PYTHON_LINKFLAGS = ['-u', '__dummy']+BF_PYTHON_LINKFLAGS
BF_QUIET = '1'
WITH_BF_OPENMP = '0'
WITH_BF_OPENMP = '0' # multithreading for fluids, cloth and smoke ( only works with ICC atm )
WITH_BF_OPENAL = True
#different lib must be used following version of gcc
# for gcc 3.3
#BF_OPENAL = LIBDIR + '/openal'
@@ -89,11 +130,11 @@ else :
BF_OPENAL = LIBDIR + '/openal'
WITH_BF_STATICOPENAL = False
BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!!
#BF_OPENAL_LIB = 'openal'
#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
# Warning, this static lib configuration is untested! users of this OS please confirm.
BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a'
# Warning, this static lib configuration is untested! users of this OS please confirm.
BF_CXX = '/usr'
@@ -112,7 +153,7 @@ BF_JACK_INC = '${BF_JACK}/include/jack'
BF_JACK_LIB = 'jack'
BF_JACK_LIBPATH = '${BF_JACK}/lib'
WITH_BF_SNDFILE = False
WITH_BF_SNDFILE = True
BF_SNDFILE = LIBDIR + '/sndfile'
BF_SNDFILE_INC = '${BF_SNDFILE}/include'
BF_SNDFILE_LIB = 'sndfile'
@@ -170,7 +211,7 @@ BF_BULLET = '#extern/bullet2/src'
BF_BULLET_INC = '${BF_BULLET}'
BF_BULLET_LIB = 'extern_bullet'
WITH_BF_FFTW3 = False
WITH_BF_FFTW3 = True
BF_FFTW3 = LIBDIR + '/fftw3'
BF_FFTW3_INC = '${BF_FFTW3}/include'
BF_FFTW3_LIB = 'libfftw3'
@@ -199,10 +240,10 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
BF_FREETYPE_LIB = 'freetype'
BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib'
WITH_BF_QUICKTIME = True # -DWITH_QUICKTIME
WITH_BF_QUICKTIME = True
WITH_BF_ICONV = True
BF_ICONV = LIBDIR + "/iconv"
BF_ICONV = '/usr'
BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'iconv'
#BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
@@ -213,12 +254,57 @@ BF_OPENGL_LIB = 'GL GLU'
BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
CFLAGS = ['-pipe','-fPIC','-funsigned-char']
#OpenCollada flags
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2'
BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
BF_PCRE = LIBDIR + '/opencollada'
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
#BF_EXPAT = '/usr'
#BF_EXPAT_LIB = 'expat'
#BF_EXPAT_LIBPATH = '/usr/lib'
CPPFLAGS = ['-fpascal-strings']
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fpascal-strings']
CXXFLAGS = [ '-pipe','-fPIC','-funsigned-char', '-fpascal-strings']
PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','QuickTime']
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = False
if MACOSX_ARCHITECTURE == 'i386':
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
elif MACOSX_ARCHITECTURE == 'x86_64':
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2']
#############################################################################
################### various compile settings and flags ##################
#############################################################################
BF_QUIET = '1' # suppress verbose output
if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
ARCH_FLAGS = ['-m64']
else:
ARCH_FLAGS = ['-m32']
CFLAGS = ['-pipe','-funsigned-char']+ARCH_FLAGS
CPPFLAGS = ['-fpascal-strings']+ARCH_FLAGS
CCFLAGS = ['-pipe','-funsigned-char','-fpascal-strings']+ARCH_FLAGS
CXXFLAGS = ['-pipe','-funsigned-char', '-fpascal-strings']+ARCH_FLAGS
if WITH_GHOST_COCOA==True:
PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
else:
PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS
if WITH_BF_QUICKTIME == True:
if USE_QTKIT == True:
PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit']
else:
PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime']
#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
LLIBS = ['stdc++', 'SystemStubs']
@@ -231,34 +317,35 @@ if MAC_MIN_VERS == '10.3':
LLIBS.append('crt3.o')
if USE_SDK==True:
SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS]
PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS, '-Wl,-syslibroot,' + MACOSX_SDK]+PLATFORM_LINKFLAGS
SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE]
PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-syslibroot '+MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS
CCFLAGS=SDK_FLAGS+CCFLAGS
CXXFLAGS=SDK_FLAGS+CXXFLAGS
# you can add -mssse3 if gcc >= 4.2
if MAC_PROC == 'i386':
if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64':
REL_CFLAGS = ['-O2','-ftree-vectorize','-msse','-msse2','-msse3']
REL_CCFLAGS = ['-O2','-ftree-vectorize','-msse','-msse2','-msse3']
else:
CFLAGS = CFLAGS+['-fno-strict-aliasing']
CCFLAGS = CCFLAGS+['-fno-strict-aliasing']
CXXFLAGS = CXXFLAGS+['-fno-strict-aliasing']
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
# add -mssse3 for intel 64bit archs
if MACOSX_ARCHITECTURE == 'x86_64':
REL_CFLAGS = REL_CFLAGS+['-mssse3']
REL_CCFLAGS = REL_CCFLAGS+['-mssse3']
##BF_DEPEND = True
##
##AR = ar
##ARFLAGS = ruv
##ARFLAGSQUIET = ru
##
CC = 'gcc'
CXX = 'g++'
C_WARN = ['-Wdeclaration-after-statement']
#C_WARN = ['-Wdeclaration-after-statement']
CC_WARN = ['-Wall', '-Wno-long-double']
CC_WARN = ['-Wall']
##FIX_STUBS_WARNINGS = -Wno-unused
@@ -272,6 +359,9 @@ BF_PROFILE = False
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']
#############################################################################
################### Output directories ##################
#############################################################################
BF_BUILDDIR='../build/darwin'
BF_INSTALLDIR='../install/darwin'
BF_DOCDIR='../install/doc'

View File

@@ -161,7 +161,7 @@ CXX = 'CC'
CCFLAGS = ['-pipe','-fPIC', '-n32']
CPPFLAGS = ['-DXP_UNIX']
CPPFLAGS = []
CXXFLAGS = ['-pipe','-fPIC', '-n32']
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
@@ -189,7 +189,6 @@ BF_DEBUG_FLAGS = '-g'
BF_BUILDDIR = '../build/irix6'
BF_INSTALLDIR='../install/irix6'
BF_DOCDIR='../install/doc'
#Link against pthread
LDIRS = []

View File

@@ -151,6 +151,26 @@ BF_OPENGL_LIB = 'GL GLU X11 Xi'
BF_OPENGL_LIBPATH = '/usr/X11R6/lib'
BF_OPENGL_LIB_STATIC = '${BF_OPENGL_LIBPATH}/libGL.a ${BF_OPENGL_LIBPATH}/libGLU.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a ${BF_OPENGL_LIBPATH}/libX11.a ${BF_OPENGL_LIBPATH}/libXi.a ${BF_OPENGL_LIBPATH}/libXext.a ${BF_OPENGL_LIBPATH}/libXxf86vm.a'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = '/usr'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre Buffer ftoa'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
BF_PCRE = ''
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '/usr/lib'
BF_EXPAT = '/usr'
BF_EXPAT_LIB = 'expat'
BF_EXPAT_LIBPATH = '/usr/lib'
WITH_BF_OPENMP = True
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = False
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-pthread']
##
CC = 'gcc'
CXX = 'g++'
@@ -159,7 +179,7 @@ CXX = 'g++'
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing']
CPPFLAGS = ['-DXP_UNIX']
CPPFLAGS = []
CXXFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing']
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
@@ -189,8 +209,6 @@ BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/linux2'
BF_INSTALLDIR='../install/linux2'
BF_DOCDIR='../install/doc'
#Link against pthread
PLATFORM_LINKFLAGS = ['-pthread']

View File

@@ -119,7 +119,7 @@ CXX = 'i586-mingw32msvc-g++'
CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ]
CPPFLAGS = [ '-DXP_UNIX', '-DWIN32', '-DFREE_WINDOWS' ]
CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS']
CXXFLAGS = ['-pipe', '-mwindows', '-funsigned-char', '-fno-strict-aliasing' ]
REL_CFLAGS = [ '-O2' ]
REL_CCFLAGS = [ '-O2' ]
@@ -139,4 +139,3 @@ BF_PROFILE_LINKFLAGS = ['-pg']
BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross'
BF_DOCDIR='../install/doc'

View File

@@ -151,4 +151,3 @@ BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR='../build/openbsd3'
BF_INSTALLDIR='../install/openbsd3'
BF_DOCDIR='../install/doc'

View File

@@ -136,7 +136,7 @@ CXX = 'g++'
CCFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing']
CPPFLAGS = ['-DXP_UNIX', '-DSUN_OGL_NO_VERTEX_MACROS']
CPPFLAGS = ['-DSUN_OGL_NO_VERTEX_MACROS']
CXXFLAGS = ['-pipe','-fPIC','-funsigned-char','-fno-strict-aliasing']
REL_CFLAGS = ['-O2']
REL_CCFLAGS = ['-O2']
@@ -165,7 +165,6 @@ BF_DEBUG_CCFLAGS = []
BF_BUILDDIR = '../build/sunos5'
BF_INSTALLDIR='../install/sunos5'
BF_DOCDIR='../install/doc'
PLATFORM_LINKFLAGS = []

View File

@@ -6,7 +6,8 @@ BF_PYTHON_VERSION = '3.1'
WITH_BF_STATICPYTHON = False
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}'
BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}mw'
BF_PYTHON_DLL = 'python31'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
BF_PYTHON_LIB_STATIC = '${BF_PYTHON}/lib/libpython${BF_PYTHON_VERSION[0]}${BF_PYTHON_VERSION[2]}.a'
@@ -125,13 +126,28 @@ BF_OPENGL_LIB = 'opengl32 glu32'
BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a',
'${BF_OPENGL}/lib/libXmu.a', '${BF_OPENGL}/lib/libXext.a',
'${BF_OPENGL}/lib/libX11.a', '${BF_OPENGL}/lib/libXi.a' ]
WITH_BF_COLLADA = True
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver xml2 pcre'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = False
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']
##
CC = 'gcc'
CXX = 'g++'
CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ]
CPPFLAGS = [ '-DXP_UNIX', '-DWIN32', '-DFREE_WINDOWS' ]
CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS']
CXXFLAGS = ['-pipe', '-mwindows', '-funsigned-char', '-fno-strict-aliasing' ]
REL_CFLAGS = [ '-O2' ]
REL_CCFLAGS = [ '-O2' ]
@@ -140,7 +156,7 @@ C_WARN = [ '-Wno-char-subscripts', '-Wdeclaration-after-statement' ]
CC_WARN = [ '-Wall' ]
LLIBS = ['-lshell32', '-lshfolder', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lws2_32', '-lz', '-lstdc++']
LLIBS = ['-lshell32', '-lshfolder', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lws2_32', '-lz', '-lstdc++','-lole32','-luuid']
BF_DEBUG = False
BF_DEBUG_CCFLAGS= ['-g']
@@ -152,4 +168,3 @@ BF_PROFILE = False
BF_BUILDDIR = '..\\build\\win32-mingw'
BF_INSTALLDIR='..\\install\\win32-mingw'
BF_DOCDIR = '..\\install\\doc'

View File

@@ -13,6 +13,7 @@ BF_PYTHON_VERSION = '3.1'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
BF_PYTHON_LIB = 'python31'
BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
WITH_BF_OPENAL = True
@@ -137,6 +138,20 @@ BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
WITH_BF_REDCODE = False
BF_REDCODE_INC = '#extern'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver xml2 pcre'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = False
BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE']
WITH_BF_STATICOPENGL = False
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'
@@ -144,6 +159,7 @@ BF_OPENGL_LIB = 'opengl32 glu32'
BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a',
'${BF_OPENGL}/lib/libXmu.a', '${BF_OPENGL}/lib/libXext.a',
'${BF_OPENGL}/lib/libX11.a', '${BF_OPENGL}/lib/libXi.a' ]
CC = 'cl.exe'
CXX = 'cl.exe'
@@ -173,4 +189,3 @@ PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:IX86','/INCREMENTAL:NO','/N
BF_BUILDDIR = '..\\build\\win32-vc'
BF_INSTALLDIR='..\\install\\win32-vc'
BF_DOCDIR='..\\install\\doc'

View File

@@ -13,6 +13,7 @@ BF_PYTHON_VERSION = '3.1'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
BF_PYTHON_BINARY = 'python'
BF_PYTHON_LIB = 'python31'
BF_PYTHON_DLL = '${BF_PYTHON_LIB}'
BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
WITH_BF_OPENAL = False
@@ -150,6 +151,20 @@ BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib'
WITH_BF_REDCODE = False
BF_REDCODE_INC = '#extern'
WITH_BF_COLLADA = False
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver xml2 pcre'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = False
BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE','/arch:SSE2']
WITH_BF_STATICOPENGL = False
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'
@@ -163,7 +178,7 @@ CXX = 'cl.exe'
CFLAGS = []
CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/wd4244', '/wd4305', '/wd4800', '/wd4065', '/wd4267']
CXXFLAGS = ['/EHsc']
BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast', '/arch:SSE2']
BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast']
BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr']
@@ -192,7 +207,6 @@ PLATFORM_LINKFLAGS = ['/SUBSYSTEM:CONSOLE','/MACHINE:X64','/INCREMENTAL:NO','/NO
BF_BUILDDIR = '..\\build\\blender25-win64-vc'
BF_INSTALLDIR='..\\install\\blender25-win64-vc'
BF_DOCDIR='..\\install\\blender25-win64-vc\\doc'

View File

@@ -38,5 +38,10 @@ IF(WITH_OPENJPEG)
ADD_SUBDIRECTORY(libopenjpeg)
ENDIF(WITH_OPENJPEG)
ADD_SUBDIRECTORY(lzo)
ADD_SUBDIRECTORY(lzma)
IF(WITH_LZO)
ADD_SUBDIRECTORY(lzo)
ENDIF(WITH_LZO)
IF(WITH_LZMA)
ADD_SUBDIRECTORY(lzma)
ENDIF(WITH_LZMA)

39
extern/Eigen2/Eigen/Array vendored Normal file
View File

@@ -0,0 +1,39 @@
#ifndef EIGEN_ARRAY_MODULE_H
#define EIGEN_ARRAY_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen {
/** \defgroup Array_Module Array module
* This module provides several handy features to manipulate matrices as simple array of values.
* In addition to listed classes, it defines various methods of the Cwise interface
* (accessible from MatrixBase::cwise()), including:
* - matrix-scalar sum,
* - coeff-wise comparison operators,
* - sin, cos, sqrt, pow, exp, log, square, cube, inverse (reciprocal).
*
* This module also provides various MatrixBase methods, including:
* - \ref MatrixBase::all() "all", \ref MatrixBase::any() "any",
* - \ref MatrixBase::Random() "random matrix initialization"
*
* \code
* #include <Eigen/Array>
* \endcode
*/
#include "src/Array/CwiseOperators.h"
#include "src/Array/Functors.h"
#include "src/Array/BooleanRedux.h"
#include "src/Array/Select.h"
#include "src/Array/PartialRedux.h"
#include "src/Array/Random.h"
#include "src/Array/Norms.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_ARRAY_MODULE_H

65
extern/Eigen2/Eigen/Cholesky vendored Normal file
View File

@@ -0,0 +1,65 @@
#ifndef EIGEN_CHOLESKY_MODULE_H
#define EIGEN_CHOLESKY_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
#ifndef EIGEN_HIDE_HEAVY_CODE
#define EIGEN_HIDE_HEAVY_CODE
#endif
#elif defined EIGEN_HIDE_HEAVY_CODE
#undef EIGEN_HIDE_HEAVY_CODE
#endif
namespace Eigen {
/** \defgroup Cholesky_Module Cholesky module
*
* \nonstableyet
*
* This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
* Those decompositions are accessible via the following MatrixBase methods:
* - MatrixBase::llt(),
* - MatrixBase::ldlt()
*
* \code
* #include <Eigen/Cholesky>
* \endcode
*/
#include "src/Array/CwiseOperators.h"
#include "src/Array/Functors.h"
#include "src/Cholesky/LLT.h"
#include "src/Cholesky/LDLT.h"
} // namespace Eigen
#define EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
PREFIX template class LLT<MATRIXTYPE>; \
PREFIX template class LDLT<MATRIXTYPE>
#define EIGEN_CHOLESKY_MODULE_INSTANTIATE(PREFIX) \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
#ifdef EIGEN_EXTERN_INSTANTIATIONS
namespace Eigen {
EIGEN_CHOLESKY_MODULE_INSTANTIATE(extern);
} // namespace Eigen
#endif
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_CHOLESKY_MODULE_H

154
extern/Eigen2/Eigen/Core vendored Normal file
View File

@@ -0,0 +1,154 @@
#ifndef EIGEN_CORE_H
#define EIGEN_CORE_H
// first thing Eigen does: prevent MSVC from committing suicide
#include "src/Core/util/DisableMSVCWarnings.h"
#ifdef _MSC_VER
#include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
#if (_MSC_VER >= 1500) // 2008 or later
// Remember that usage of defined() in a #define is undefined by the standard.
// a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
#if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
#define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
#endif
#endif
#endif
#ifdef __GNUC__
#define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x)
#else
#define EIGEN_GNUC_AT_LEAST(x,y) 0
#endif
// Remember that usage of defined() in a #define is undefined by the standard
#if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) )
#define EIGEN_SSE2_BUT_NOT_OLD_GCC
#endif
#ifndef EIGEN_DONT_VECTORIZE
#if defined (EIGEN_SSE2_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
#define EIGEN_VECTORIZE
#define EIGEN_VECTORIZE_SSE
#include <emmintrin.h>
#include <xmmintrin.h>
#ifdef __SSE3__
#include <pmmintrin.h>
#endif
#ifdef __SSSE3__
#include <tmmintrin.h>
#endif
#elif defined __ALTIVEC__
#define EIGEN_VECTORIZE
#define EIGEN_VECTORIZE_ALTIVEC
#include <altivec.h>
// We need to #undef all these ugly tokens defined in <altivec.h>
// => use __vector instead of vector
#undef bool
#undef vector
#undef pixel
#endif
#endif
#include <cstdlib>
#include <cmath>
#include <complex>
#include <cassert>
#include <functional>
#include <iostream>
#include <cstring>
#include <string>
#include <limits>
#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_NO_EXCEPTIONS)
#define EIGEN_EXCEPTIONS
#endif
#ifdef EIGEN_EXCEPTIONS
#include <new>
#endif
// this needs to be done after all possible windows C header includes and before any Eigen source includes
// (system C++ includes are supposed to be able to deal with this already):
// windows.h defines min and max macros which would make Eigen fail to compile.
#if defined(min) || defined(max)
#error The preprocessor symbols 'min' or 'max' are defined. If you are compiling on Windows, do #define NOMINMAX to prevent windows.h from defining these symbols.
#endif
namespace Eigen {
/** \defgroup Core_Module Core module
* This is the main module of Eigen providing dense matrix and vector support
* (both fixed and dynamic size) with all the features corresponding to a BLAS library
* and much more...
*
* \code
* #include <Eigen/Core>
* \endcode
*/
#include "src/Core/util/Macros.h"
#include "src/Core/util/Constants.h"
#include "src/Core/util/ForwardDeclarations.h"
#include "src/Core/util/Meta.h"
#include "src/Core/util/XprHelper.h"
#include "src/Core/util/StaticAssert.h"
#include "src/Core/util/Memory.h"
#include "src/Core/NumTraits.h"
#include "src/Core/MathFunctions.h"
#include "src/Core/GenericPacketMath.h"
#if defined EIGEN_VECTORIZE_SSE
#include "src/Core/arch/SSE/PacketMath.h"
#elif defined EIGEN_VECTORIZE_ALTIVEC
#include "src/Core/arch/AltiVec/PacketMath.h"
#endif
#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 16
#endif
#include "src/Core/Functors.h"
#include "src/Core/MatrixBase.h"
#include "src/Core/Coeffs.h"
#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
// at least confirmed with Doxygen 1.5.5 and 1.5.6
#include "src/Core/Assign.h"
#endif
#include "src/Core/MatrixStorage.h"
#include "src/Core/NestByValue.h"
#include "src/Core/Flagged.h"
#include "src/Core/Matrix.h"
#include "src/Core/Cwise.h"
#include "src/Core/CwiseBinaryOp.h"
#include "src/Core/CwiseUnaryOp.h"
#include "src/Core/CwiseNullaryOp.h"
#include "src/Core/Dot.h"
#include "src/Core/Product.h"
#include "src/Core/DiagonalProduct.h"
#include "src/Core/SolveTriangular.h"
#include "src/Core/MapBase.h"
#include "src/Core/Map.h"
#include "src/Core/Block.h"
#include "src/Core/Minor.h"
#include "src/Core/Transpose.h"
#include "src/Core/DiagonalMatrix.h"
#include "src/Core/DiagonalCoeffs.h"
#include "src/Core/Sum.h"
#include "src/Core/Redux.h"
#include "src/Core/Visitor.h"
#include "src/Core/Fuzzy.h"
#include "src/Core/IO.h"
#include "src/Core/Swap.h"
#include "src/Core/CommaInitializer.h"
#include "src/Core/Part.h"
#include "src/Core/CacheFriendlyProduct.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_CORE_H

8
extern/Eigen2/Eigen/Dense vendored Normal file
View File

@@ -0,0 +1,8 @@
#include "Core"
#include "Array"
#include "LU"
#include "Cholesky"
#include "QR"
#include "SVD"
#include "Geometry"
#include "LeastSquares"

2
extern/Eigen2/Eigen/Eigen vendored Normal file
View File

@@ -0,0 +1,2 @@
#include "Dense"
#include "Sparse"

51
extern/Eigen2/Eigen/Geometry vendored Normal file
View File

@@ -0,0 +1,51 @@
#ifndef EIGEN_GEOMETRY_MODULE_H
#define EIGEN_GEOMETRY_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "Array"
#include <limits>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
namespace Eigen {
/** \defgroup Geometry_Module Geometry module
*
* \nonstableyet
*
* This module provides support for:
* - fixed-size homogeneous transformations
* - translation, scaling, 2D and 3D rotations
* - quaternions
* - \ref MatrixBase::cross() "cross product"
* - \ref MatrixBase::unitOrthogonal() "orthognal vector generation"
* - some linear components: parametrized-lines and hyperplanes
*
* \code
* #include <Eigen/Geometry>
* \endcode
*/
#include "src/Geometry/OrthoMethods.h"
#include "src/Geometry/RotationBase.h"
#include "src/Geometry/Rotation2D.h"
#include "src/Geometry/Quaternion.h"
#include "src/Geometry/AngleAxis.h"
#include "src/Geometry/EulerAngles.h"
#include "src/Geometry/Transform.h"
#include "src/Geometry/Translation.h"
#include "src/Geometry/Scaling.h"
#include "src/Geometry/Hyperplane.h"
#include "src/Geometry/ParametrizedLine.h"
#include "src/Geometry/AlignedBox.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_GEOMETRY_MODULE_H

29
extern/Eigen2/Eigen/LU vendored Normal file
View File

@@ -0,0 +1,29 @@
#ifndef EIGEN_LU_MODULE_H
#define EIGEN_LU_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen {
/** \defgroup LU_Module LU module
* This module includes %LU decomposition and related notions such as matrix inversion and determinant.
* This module defines the following MatrixBase methods:
* - MatrixBase::inverse()
* - MatrixBase::determinant()
*
* \code
* #include <Eigen/LU>
* \endcode
*/
#include "src/LU/LU.h"
#include "src/LU/Determinant.h"
#include "src/LU/Inverse.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_LU_MODULE_H

27
extern/Eigen2/Eigen/LeastSquares vendored Normal file
View File

@@ -0,0 +1,27 @@
#ifndef EIGEN_REGRESSION_MODULE_H
#define EIGEN_REGRESSION_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "QR"
#include "Geometry"
namespace Eigen {
/** \defgroup LeastSquares_Module LeastSquares module
* This module provides linear regression and related features.
*
* \code
* #include <Eigen/LeastSquares>
* \endcode
*/
#include "src/LeastSquares/LeastSquares.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_REGRESSION_MODULE_H

168
extern/Eigen2/Eigen/NewStdVector vendored Normal file
View File

@@ -0,0 +1,168 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_STDVECTOR_MODULE_H
#define EIGEN_STDVECTOR_MODULE_H
#include "Core"
#include <vector>
namespace Eigen {
// This one is needed to prevent reimplementing the whole std::vector.
template <class T>
class aligned_allocator_indirection : public aligned_allocator<T>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
template<class U>
struct rebind
{
typedef aligned_allocator_indirection<U> other;
};
aligned_allocator_indirection() throw() {}
aligned_allocator_indirection(const aligned_allocator_indirection& ) throw() : aligned_allocator<T>() {}
aligned_allocator_indirection(const aligned_allocator<T>& ) throw() {}
template<class U>
aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) throw() {}
template<class U>
aligned_allocator_indirection(const aligned_allocator<U>& ) throw() {}
~aligned_allocator_indirection() throw() {}
};
#ifdef _MSC_VER
// sometimes, MSVC detects, at compile time, that the argument x
// in std::vector::resize(size_t s,T x) won't be aligned and generate an error
// even if this function is never called. Whence this little wrapper.
#define EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) Eigen::ei_workaround_msvc_std_vector<T>
template<typename T> struct ei_workaround_msvc_std_vector : public T
{
inline ei_workaround_msvc_std_vector() : T() {}
inline ei_workaround_msvc_std_vector(const T& other) : T(other) {}
inline operator T& () { return *static_cast<T*>(this); }
inline operator const T& () const { return *static_cast<const T*>(this); }
template<typename OtherT>
inline T& operator=(const OtherT& other)
{ T::operator=(other); return *this; }
inline ei_workaround_msvc_std_vector& operator=(const ei_workaround_msvc_std_vector& other)
{ T::operator=(other); return *this; }
};
#else
#define EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) T
#endif
}
namespace std {
#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
public: \
typedef T value_type; \
typedef typename vector_base::allocator_type allocator_type; \
typedef typename vector_base::size_type size_type; \
typedef typename vector_base::iterator iterator; \
typedef typename vector_base::const_iterator const_iterator; \
explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
template<typename InputIterator> \
vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
: vector_base(first, last, a) {} \
vector(const vector& c) : vector_base(c) {} \
explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
vector(iterator start, iterator end) : vector_base(start, end) {} \
vector& operator=(const vector& x) { \
vector_base::operator=(x); \
return *this; \
}
template<typename T>
class vector<T,Eigen::aligned_allocator<T> >
: public vector<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> >
{
typedef vector<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> > vector_base;
EIGEN_STD_VECTOR_SPECIALIZATION_BODY
void resize(size_type new_size)
{ resize(new_size, T()); }
#if defined(_VECTOR_)
// workaround MSVC std::vector implementation
void resize(size_type new_size, const value_type& x)
{
if (vector_base::size() < new_size)
vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);
else if (new_size < vector_base::size())
vector_base::erase(vector_base::begin() + new_size, vector_base::end());
}
void push_back(const value_type& x)
{ vector_base::push_back(x); }
using vector_base::insert;
iterator insert(const_iterator position, const value_type& x)
{ return vector_base::insert(position,x); }
void insert(const_iterator position, size_type new_size, const value_type& x)
{ vector_base::insert(position, new_size, x); }
#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
// workaround GCC std::vector implementation
void resize(size_type new_size, const value_type& x)
{
if (new_size < vector_base::size())
vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);
else
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
}
#elif defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))
// Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&),
// no no need to workaround !
using vector_base::resize;
#else
// either GCC 4.1 or non-GCC
// default implementation which should always work.
void resize(size_type new_size, const value_type& x)
{
if (new_size < vector_base::size())
vector_base::erase(vector_base::begin() + new_size, vector_base::end());
else if (new_size > vector_base::size())
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
}
#endif
};
}
#endif // EIGEN_STDVECTOR_MODULE_H

73
extern/Eigen2/Eigen/QR vendored Normal file
View File

@@ -0,0 +1,73 @@
#ifndef EIGEN_QR_MODULE_H
#define EIGEN_QR_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include "Cholesky"
// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
#ifndef EIGEN_HIDE_HEAVY_CODE
#define EIGEN_HIDE_HEAVY_CODE
#endif
#elif defined EIGEN_HIDE_HEAVY_CODE
#undef EIGEN_HIDE_HEAVY_CODE
#endif
namespace Eigen {
/** \defgroup QR_Module QR module
*
* \nonstableyet
*
* This module mainly provides QR decomposition and an eigen value solver.
* This module also provides some MatrixBase methods, including:
* - MatrixBase::qr(),
* - MatrixBase::eigenvalues(),
* - MatrixBase::operatorNorm()
*
* \code
* #include <Eigen/QR>
* \endcode
*/
#include "src/QR/QR.h"
#include "src/QR/Tridiagonalization.h"
#include "src/QR/EigenSolver.h"
#include "src/QR/SelfAdjointEigenSolver.h"
#include "src/QR/HessenbergDecomposition.h"
// declare all classes for a given matrix type
#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
PREFIX template class QR<MATRIXTYPE>; \
PREFIX template class Tridiagonalization<MATRIXTYPE>; \
PREFIX template class HessenbergDecomposition<MATRIXTYPE>; \
PREFIX template class SelfAdjointEigenSolver<MATRIXTYPE>
// removed because it does not support complex yet
// PREFIX template class EigenSolver<MATRIXTYPE>
// declare all class for all types
#define EIGEN_QR_MODULE_INSTANTIATE(PREFIX) \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
#ifdef EIGEN_EXTERN_INSTANTIATIONS
EIGEN_QR_MODULE_INSTANTIATE(extern);
#endif // EIGEN_EXTERN_INSTANTIATIONS
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_QR_MODULE_H

29
extern/Eigen2/Eigen/QtAlignedMalloc vendored Normal file
View File

@@ -0,0 +1,29 @@
#ifndef EIGEN_QTMALLOC_MODULE_H
#define EIGEN_QTMALLOC_MODULE_H
#include "Core"
#if (!EIGEN_MALLOC_ALREADY_ALIGNED)
inline void *qMalloc(size_t size)
{
return Eigen::ei_aligned_malloc(size);
}
inline void qFree(void *ptr)
{
Eigen::ei_aligned_free(ptr);
}
inline void *qRealloc(void *ptr, size_t size)
{
void* newPtr = Eigen::ei_aligned_malloc(size);
memcpy(newPtr, ptr, size);
Eigen::ei_aligned_free(ptr);
return newPtr;
}
#endif
#endif // EIGEN_QTMALLOC_MODULE_H

29
extern/Eigen2/Eigen/SVD vendored Normal file
View File

@@ -0,0 +1,29 @@
#ifndef EIGEN_SVD_MODULE_H
#define EIGEN_SVD_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen {
/** \defgroup SVD_Module SVD module
*
* \nonstableyet
*
* This module provides SVD decomposition for (currently) real matrices.
* This decomposition is accessible via the following MatrixBase method:
* - MatrixBase::svd()
*
* \code
* #include <Eigen/SVD>
* \endcode
*/
#include "src/SVD/SVD.h"
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_SVD_MODULE_H

132
extern/Eigen2/Eigen/Sparse vendored Normal file
View File

@@ -0,0 +1,132 @@
#ifndef EIGEN_SPARSE_MODULE_H
#define EIGEN_SPARSE_MODULE_H
#include "Core"
#include "src/Core/util/DisableMSVCWarnings.h"
#include <vector>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#ifdef EIGEN_GOOGLEHASH_SUPPORT
#include <google/dense_hash_map>
#endif
#ifdef EIGEN_CHOLMOD_SUPPORT
extern "C" {
#include "cholmod.h"
}
#endif
#ifdef EIGEN_TAUCS_SUPPORT
// taucs.h declares a lot of mess
#define isnan
#define finite
#define isinf
extern "C" {
#include "taucs.h"
}
#undef isnan
#undef finite
#undef isinf
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef complex
#undef complex
#endif
#endif
#ifdef EIGEN_SUPERLU_SUPPORT
typedef int int_t;
#include "superlu/slu_Cnames.h"
#include "superlu/supermatrix.h"
#include "superlu/slu_util.h"
namespace SuperLU_S {
#include "superlu/slu_sdefs.h"
}
namespace SuperLU_D {
#include "superlu/slu_ddefs.h"
}
namespace SuperLU_C {
#include "superlu/slu_cdefs.h"
}
namespace SuperLU_Z {
#include "superlu/slu_zdefs.h"
}
namespace Eigen { struct SluMatrix; }
#endif
#ifdef EIGEN_UMFPACK_SUPPORT
#include "umfpack.h"
#endif
namespace Eigen {
/** \defgroup Sparse_Module Sparse module
*
* \nonstableyet
*
* See the \ref TutorialSparse "Sparse tutorial"
*
* \code
* #include <Eigen/QR>
* \endcode
*/
#include "src/Sparse/SparseUtil.h"
#include "src/Sparse/SparseMatrixBase.h"
#include "src/Sparse/CompressedStorage.h"
#include "src/Sparse/AmbiVector.h"
#include "src/Sparse/RandomSetter.h"
#include "src/Sparse/SparseBlock.h"
#include "src/Sparse/SparseMatrix.h"
#include "src/Sparse/DynamicSparseMatrix.h"
#include "src/Sparse/MappedSparseMatrix.h"
#include "src/Sparse/SparseVector.h"
#include "src/Sparse/CoreIterators.h"
#include "src/Sparse/SparseTranspose.h"
#include "src/Sparse/SparseCwise.h"
#include "src/Sparse/SparseCwiseUnaryOp.h"
#include "src/Sparse/SparseCwiseBinaryOp.h"
#include "src/Sparse/SparseDot.h"
#include "src/Sparse/SparseAssign.h"
#include "src/Sparse/SparseRedux.h"
#include "src/Sparse/SparseFuzzy.h"
#include "src/Sparse/SparseFlagged.h"
#include "src/Sparse/SparseProduct.h"
#include "src/Sparse/SparseDiagonalProduct.h"
#include "src/Sparse/TriangularSolver.h"
#include "src/Sparse/SparseLLT.h"
#include "src/Sparse/SparseLDLT.h"
#include "src/Sparse/SparseLU.h"
#ifdef EIGEN_CHOLMOD_SUPPORT
# include "src/Sparse/CholmodSupport.h"
#endif
#ifdef EIGEN_TAUCS_SUPPORT
# include "src/Sparse/TaucsSupport.h"
#endif
#ifdef EIGEN_SUPERLU_SUPPORT
# include "src/Sparse/SuperLUSupport.h"
#endif
#ifdef EIGEN_UMFPACK_SUPPORT
# include "src/Sparse/UmfPackSupport.h"
#endif
} // namespace Eigen
#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_SPARSE_MODULE_H

147
extern/Eigen2/Eigen/StdVector vendored Normal file
View File

@@ -0,0 +1,147 @@
#ifdef EIGEN_USE_NEW_STDVECTOR
#include "NewStdVector"
#else
#ifndef EIGEN_STDVECTOR_MODULE_H
#define EIGEN_STDVECTOR_MODULE_H
#if defined(_GLIBCXX_VECTOR) || defined(_VECTOR_)
#error you must include <Eigen/StdVector> before <vector>. Also note that <Eigen/Sparse> includes <vector>, so it must be included after <Eigen/StdVector> too.
#endif
#ifndef EIGEN_GNUC_AT_LEAST
#ifdef __GNUC__
#define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x)
#else
#define EIGEN_GNUC_AT_LEAST(x,y) 0
#endif
#endif
#define vector std_vector
#include <vector>
#undef vector
namespace Eigen {
template<typename T> class aligned_allocator;
// meta programming to determine if a class has a given member
struct ei_does_not_have_aligned_operator_new_marker_sizeof {int a[1];};
struct ei_has_aligned_operator_new_marker_sizeof {int a[2];};
template<typename ClassType>
struct ei_has_aligned_operator_new {
template<typename T>
static ei_has_aligned_operator_new_marker_sizeof
test(T const *, typename T::ei_operator_new_marker_type const * = 0);
static ei_does_not_have_aligned_operator_new_marker_sizeof
test(...);
// note that the following indirection is needed for gcc-3.3
enum {ret = sizeof(test(static_cast<ClassType*>(0)))
== sizeof(ei_has_aligned_operator_new_marker_sizeof) };
};
#ifdef _MSC_VER
// sometimes, MSVC detects, at compile time, that the argument x
// in std::vector::resize(size_t s,T x) won't be aligned and generate an error
// even if this function is never called. Whence this little wrapper.
#define _EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) Eigen::ei_workaround_msvc_std_vector<T>
template<typename T> struct ei_workaround_msvc_std_vector : public T
{
inline ei_workaround_msvc_std_vector() : T() {}
inline ei_workaround_msvc_std_vector(const T& other) : T(other) {}
inline operator T& () { return *static_cast<T*>(this); }
inline operator const T& () const { return *static_cast<const T*>(this); }
template<typename OtherT>
inline T& operator=(const OtherT& other)
{ T::operator=(other); return *this; }
inline ei_workaround_msvc_std_vector& operator=(const ei_workaround_msvc_std_vector& other)
{ T::operator=(other); return *this; }
};
#else
#define _EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) T
#endif
}
namespace std {
#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
public: \
typedef T value_type; \
typedef typename vector_base::allocator_type allocator_type; \
typedef typename vector_base::size_type size_type; \
typedef typename vector_base::iterator iterator; \
explicit vector(const allocator_type& __a = allocator_type()) : vector_base(__a) {} \
vector(const vector& c) : vector_base(c) {} \
vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
vector(iterator start, iterator end) : vector_base(start, end) {} \
vector& operator=(const vector& __x) { \
vector_base::operator=(__x); \
return *this; \
}
template<typename T,
typename AllocT = std::allocator<T>,
bool HasAlignedNew = Eigen::ei_has_aligned_operator_new<T>::ret>
class vector : public std::std_vector<T,AllocT>
{
typedef std_vector<T, AllocT> vector_base;
EIGEN_STD_VECTOR_SPECIALIZATION_BODY
};
template<typename T,typename DummyAlloc>
class vector<T,DummyAlloc,true>
: public std::std_vector<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
Eigen::aligned_allocator<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> >
{
typedef std_vector<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
Eigen::aligned_allocator<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> > vector_base;
EIGEN_STD_VECTOR_SPECIALIZATION_BODY
void resize(size_type __new_size)
{ resize(__new_size, T()); }
#if defined(_VECTOR_)
// workaround MSVC std::vector implementation
void resize(size_type __new_size, const value_type& __x)
{
if (vector_base::size() < __new_size)
vector_base::_Insert_n(vector_base::end(), __new_size - vector_base::size(), __x);
else if (__new_size < vector_base::size())
vector_base::erase(vector_base::begin() + __new_size, vector_base::end());
}
#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
// workaround GCC std::vector implementation
void resize(size_type __new_size, const value_type& __x)
{
if (__new_size < vector_base::size())
vector_base::_M_erase_at_end(this->_M_impl._M_start + __new_size);
else
vector_base::insert(vector_base::end(), __new_size - vector_base::size(), __x);
}
#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,1)
void resize(size_type __new_size, const value_type& __x)
{
if (__new_size < vector_base::size())
vector_base::erase(vector_base::begin() + __new_size, vector_base::end());
else
vector_base::insert(vector_base::end(), __new_size - vector_base::size(), __x);
}
#else
// Before gcc-4.1 we already have: std::vector::resize(size_type,const T&),
// so no need for a workaround !
using vector_base::resize;
#endif
};
}
#endif // EIGEN_STDVECTOR_MODULE_H
#endif // EIGEN_USE_NEW_STDVECTOR

View File

@@ -0,0 +1,145 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ALLANDANY_H
#define EIGEN_ALLANDANY_H
template<typename Derived, int UnrollCount>
struct ei_all_unroller
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
row = (UnrollCount-1) % Derived::RowsAtCompileTime
};
inline static bool run(const Derived &mat)
{
return ei_all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col);
}
};
template<typename Derived>
struct ei_all_unroller<Derived, 1>
{
inline static bool run(const Derived &mat) { return mat.coeff(0, 0); }
};
template<typename Derived>
struct ei_all_unroller<Derived, Dynamic>
{
inline static bool run(const Derived &) { return false; }
};
template<typename Derived, int UnrollCount>
struct ei_any_unroller
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
row = (UnrollCount-1) % Derived::RowsAtCompileTime
};
inline static bool run(const Derived &mat)
{
return ei_any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col);
}
};
template<typename Derived>
struct ei_any_unroller<Derived, 1>
{
inline static bool run(const Derived &mat) { return mat.coeff(0, 0); }
};
template<typename Derived>
struct ei_any_unroller<Derived, Dynamic>
{
inline static bool run(const Derived &) { return false; }
};
/** \array_module
*
* \returns true if all coefficients are true
*
* \addexample CwiseAll \label How to check whether a point is inside a box (using operator< and all())
*
* Example: \include MatrixBase_all.cpp
* Output: \verbinclude MatrixBase_all.out
*
* \sa MatrixBase::any(), Cwise::operator<()
*/
template<typename Derived>
inline bool MatrixBase<Derived>::all() const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;
if(unroll)
return ei_all_unroller<Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived());
else
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
if (!coeff(i, j)) return false;
return true;
}
}
/** \array_module
*
* \returns true if at least one coefficient is true
*
* \sa MatrixBase::all()
*/
template<typename Derived>
inline bool MatrixBase<Derived>::any() const
{
const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
<= EIGEN_UNROLLING_LIMIT;
if(unroll)
return ei_any_unroller<Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived());
else
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
if (coeff(i, j)) return true;
return false;
}
}
/** \array_module
*
* \returns the number of coefficients which evaluate to true
*
* \sa MatrixBase::all(), MatrixBase::any()
*/
template<typename Derived>
inline int MatrixBase<Derived>::count() const
{
return this->cast<bool>().cast<int>().sum();
}
#endif // EIGEN_ALLANDANY_H

View File

@@ -0,0 +1,453 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
#define EIGEN_ARRAY_CWISE_OPERATORS_H
// -- unary operators --
/** \array_module
*
* \returns an expression of the coefficient-wise square root of *this.
*
* Example: \include Cwise_sqrt.cpp
* Output: \verbinclude Cwise_sqrt.out
*
* \sa pow(), square()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
Cwise<ExpressionType>::sqrt() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise exponential of *this.
*
* Example: \include Cwise_exp.cpp
* Output: \verbinclude Cwise_exp.out
*
* \sa pow(), log(), sin(), cos()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
Cwise<ExpressionType>::exp() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise logarithm of *this.
*
* Example: \include Cwise_log.cpp
* Output: \verbinclude Cwise_log.out
*
* \sa exp()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
Cwise<ExpressionType>::log() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise cosine of *this.
*
* Example: \include Cwise_cos.cpp
* Output: \verbinclude Cwise_cos.out
*
* \sa sin(), exp()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
Cwise<ExpressionType>::cos() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise sine of *this.
*
* Example: \include Cwise_sin.cpp
* Output: \verbinclude Cwise_sin.out
*
* \sa cos(), exp()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
Cwise<ExpressionType>::sin() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise power of *this to the given exponent.
*
* Example: \include Cwise_pow.cpp
* Output: \verbinclude Cwise_pow.out
*
* \sa exp(), log()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
Cwise<ExpressionType>::pow(const Scalar& exponent) const
{
return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent));
}
/** \array_module
*
* \returns an expression of the coefficient-wise inverse of *this.
*
* Example: \include Cwise_inverse.cpp
* Output: \verbinclude Cwise_inverse.out
*
* \sa operator/(), operator*()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
Cwise<ExpressionType>::inverse() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise square of *this.
*
* Example: \include Cwise_square.cpp
* Output: \verbinclude Cwise_square.out
*
* \sa operator/(), operator*(), abs2()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
Cwise<ExpressionType>::square() const
{
return _expression();
}
/** \array_module
*
* \returns an expression of the coefficient-wise cube of *this.
*
* Example: \include Cwise_cube.cpp
* Output: \verbinclude Cwise_cube.out
*
* \sa square(), pow()
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
Cwise<ExpressionType>::cube() const
{
return _expression();
}
// -- binary operators --
/** \array_module
*
* \returns an expression of the coefficient-wise \< operator of *this and \a other
*
* Example: \include Cwise_less.cpp
* Output: \verbinclude Cwise_less.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
}
/** \array_module
*
* \returns an expression of the coefficient-wise \<= operator of *this and \a other
*
* Example: \include Cwise_less_equal.cpp
* Output: \verbinclude Cwise_less_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
}
/** \array_module
*
* \returns an expression of the coefficient-wise \> operator of *this and \a other
*
* Example: \include Cwise_greater.cpp
* Output: \verbinclude Cwise_greater.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
}
/** \array_module
*
* \returns an expression of the coefficient-wise \>= operator of *this and \a other
*
* Example: \include Cwise_greater_equal.cpp
* Output: \verbinclude Cwise_greater_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
}
/** \array_module
*
* \returns an expression of the coefficient-wise == operator of *this and \a other
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* Example: \include Cwise_equal_equal.cpp
* Output: \verbinclude Cwise_equal_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
}
/** \array_module
*
* \returns an expression of the coefficient-wise != operator of *this and \a other
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* Example: \include Cwise_not_equal.cpp
* Output: \verbinclude Cwise_not_equal.out
*
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
}
// comparisons to scalar value
/** \array_module
*
* \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s
*
* \sa operator<(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
Cwise<ExpressionType>::operator<(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
/** \array_module
*
* \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s
*
* \sa operator<=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType>::operator<=(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
/** \array_module
*
* \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s
*
* \sa operator>(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
Cwise<ExpressionType>::operator>(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
/** \array_module
*
* \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s
*
* \sa operator>=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType>::operator>=(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
/** \array_module
*
* \returns an expression of the coefficient-wise == operator of *this and a scalar \a s
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* \sa operator==(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType>::operator==(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
/** \array_module
*
* \returns an expression of the coefficient-wise != operator of *this and a scalar \a s
*
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
* In order to check for equality between two vectors or matrices with floating-point coefficients, it is
* generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
* MatrixBase::isMuchSmallerThan().
*
* \sa operator!=(const MatrixBase<OtherDerived> &) const
*/
template<typename ExpressionType>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType>::operator!=(Scalar s) const
{
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
}
// scalar addition
/** \array_module
*
* \returns an expression of \c *this with each coeff incremented by the constant \a scalar
*
* Example: \include Cwise_plus.cpp
* Output: \verbinclude Cwise_plus.out
*
* \sa operator+=(), operator-()
*/
template<typename ExpressionType>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType>::operator+(const Scalar& scalar) const
{
return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
}
/** \array_module
*
* Adds the given \a scalar to each coeff of this expression.
*
* Example: \include Cwise_plus_equal.cpp
* Output: \verbinclude Cwise_plus_equal.out
*
* \sa operator+(), operator-=()
*/
template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
{
return m_matrix.const_cast_derived() = *this + scalar;
}
/** \array_module
*
* \returns an expression of \c *this with each coeff decremented by the constant \a scalar
*
* Example: \include Cwise_minus.cpp
* Output: \verbinclude Cwise_minus.out
*
* \sa operator+(), operator-=()
*/
template<typename ExpressionType>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType
Cwise<ExpressionType>::operator-(const Scalar& scalar) const
{
return *this + (-scalar);
}
/** \array_module
*
* Substracts the given \a scalar from each coeff of this expression.
*
* Example: \include Cwise_minus_equal.cpp
* Output: \verbinclude Cwise_minus_equal.out
*
* \sa operator+=(), operator-()
*/
template<typename ExpressionType>
inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
{
return m_matrix.const_cast_derived() = *this - scalar;
}
#endif // EIGEN_ARRAY_CWISE_OPERATORS_H

309
extern/Eigen2/Eigen/src/Array/Functors.h vendored Normal file
View File

@@ -0,0 +1,309 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ARRAY_FUNCTORS_H
#define EIGEN_ARRAY_FUNCTORS_H
/** \internal
* \array_module
*
* \brief Template functor to add a scalar to a fixed other one
*
* \sa class CwiseUnaryOp, Array::operator+
*/
/* If you wonder why doing the ei_pset1() in packetOp() is an optimization check ei_scalar_multiple_op */
template<typename Scalar>
struct ei_scalar_add_op {
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
// FIXME default copy constructors seems bugged with std::complex<>
inline ei_scalar_add_op(const ei_scalar_add_op& other) : m_other(other.m_other) { }
inline ei_scalar_add_op(const Scalar& other) : m_other(other) { }
inline Scalar operator() (const Scalar& a) const { return a + m_other; }
inline const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_padd(a, ei_pset1(m_other)); }
const Scalar m_other;
private:
ei_scalar_add_op& operator=(const ei_scalar_add_op&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_add_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = ei_packet_traits<Scalar>::size>1 }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the square root of a scalar
*
* \sa class CwiseUnaryOp, Cwise::sqrt()
*/
template<typename Scalar> struct ei_scalar_sqrt_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_sqrt(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the exponential of a scalar
*
* \sa class CwiseUnaryOp, Cwise::exp()
*/
template<typename Scalar> struct ei_scalar_exp_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_exp(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_exp_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the logarithm of a scalar
*
* \sa class CwiseUnaryOp, Cwise::log()
*/
template<typename Scalar> struct ei_scalar_log_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_log(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_log_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the cosine of a scalar
*
* \sa class CwiseUnaryOp, Cwise::cos()
*/
template<typename Scalar> struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_cos(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the sine of a scalar
*
* \sa class CwiseUnaryOp, Cwise::sin()
*/
template<typename Scalar> struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT {
inline const Scalar operator() (const Scalar& a) const { return ei_sin(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_sin_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to raise a scalar to a power
*
* \sa class CwiseUnaryOp, Cwise::pow
*/
template<typename Scalar>
struct ei_scalar_pow_op {
// FIXME default copy constructors seems bugged with std::complex<>
inline ei_scalar_pow_op(const ei_scalar_pow_op& other) : m_exponent(other.m_exponent) { }
inline ei_scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {}
inline Scalar operator() (const Scalar& a) const { return ei_pow(a, m_exponent); }
const Scalar m_exponent;
private:
ei_scalar_pow_op& operator=(const ei_scalar_pow_op&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_pow_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the inverse of a scalar
*
* \sa class CwiseUnaryOp, Cwise::inverse()
*/
template<typename Scalar>
struct ei_scalar_inverse_op {
inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
template<typename PacketScalar>
inline const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pdiv(ei_pset1(Scalar(1)),a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_inverse_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the square of a scalar
*
* \sa class CwiseUnaryOp, Cwise::square()
*/
template<typename Scalar>
struct ei_scalar_square_op {
inline Scalar operator() (const Scalar& a) const { return a*a; }
template<typename PacketScalar>
inline const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pmul(a,a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_square_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
/** \internal
*
* \array_module
*
* \brief Template functor to compute the cube of a scalar
*
* \sa class CwiseUnaryOp, Cwise::cube()
*/
template<typename Scalar>
struct ei_scalar_cube_op {
inline Scalar operator() (const Scalar& a) const { return a*a*a; }
template<typename PacketScalar>
inline const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pmul(a,ei_pmul(a,a)); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_cube_op<Scalar> >
{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
// default ei_functor_traits for STL functors:
template<typename T>
struct ei_functor_traits<std::multiplies<T> >
{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::divides<T> >
{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::plus<T> >
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::minus<T> >
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::negate<T> >
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::logical_or<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::logical_and<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::logical_not<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::greater<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::less<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::greater_equal<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::less_equal<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::equal_to<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::not_equal_to<T> >
{ enum { Cost = 1, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::binder2nd<T> >
{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::binder1st<T> >
{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::unary_negate<T> >
{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; };
template<typename T>
struct ei_functor_traits<std::binary_negate<T> >
{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; };
#ifdef EIGEN_STDEXT_SUPPORT
template<typename T0,typename T1>
struct ei_functor_traits<std::project1st<T0,T1> >
{ enum { Cost = 0, PacketAccess = false }; };
template<typename T0,typename T1>
struct ei_functor_traits<std::project2nd<T0,T1> >
{ enum { Cost = 0, PacketAccess = false }; };
template<typename T0,typename T1>
struct ei_functor_traits<std::select2nd<std::pair<T0,T1> > >
{ enum { Cost = 0, PacketAccess = false }; };
template<typename T0,typename T1>
struct ei_functor_traits<std::select1st<std::pair<T0,T1> > >
{ enum { Cost = 0, PacketAccess = false }; };
template<typename T0,typename T1>
struct ei_functor_traits<std::unary_compose<T0,T1> >
{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost, PacketAccess = false }; };
template<typename T0,typename T1,typename T2>
struct ei_functor_traits<std::binary_compose<T0,T1,T2> >
{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost + ei_functor_traits<T2>::Cost, PacketAccess = false }; };
#endif // EIGEN_STDEXT_SUPPORT
#endif // EIGEN_ARRAY_FUNCTORS_H

80
extern/Eigen2/Eigen/src/Array/Norms.h vendored Normal file
View File

@@ -0,0 +1,80 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ARRAY_NORMS_H
#define EIGEN_ARRAY_NORMS_H
template<typename Derived, int p>
struct ei_lpNorm_selector
{
typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar;
inline static RealScalar run(const MatrixBase<Derived>& m)
{
return ei_pow(m.cwise().abs().cwise().pow(p).sum(), RealScalar(1)/p);
}
};
template<typename Derived>
struct ei_lpNorm_selector<Derived, 1>
{
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{
return m.cwise().abs().sum();
}
};
template<typename Derived>
struct ei_lpNorm_selector<Derived, 2>
{
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{
return m.norm();
}
};
template<typename Derived>
struct ei_lpNorm_selector<Derived, Infinity>
{
inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
{
return m.cwise().abs().maxCoeff();
}
};
/** \array_module
*
* \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values
* of the coefficients of *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^p\infty \f$
* norm, that is the maximum of the absolute values of the coefficients of *this.
*
* \sa norm()
*/
template<typename Derived>
template<int p>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::lpNorm() const
{
return ei_lpNorm_selector<Derived, p>::run(*this);
}
#endif // EIGEN_ARRAY_NORMS_H

View File

@@ -0,0 +1,347 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PARTIAL_REDUX_H
#define EIGEN_PARTIAL_REDUX_H
/** \array_module \ingroup Array
*
* \class PartialReduxExpr
*
* \brief Generic expression of a partially reduxed matrix
*
* \param MatrixType the type of the matrix we are applying the redux operation
* \param MemberOp type of the member functor
* \param Direction indicates the direction of the redux (Vertical or Horizontal)
*
* This class represents an expression of a partial redux operator of a matrix.
* It is the return type of PartialRedux functions,
* and most of the time this is the only way it is used.
*
* \sa class PartialRedux
*/
template< typename MatrixType, typename MemberOp, int Direction>
class PartialReduxExpr;
template<typename MatrixType, typename MemberOp, int Direction>
struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
{
typedef typename MemberOp::result_type Scalar;
typedef typename MatrixType::Scalar InputScalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
enum {
RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime,
ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
Flags = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits,
TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime
};
#if EIGEN_GNUC_AT_LEAST(3,4)
typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
#else
typedef typename MemberOp::template Cost<InputScalar,TraversalSize> CostOpType;
#endif
enum {
CoeffReadCost = TraversalSize * ei_traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value)
};
};
template< typename MatrixType, typename MemberOp, int Direction>
class PartialReduxExpr : ei_no_assignment_operator,
public MatrixBase<PartialReduxExpr<MatrixType, MemberOp, Direction> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;
PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
: m_matrix(mat), m_functor(func) {}
int rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); }
int cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
const Scalar coeff(int i, int j) const
{
if (Direction==Vertical)
return m_functor(m_matrix.col(j));
else
return m_functor(m_matrix.row(i));
}
protected:
const MatrixTypeNested m_matrix;
const MemberOp m_functor;
};
#define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
template <typename ResultType> \
struct ei_member_##MEMBER EIGEN_EMPTY_STRUCT { \
typedef ResultType result_type; \
template<typename Scalar, int Size> struct Cost \
{ enum { value = COST }; }; \
template<typename Derived> \
inline ResultType operator()(const MatrixBase<Derived>& mat) const \
{ return mat.MEMBER(); } \
}
EIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);
EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);
/** \internal */
template <typename BinaryOp, typename Scalar>
struct ei_member_redux {
typedef typename ei_result_of<
BinaryOp(Scalar)
>::type result_type;
template<typename _Scalar, int Size> struct Cost
{ enum { value = (Size-1) * ei_functor_traits<BinaryOp>::Cost }; };
ei_member_redux(const BinaryOp func) : m_functor(func) {}
template<typename Derived>
inline result_type operator()(const MatrixBase<Derived>& mat) const
{ return mat.redux(m_functor); }
const BinaryOp m_functor;
private:
ei_member_redux& operator=(const ei_member_redux&);
};
/** \array_module \ingroup Array
*
* \class PartialRedux
*
* \brief Pseudo expression providing partial reduction operations
*
* \param ExpressionType the type of the object on which to do partial reductions
* \param Direction indicates the direction of the redux (Vertical or Horizontal)
*
* This class represents a pseudo expression with partial reduction features.
* It is the return type of MatrixBase::colwise() and MatrixBase::rowwise()
* and most of the time this is the only way it is used.
*
* Example: \include MatrixBase_colwise.cpp
* Output: \verbinclude MatrixBase_colwise.out
*
* \sa MatrixBase::colwise(), MatrixBase::rowwise(), class PartialReduxExpr
*/
template<typename ExpressionType, int Direction> class PartialRedux
{
public:
typedef typename ei_traits<ExpressionType>::Scalar Scalar;
typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
template<template<typename _Scalar> class Functor> struct ReturnType
{
typedef PartialReduxExpr<ExpressionType,
Functor<typename ei_traits<ExpressionType>::Scalar>,
Direction
> Type;
};
template<typename BinaryOp> struct ReduxReturnType
{
typedef PartialReduxExpr<ExpressionType,
ei_member_redux<BinaryOp,typename ei_traits<ExpressionType>::Scalar>,
Direction
> Type;
};
typedef typename ExpressionType::PlainMatrixType CrossReturnType;
inline PartialRedux(const ExpressionType& matrix) : m_matrix(matrix) {}
/** \internal */
inline const ExpressionType& _expression() const { return m_matrix; }
template<typename BinaryOp>
const typename ReduxReturnType<BinaryOp>::Type
redux(const BinaryOp& func = BinaryOp()) const;
/** \returns a row (or column) vector expression of the smallest coefficient
* of each column (or row) of the referenced expression.
*
* Example: \include PartialRedux_minCoeff.cpp
* Output: \verbinclude PartialRedux_minCoeff.out
*
* \sa MatrixBase::minCoeff() */
const typename ReturnType<ei_member_minCoeff>::Type minCoeff() const
{ return _expression(); }
/** \returns a row (or column) vector expression of the largest coefficient
* of each column (or row) of the referenced expression.
*
* Example: \include PartialRedux_maxCoeff.cpp
* Output: \verbinclude PartialRedux_maxCoeff.out
*
* \sa MatrixBase::maxCoeff() */
const typename ReturnType<ei_member_maxCoeff>::Type maxCoeff() const
{ return _expression(); }
/** \returns a row (or column) vector expression of the squared norm
* of each column (or row) of the referenced expression.
*
* Example: \include PartialRedux_squaredNorm.cpp
* Output: \verbinclude PartialRedux_squaredNorm.out
*
* \sa MatrixBase::squaredNorm() */
const typename ReturnType<ei_member_squaredNorm>::Type squaredNorm() const
{ return _expression(); }
/** \returns a row (or column) vector expression of the norm
* of each column (or row) of the referenced expression.
*
* Example: \include PartialRedux_norm.cpp
* Output: \verbinclude PartialRedux_norm.out
*
* \sa MatrixBase::norm() */
const typename ReturnType<ei_member_norm>::Type norm() const
{ return _expression(); }
/** \returns a row (or column) vector expression of the sum
* of each column (or row) of the referenced expression.
*
* Example: \include PartialRedux_sum.cpp
* Output: \verbinclude PartialRedux_sum.out
*
* \sa MatrixBase::sum() */
const typename ReturnType<ei_member_sum>::Type sum() const
{ return _expression(); }
/** \returns a row (or column) vector expression representing
* whether \b all coefficients of each respective column (or row) are \c true.
*
* \sa MatrixBase::all() */
const typename ReturnType<ei_member_all>::Type all() const
{ return _expression(); }
/** \returns a row (or column) vector expression representing
* whether \b at \b least one coefficient of each respective column (or row) is \c true.
*
* \sa MatrixBase::any() */
const typename ReturnType<ei_member_any>::Type any() const
{ return _expression(); }
/** \returns a row (or column) vector expression representing
* the number of \c true coefficients of each respective column (or row).
*
* Example: \include PartialRedux_count.cpp
* Output: \verbinclude PartialRedux_count.out
*
* \sa MatrixBase::count() */
const PartialReduxExpr<ExpressionType, ei_member_count<int>, Direction> count() const
{ return _expression(); }
/** \returns a 3x3 matrix expression of the cross product
* of each column or row of the referenced expression with the \a other vector.
*
* \geometry_module
*
* \sa MatrixBase::cross() */
template<typename OtherDerived>
const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(CrossReturnType,3,3)
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
if(Direction==Vertical)
return (CrossReturnType()
<< _expression().col(0).cross(other),
_expression().col(1).cross(other),
_expression().col(2).cross(other)).finished();
else
return (CrossReturnType()
<< _expression().row(0).cross(other),
_expression().row(1).cross(other),
_expression().row(2).cross(other)).finished();
}
protected:
ExpressionTypeNested m_matrix;
private:
PartialRedux& operator=(const PartialRedux&);
};
/** \array_module
*
* \returns a PartialRedux wrapper of *this providing additional partial reduction operations
*
* Example: \include MatrixBase_colwise.cpp
* Output: \verbinclude MatrixBase_colwise.out
*
* \sa rowwise(), class PartialRedux
*/
template<typename Derived>
inline const PartialRedux<Derived,Vertical>
MatrixBase<Derived>::colwise() const
{
return derived();
}
/** \array_module
*
* \returns a PartialRedux wrapper of *this providing additional partial reduction operations
*
* Example: \include MatrixBase_rowwise.cpp
* Output: \verbinclude MatrixBase_rowwise.out
*
* \sa colwise(), class PartialRedux
*/
template<typename Derived>
inline const PartialRedux<Derived,Horizontal>
MatrixBase<Derived>::rowwise() const
{
return derived();
}
/** \returns a row or column vector expression of \c *this reduxed by \a func
*
* The template parameter \a BinaryOp is the type of the functor
* of the custom redux operator. Note that func must be an associative operator.
*
* \sa class PartialRedux, MatrixBase::colwise(), MatrixBase::rowwise()
*/
template<typename ExpressionType, int Direction>
template<typename BinaryOp>
const typename PartialRedux<ExpressionType,Direction>::template ReduxReturnType<BinaryOp>::Type
PartialRedux<ExpressionType,Direction>::redux(const BinaryOp& func) const
{
return typename ReduxReturnType<BinaryOp>::Type(_expression(), func);
}
#endif // EIGEN_PARTIAL_REDUX_H

156
extern/Eigen2/Eigen/src/Array/Random.h vendored Normal file
View File

@@ -0,0 +1,156 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_RANDOM_H
#define EIGEN_RANDOM_H
template<typename Scalar> struct ei_scalar_random_op EIGEN_EMPTY_STRUCT {
inline ei_scalar_random_op(void) {}
inline const Scalar operator() (int, int) const { return ei_random<Scalar>(); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_random_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
/** \array_module
*
* \returns a random matrix (not an expression, the matrix is immediately evaluated).
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so ei_random() should be used
* instead.
*
* \addexample RandomExample \label How to create a matrix with random coefficients
*
* Example: \include MatrixBase_random_int_int.cpp
* Output: \verbinclude MatrixBase_random_int_int.out
*
* \sa MatrixBase::setRandom(), MatrixBase::Random(int), MatrixBase::Random()
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::Random(int rows, int cols)
{
return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>());
}
/** \array_module
*
* \returns a random vector (not an expression, the vector is immediately evaluated).
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
*
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
* it is redundant to pass \a size as argument, so ei_random() should be used
* instead.
*
* Example: \include MatrixBase_random_int.cpp
* Output: \verbinclude MatrixBase_random_int.out
*
* \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random()
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::Random(int size)
{
return NullaryExpr(size, ei_scalar_random_op<Scalar>());
}
/** \array_module
*
* \returns a fixed-size random matrix or vector
* (not an expression, the matrix is immediately evaluated).
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* Example: \include MatrixBase_random.cpp
* Output: \verbinclude MatrixBase_random.out
*
* \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random(int)
*/
template<typename Derived>
inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::Random()
{
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>());
}
/** \array_module
*
* Sets all coefficients in this expression to random values.
*
* Example: \include MatrixBase_setRandom.cpp
* Output: \verbinclude MatrixBase_setRandom.out
*
* \sa class CwiseNullaryOp, setRandom(int), setRandom(int,int)
*/
template<typename Derived>
inline Derived& MatrixBase<Derived>::setRandom()
{
return *this = Random(rows(), cols());
}
/** Resizes to the given \a size, and sets all coefficients in this expression to random values.
*
* \only_for_vectors
*
* Example: \include Matrix_setRandom_int.cpp
* Output: \verbinclude Matrix_setRandom_int.out
*
* \sa MatrixBase::setRandom(), setRandom(int,int), class CwiseNullaryOp, MatrixBase::Random()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
{
resize(size);
return setRandom();
}
/** Resizes to the given size, and sets all coefficients in this expression to random values.
*
* \param rows the new number of rows
* \param cols the new number of columns
*
* Example: \include Matrix_setRandom_int_int.cpp
* Output: \verbinclude Matrix_setRandom_int_int.out
*
* \sa MatrixBase::setRandom(), setRandom(int), class CwiseNullaryOp, MatrixBase::Random()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
{
resize(rows, cols);
return setRandom();
}
#endif // EIGEN_RANDOM_H

159
extern/Eigen2/Eigen/src/Array/Select.h vendored Normal file
View File

@@ -0,0 +1,159 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_SELECT_H
#define EIGEN_SELECT_H
/** \array_module \ingroup Array
*
* \class Select
*
* \brief Expression of a coefficient wise version of the C++ ternary operator ?:
*
* \param ConditionMatrixType the type of the \em condition expression which must be a boolean matrix
* \param ThenMatrixType the type of the \em then expression
* \param ElseMatrixType the type of the \em else expression
*
* This class represents an expression of a coefficient wise version of the C++ ternary operator ?:.
* It is the return type of MatrixBase::select() and most of the time this is the only way it is used.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const
*/
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{
typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
typedef typename ThenMatrixType::Nested ThenMatrixNested;
typedef typename ElseMatrixType::Nested ElseMatrixNested;
enum {
RowsAtCompileTime = ConditionMatrixType::RowsAtCompileTime,
ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,
Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits,
CoeffReadCost = ei_traits<typename ei_cleantype<ConditionMatrixNested>::type>::CoeffReadCost
+ EIGEN_ENUM_MAX(ei_traits<typename ei_cleantype<ThenMatrixNested>::type>::CoeffReadCost,
ei_traits<typename ei_cleantype<ElseMatrixNested>::type>::CoeffReadCost)
};
};
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
class Select : ei_no_assignment_operator,
public MatrixBase<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix,
const ThenMatrixType& thenMatrix,
const ElseMatrixType& elseMatrix)
: m_condition(conditionMatrix), m_then(thenMatrix), m_else(elseMatrix)
{
ei_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());
ei_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
}
int rows() const { return m_condition.rows(); }
int cols() const { return m_condition.cols(); }
const Scalar coeff(int i, int j) const
{
if (m_condition.coeff(i,j))
return m_then.coeff(i,j);
else
return m_else.coeff(i,j);
}
const Scalar coeff(int i) const
{
if (m_condition.coeff(i))
return m_then.coeff(i);
else
return m_else.coeff(i);
}
protected:
const typename ConditionMatrixType::Nested m_condition;
const typename ThenMatrixType::Nested m_then;
const typename ElseMatrixType::Nested m_else;
};
/** \array_module
*
* \returns a matrix where each coefficient (i,j) is equal to \a thenMatrix(i,j)
* if \c *this(i,j), and \a elseMatrix(i,j) otherwise.
*
* Example: \include MatrixBase_select.cpp
* Output: \verbinclude MatrixBase_select.out
*
* \sa class Select
*/
template<typename Derived>
template<typename ThenDerived,typename ElseDerived>
inline const Select<Derived,ThenDerived,ElseDerived>
MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
const MatrixBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,ThenDerived,ElseDerived>(derived(), thenMatrix.derived(), elseMatrix.derived());
}
/** \array_module
*
* Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* the \em else expression being a scalar value.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ThenDerived>
inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
typename ThenDerived::Scalar elseScalar) const
{
return Select<Derived,ThenDerived,NestByValue<typename ThenDerived::ConstantReturnType> >(
derived(), thenMatrix.derived(), ThenDerived::Constant(rows(),cols(),elseScalar));
}
/** \array_module
*
* Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* the \em then expression being a scalar value.
*
* \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ElseDerived>
inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
MatrixBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
const MatrixBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,NestByValue<typename ElseDerived::ConstantReturnType>,ElseDerived>(
derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());
}
#endif // EIGEN_SELECT_H

View File

@@ -0,0 +1,35 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_EXTERN_INSTANTIATIONS
#define EIGEN_EXTERN_INSTANTIATIONS
#endif
#include "../../Core"
#undef EIGEN_EXTERN_INSTANTIATIONS
#include "../../Cholesky"
namespace Eigen {
EIGEN_CHOLESKY_MODULE_INSTANTIATE();
}

198
extern/Eigen2/Eigen/src/Cholesky/LDLT.h vendored Normal file
View File

@@ -0,0 +1,198 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_LDLT_H
#define EIGEN_LDLT_H
/** \ingroup cholesky_Module
*
* \class LDLT
*
* \brief Robust Cholesky decomposition of a matrix and associated features
*
* \param MatrixType the type of the matrix of which we are computing the LDL^T Cholesky decomposition
*
* This class performs a Cholesky decomposition without square root of a symmetric, positive definite
* matrix A such that A = L D L^* = U^* D U, where L is lower triangular with a unit diagonal
* and D is a diagonal matrix.
*
* Compared to a standard Cholesky decomposition, avoiding the square roots allows for faster and more
* stable computation.
*
* Note that during the decomposition, only the upper triangular part of A is considered. Therefore,
* the strict lower part does not have to store correct values.
*
* \sa MatrixBase::ldlt(), class LLT
*/
template<typename MatrixType> class LDLT
{
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
LDLT(const MatrixType& matrix)
: m_matrix(matrix.rows(), matrix.cols())
{
compute(matrix);
}
/** \returns the lower triangular matrix L */
inline Part<MatrixType, UnitLowerTriangular> matrixL(void) const { return m_matrix; }
/** \returns the coefficients of the diagonal matrix D */
inline DiagonalCoeffs<MatrixType> vectorD(void) const { return m_matrix.diagonal(); }
/** \returns true if the matrix is positive definite */
inline bool isPositiveDefinite(void) const { return m_isPositiveDefinite; }
template<typename RhsDerived, typename ResultType>
bool solve(const MatrixBase<RhsDerived> &b, ResultType *result) const;
template<typename Derived>
bool solveInPlace(MatrixBase<Derived> &bAndX) const;
void compute(const MatrixType& matrix);
protected:
/** \internal
* Used to compute and store the cholesky decomposition A = L D L^* = U^* D U.
* The strict upper part is used during the decomposition, the strict lower
* part correspond to the coefficients of L (its diagonal is equal to 1 and
* is not stored), and the diagonal entries correspond to D.
*/
MatrixType m_matrix;
bool m_isPositiveDefinite;
};
/** Compute / recompute the LLT decomposition A = L D L^* = U^* D U of \a matrix
*/
template<typename MatrixType>
void LDLT<MatrixType>::compute(const MatrixType& a)
{
assert(a.rows()==a.cols());
const int size = a.rows();
m_matrix.resize(size, size);
m_isPositiveDefinite = true;
const RealScalar eps = ei_sqrt(precision<Scalar>());
if (size<=1)
{
m_matrix = a;
return;
}
// Let's preallocate a temporay vector to evaluate the matrix-vector product into it.
// Unlike the standard LLT decomposition, here we cannot evaluate it to the destination
// matrix because it a sub-row which is not compatible suitable for efficient packet evaluation.
// (at least if we assume the matrix is col-major)
Matrix<Scalar,MatrixType::RowsAtCompileTime,1> _temporary(size);
// Note that, in this algorithm the rows of the strict upper part of m_matrix is used to store
// column vector, thus the strange .conjugate() and .transpose()...
m_matrix.row(0) = a.row(0).conjugate();
m_matrix.col(0).end(size-1) = m_matrix.row(0).end(size-1) / m_matrix.coeff(0,0);
for (int j = 1; j < size; ++j)
{
RealScalar tmp = ei_real(a.coeff(j,j) - (m_matrix.row(j).start(j) * m_matrix.col(j).start(j).conjugate()).coeff(0,0));
m_matrix.coeffRef(j,j) = tmp;
if (tmp < eps)
{
m_isPositiveDefinite = false;
return;
}
int endSize = size-j-1;
if (endSize>0)
{
_temporary.end(endSize) = ( m_matrix.block(j+1,0, endSize, j)
* m_matrix.col(j).start(j).conjugate() ).lazy();
m_matrix.row(j).end(endSize) = a.row(j).end(endSize).conjugate()
- _temporary.end(endSize).transpose();
m_matrix.col(j).end(endSize) = m_matrix.row(j).end(endSize) / tmp;
}
}
}
/** Computes the solution x of \f$ A x = b \f$ using the current decomposition of A.
* The result is stored in \a result
*
* \returns true in case of success, false otherwise.
*
* In other words, it computes \f$ b = A^{-1} b \f$ with
* \f$ {L^{*}}^{-1} D^{-1} L^{-1} b \f$ from right to left.
*
* \sa LDLT::solveInPlace(), MatrixBase::ldlt()
*/
template<typename MatrixType>
template<typename RhsDerived, typename ResultType>
bool LDLT<MatrixType>
::solve(const MatrixBase<RhsDerived> &b, ResultType *result) const
{
const int size = m_matrix.rows();
ei_assert(size==b.rows() && "LLT::solve(): invalid number of rows of the right hand side matrix b");
*result = b;
return solveInPlace(*result);
}
/** This is the \em in-place version of solve().
*
* \param bAndX represents both the right-hand side matrix b and result x.
*
* This version avoids a copy when the right hand side matrix b is not
* needed anymore.
*
* \sa LDLT::solve(), MatrixBase::ldlt()
*/
template<typename MatrixType>
template<typename Derived>
bool LDLT<MatrixType>::solveInPlace(MatrixBase<Derived> &bAndX) const
{
const int size = m_matrix.rows();
ei_assert(size==bAndX.rows());
if (!m_isPositiveDefinite)
return false;
matrixL().solveTriangularInPlace(bAndX);
bAndX = (m_matrix.cwise().inverse().template part<Diagonal>() * bAndX).lazy();
m_matrix.adjoint().template part<UnitUpperTriangular>().solveTriangularInPlace(bAndX);
return true;
}
/** \cholesky_module
* \returns the Cholesky decomposition without square root of \c *this
*/
template<typename Derived>
inline const LDLT<typename MatrixBase<Derived>::PlainMatrixType>
MatrixBase<Derived>::ldlt() const
{
return derived();
}
#endif // EIGEN_LDLT_H

219
extern/Eigen2/Eigen/src/Cholesky/LLT.h vendored Normal file
View File

@@ -0,0 +1,219 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_LLT_H
#define EIGEN_LLT_H
/** \ingroup cholesky_Module
*
* \class LLT
*
* \brief Standard Cholesky decomposition (LL^T) of a matrix and associated features
*
* \param MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition
*
* This class performs a LL^T Cholesky decomposition of a symmetric, positive definite
* matrix A such that A = LL^* = U^*U, where L is lower triangular.
*
* While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b,
* for that purpose, we recommend the Cholesky decomposition without square root which is more stable
* and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other
* situations like generalised eigen problems with hermitian matrices.
*
* Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive definite matrices,
* use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine whether a system of equations
* has a solution.
*
* \sa MatrixBase::llt(), class LDLT
*/
/* HEY THIS DOX IS DISABLED BECAUSE THERE's A BUG EITHER HERE OR IN LDLT ABOUT THAT (OR BOTH)
* Note that during the decomposition, only the upper triangular part of A is considered. Therefore,
* the strict lower part does not have to store correct values.
*/
template<typename MatrixType> class LLT
{
private:
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
enum {
PacketSize = ei_packet_traits<Scalar>::size,
AlignmentMask = int(PacketSize)-1
};
public:
/**
* \brief Default Constructor.
*
* The default constructor is useful in cases in which the user intends to
* perform decompositions via LLT::compute(const MatrixType&).
*/
LLT() : m_matrix(), m_isInitialized(false) {}
LLT(const MatrixType& matrix)
: m_matrix(matrix.rows(), matrix.cols()),
m_isInitialized(false)
{
compute(matrix);
}
/** \returns the lower triangular matrix L */
inline Part<MatrixType, LowerTriangular> matrixL(void) const
{
ei_assert(m_isInitialized && "LLT is not initialized.");
return m_matrix;
}
/** \deprecated */
inline bool isPositiveDefinite(void) const { return m_isInitialized && m_isPositiveDefinite; }
template<typename RhsDerived, typename ResultType>
bool solve(const MatrixBase<RhsDerived> &b, ResultType *result) const;
template<typename Derived>
bool solveInPlace(MatrixBase<Derived> &bAndX) const;
void compute(const MatrixType& matrix);
protected:
/** \internal
* Used to compute and store L
* The strict upper part is not used and even not initialized.
*/
MatrixType m_matrix;
bool m_isInitialized;
bool m_isPositiveDefinite;
};
/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \a matrix
*/
template<typename MatrixType>
void LLT<MatrixType>::compute(const MatrixType& a)
{
assert(a.rows()==a.cols());
m_isPositiveDefinite = true;
const int size = a.rows();
m_matrix.resize(size, size);
// The biggest overall is the point of reference to which further diagonals
// are compared; if any diagonal is negligible compared
// to the largest overall, the algorithm bails. This cutoff is suggested
// in "Analysis of the Cholesky Decomposition of a Semi-definite Matrix" by
// Nicholas J. Higham. Also see "Accuracy and Stability of Numerical
// Algorithms" page 217, also by Higham.
const RealScalar cutoff = machine_epsilon<Scalar>() * size * a.diagonal().cwise().abs().maxCoeff();
RealScalar x;
x = ei_real(a.coeff(0,0));
m_matrix.coeffRef(0,0) = ei_sqrt(x);
if(size==1)
{
m_isInitialized = true;
return;
}
m_matrix.col(0).end(size-1) = a.row(0).end(size-1).adjoint() / ei_real(m_matrix.coeff(0,0));
for (int j = 1; j < size; ++j)
{
x = ei_real(a.coeff(j,j)) - m_matrix.row(j).start(j).squaredNorm();
if (x < cutoff)
{
m_isPositiveDefinite = false;
continue;
}
m_matrix.coeffRef(j,j) = x = ei_sqrt(x);
int endSize = size-j-1;
if (endSize>0) {
// Note that when all matrix columns have good alignment, then the following
// product is guaranteed to be optimal with respect to alignment.
m_matrix.col(j).end(endSize) =
(m_matrix.block(j+1, 0, endSize, j) * m_matrix.row(j).start(j).adjoint()).lazy();
// FIXME could use a.col instead of a.row
m_matrix.col(j).end(endSize) = (a.row(j).end(endSize).adjoint()
- m_matrix.col(j).end(endSize) ) / x;
}
}
m_isInitialized = true;
}
/** Computes the solution x of \f$ A x = b \f$ using the current decomposition of A.
* The result is stored in \a result
*
* \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.
*
* In other words, it computes \f$ b = A^{-1} b \f$ with
* \f$ {L^{*}}^{-1} L^{-1} b \f$ from right to left.
*
* Example: \include LLT_solve.cpp
* Output: \verbinclude LLT_solve.out
*
* \sa LLT::solveInPlace(), MatrixBase::llt()
*/
template<typename MatrixType>
template<typename RhsDerived, typename ResultType>
bool LLT<MatrixType>::solve(const MatrixBase<RhsDerived> &b, ResultType *result) const
{
ei_assert(m_isInitialized && "LLT is not initialized.");
const int size = m_matrix.rows();
ei_assert(size==b.rows() && "LLT::solve(): invalid number of rows of the right hand side matrix b");
return solveInPlace((*result) = b);
}
/** This is the \em in-place version of solve().
*
* \param bAndX represents both the right-hand side matrix b and result x.
*
* \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.
*
* This version avoids a copy when the right hand side matrix b is not
* needed anymore.
*
* \sa LLT::solve(), MatrixBase::llt()
*/
template<typename MatrixType>
template<typename Derived>
bool LLT<MatrixType>::solveInPlace(MatrixBase<Derived> &bAndX) const
{
ei_assert(m_isInitialized && "LLT is not initialized.");
const int size = m_matrix.rows();
ei_assert(size==bAndX.rows());
matrixL().solveTriangularInPlace(bAndX);
m_matrix.adjoint().template part<UpperTriangular>().solveTriangularInPlace(bAndX);
return true;
}
/** \cholesky_module
* \returns the LLT decomposition of \c *this
*/
template<typename Derived>
inline const LLT<typename MatrixBase<Derived>::PlainMatrixType>
MatrixBase<Derived>::llt() const
{
return LLT<PlainMatrixType>(derived());
}
#endif // EIGEN_LLT_H

445
extern/Eigen2/Eigen/src/Core/Assign.h vendored Normal file
View File

@@ -0,0 +1,445 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ASSIGN_H
#define EIGEN_ASSIGN_H
/***************************************************************************
* Part 1 : the logic deciding a strategy for vectorization and unrolling
***************************************************************************/
template <typename Derived, typename OtherDerived>
struct ei_assign_traits
{
public:
enum {
DstIsAligned = Derived::Flags & AlignedBit,
SrcIsAligned = OtherDerived::Flags & AlignedBit,
SrcAlignment = DstIsAligned && SrcIsAligned ? Aligned : Unaligned
};
private:
enum {
InnerSize = int(Derived::Flags)&RowMajorBit
? Derived::ColsAtCompileTime
: Derived::RowsAtCompileTime,
InnerMaxSize = int(Derived::Flags)&RowMajorBit
? Derived::MaxColsAtCompileTime
: Derived::MaxRowsAtCompileTime,
PacketSize = ei_packet_traits<typename Derived::Scalar>::size
};
enum {
MightVectorize = (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit)
&& ((int(Derived::Flags)&RowMajorBit)==(int(OtherDerived::Flags)&RowMajorBit)),
MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0
&& int(DstIsAligned) && int(SrcIsAligned),
MayLinearVectorize = MightVectorize && (int(Derived::Flags) & int(OtherDerived::Flags) & LinearAccessBit),
MaySliceVectorize = MightVectorize && int(InnerMaxSize)>=3*PacketSize /* slice vectorization can be slow, so we only
want it if the slices are big, which is indicated by InnerMaxSize rather than InnerSize, think of the case
of a dynamic block in a fixed-size matrix */
};
public:
enum {
Vectorization = int(MayInnerVectorize) ? int(InnerVectorization)
: int(MayLinearVectorize) ? int(LinearVectorization)
: int(MaySliceVectorize) ? int(SliceVectorization)
: int(NoVectorization)
};
private:
enum {
UnrollingLimit = EIGEN_UNROLLING_LIMIT * (int(Vectorization) == int(NoVectorization) ? 1 : int(PacketSize)),
MayUnrollCompletely = int(Derived::SizeAtCompileTime) * int(OtherDerived::CoeffReadCost) <= int(UnrollingLimit),
MayUnrollInner = int(InnerSize * OtherDerived::CoeffReadCost) <= int(UnrollingLimit)
};
public:
enum {
Unrolling = (int(Vectorization) == int(InnerVectorization) || int(Vectorization) == int(NoVectorization))
? (
int(MayUnrollCompletely) ? int(CompleteUnrolling)
: int(MayUnrollInner) ? int(InnerUnrolling)
: int(NoUnrolling)
)
: int(Vectorization) == int(LinearVectorization)
? ( int(MayUnrollCompletely) && int(DstIsAligned) ? int(CompleteUnrolling) : int(NoUnrolling) )
: int(NoUnrolling)
};
};
/***************************************************************************
* Part 2 : meta-unrollers
***************************************************************************/
/***********************
*** No vectorization ***
***********************/
template<typename Derived1, typename Derived2, int Index, int Stop>
struct ei_assign_novec_CompleteUnrolling
{
enum {
row = int(Derived1::Flags)&RowMajorBit
? Index / int(Derived1::ColsAtCompileTime)
: Index % Derived1::RowsAtCompileTime,
col = int(Derived1::Flags)&RowMajorBit
? Index % int(Derived1::ColsAtCompileTime)
: Index / Derived1::RowsAtCompileTime
};
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
dst.copyCoeff(row, col, src);
ei_assign_novec_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src);
}
};
template<typename Derived1, typename Derived2, int Stop>
struct ei_assign_novec_CompleteUnrolling<Derived1, Derived2, Stop, Stop>
{
EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {}
};
template<typename Derived1, typename Derived2, int Index, int Stop>
struct ei_assign_novec_InnerUnrolling
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int row_or_col)
{
const bool rowMajor = int(Derived1::Flags)&RowMajorBit;
const int row = rowMajor ? row_or_col : Index;
const int col = rowMajor ? Index : row_or_col;
dst.copyCoeff(row, col, src);
ei_assign_novec_InnerUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src, row_or_col);
}
};
template<typename Derived1, typename Derived2, int Stop>
struct ei_assign_novec_InnerUnrolling<Derived1, Derived2, Stop, Stop>
{
EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &, int) {}
};
/**************************
*** Inner vectorization ***
**************************/
template<typename Derived1, typename Derived2, int Index, int Stop>
struct ei_assign_innervec_CompleteUnrolling
{
enum {
row = int(Derived1::Flags)&RowMajorBit
? Index / int(Derived1::ColsAtCompileTime)
: Index % Derived1::RowsAtCompileTime,
col = int(Derived1::Flags)&RowMajorBit
? Index % int(Derived1::ColsAtCompileTime)
: Index / Derived1::RowsAtCompileTime,
SrcAlignment = ei_assign_traits<Derived1,Derived2>::SrcAlignment
};
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
dst.template copyPacket<Derived2, Aligned, SrcAlignment>(row, col, src);
ei_assign_innervec_CompleteUnrolling<Derived1, Derived2,
Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src);
}
};
template<typename Derived1, typename Derived2, int Stop>
struct ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, Stop, Stop>
{
EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &) {}
};
template<typename Derived1, typename Derived2, int Index, int Stop>
struct ei_assign_innervec_InnerUnrolling
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int row_or_col)
{
const int row = int(Derived1::Flags)&RowMajorBit ? row_or_col : Index;
const int col = int(Derived1::Flags)&RowMajorBit ? Index : row_or_col;
dst.template copyPacket<Derived2, Aligned, Aligned>(row, col, src);
ei_assign_innervec_InnerUnrolling<Derived1, Derived2,
Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src, row_or_col);
}
};
template<typename Derived1, typename Derived2, int Stop>
struct ei_assign_innervec_InnerUnrolling<Derived1, Derived2, Stop, Stop>
{
EIGEN_STRONG_INLINE static void run(Derived1 &, const Derived2 &, int) {}
};
/***************************************************************************
* Part 3 : implementation of all cases
***************************************************************************/
template<typename Derived1, typename Derived2,
int Vectorization = ei_assign_traits<Derived1, Derived2>::Vectorization,
int Unrolling = ei_assign_traits<Derived1, Derived2>::Unrolling>
struct ei_assign_impl;
/***********************
*** No vectorization ***
***********************/
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, NoVectorization, NoUnrolling>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
const int innerSize = dst.innerSize();
const int outerSize = dst.outerSize();
for(int j = 0; j < outerSize; ++j)
for(int i = 0; i < innerSize; ++i)
{
if(int(Derived1::Flags)&RowMajorBit)
dst.copyCoeff(j, i, src);
else
dst.copyCoeff(i, j, src);
}
}
};
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, NoVectorization, CompleteUnrolling>
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
ei_assign_novec_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime>
::run(dst, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, NoVectorization, InnerUnrolling>
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
const bool rowMajor = int(Derived1::Flags)&RowMajorBit;
const int innerSize = rowMajor ? Derived1::ColsAtCompileTime : Derived1::RowsAtCompileTime;
const int outerSize = dst.outerSize();
for(int j = 0; j < outerSize; ++j)
ei_assign_novec_InnerUnrolling<Derived1, Derived2, 0, innerSize>
::run(dst, src, j);
}
};
/**************************
*** Inner vectorization ***
**************************/
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, InnerVectorization, NoUnrolling>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
const int innerSize = dst.innerSize();
const int outerSize = dst.outerSize();
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
for(int j = 0; j < outerSize; ++j)
for(int i = 0; i < innerSize; i+=packetSize)
{
if(int(Derived1::Flags)&RowMajorBit)
dst.template copyPacket<Derived2, Aligned, Aligned>(j, i, src);
else
dst.template copyPacket<Derived2, Aligned, Aligned>(i, j, src);
}
}
};
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, InnerVectorization, CompleteUnrolling>
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, Derived1::SizeAtCompileTime>
::run(dst, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, InnerVectorization, InnerUnrolling>
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
const bool rowMajor = int(Derived1::Flags)&RowMajorBit;
const int innerSize = rowMajor ? Derived1::ColsAtCompileTime : Derived1::RowsAtCompileTime;
const int outerSize = dst.outerSize();
for(int j = 0; j < outerSize; ++j)
ei_assign_innervec_InnerUnrolling<Derived1, Derived2, 0, innerSize>
::run(dst, src, j);
}
};
/***************************
*** Linear vectorization ***
***************************/
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, LinearVectorization, NoUnrolling>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
const int size = dst.size();
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
const int alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0
: ei_alignmentOffset(&dst.coeffRef(0), size);
const int alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
for(int index = 0; index < alignedStart; ++index)
dst.copyCoeff(index, src);
for(int index = alignedStart; index < alignedEnd; index += packetSize)
{
dst.template copyPacket<Derived2, Aligned, ei_assign_traits<Derived1,Derived2>::SrcAlignment>(index, src);
}
for(int index = alignedEnd; index < size; ++index)
dst.copyCoeff(index, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, LinearVectorization, CompleteUnrolling>
{
EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src)
{
const int size = Derived1::SizeAtCompileTime;
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
const int alignedSize = (size/packetSize)*packetSize;
ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, 0, alignedSize>::run(dst, src);
ei_assign_novec_CompleteUnrolling<Derived1, Derived2, alignedSize, size>::run(dst, src);
}
};
/**************************
*** Slice vectorization ***
***************************/
template<typename Derived1, typename Derived2>
struct ei_assign_impl<Derived1, Derived2, SliceVectorization, NoUnrolling>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size;
const int packetAlignedMask = packetSize - 1;
const int innerSize = dst.innerSize();
const int outerSize = dst.outerSize();
const int alignedStep = (packetSize - dst.stride() % packetSize) & packetAlignedMask;
int alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0
: ei_alignmentOffset(&dst.coeffRef(0,0), innerSize);
for(int i = 0; i < outerSize; ++i)
{
const int alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask);
// do the non-vectorizable part of the assignment
for (int index = 0; index<alignedStart ; ++index)
{
if(Derived1::Flags&RowMajorBit)
dst.copyCoeff(i, index, src);
else
dst.copyCoeff(index, i, src);
}
// do the vectorizable part of the assignment
for (int index = alignedStart; index<alignedEnd; index+=packetSize)
{
if(Derived1::Flags&RowMajorBit)
dst.template copyPacket<Derived2, Aligned, Unaligned>(i, index, src);
else
dst.template copyPacket<Derived2, Aligned, Unaligned>(index, i, src);
}
// do the non-vectorizable part of the assignment
for (int index = alignedEnd; index<innerSize ; ++index)
{
if(Derived1::Flags&RowMajorBit)
dst.copyCoeff(i, index, src);
else
dst.copyCoeff(index, i, src);
}
alignedStart = std::min<int>((alignedStart+alignedStep)%packetSize, innerSize);
}
}
};
/***************************************************************************
* Part 4 : implementation of MatrixBase methods
***************************************************************************/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
::lazyAssign(const MatrixBase<OtherDerived>& other)
{
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
ei_assert(rows() == other.rows() && cols() == other.cols());
ei_assign_impl<Derived, OtherDerived>::run(derived(),other.derived());
return derived();
}
template<typename Derived, typename OtherDerived,
bool EvalBeforeAssigning = (int(OtherDerived::Flags) & EvalBeforeAssigningBit) != 0,
bool NeedToTranspose = Derived::IsVectorAtCompileTime
&& OtherDerived::IsVectorAtCompileTime
&& int(Derived::RowsAtCompileTime) == int(OtherDerived::ColsAtCompileTime)
&& int(Derived::ColsAtCompileTime) == int(OtherDerived::RowsAtCompileTime)
&& int(Derived::SizeAtCompileTime) != 1>
struct ei_assign_selector;
template<typename Derived, typename OtherDerived>
struct ei_assign_selector<Derived,OtherDerived,false,false> {
EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); }
};
template<typename Derived, typename OtherDerived>
struct ei_assign_selector<Derived,OtherDerived,true,false> {
EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); }
};
template<typename Derived, typename OtherDerived>
struct ei_assign_selector<Derived,OtherDerived,false,true> {
EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); }
};
template<typename Derived, typename OtherDerived>
struct ei_assign_selector<Derived,OtherDerived,true,true> {
EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); }
};
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
::operator=(const MatrixBase<OtherDerived>& other)
{
return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
}
#endif // EIGEN_ASSIGN_H

752
extern/Eigen2/Eigen/src/Core/Block.h vendored Normal file
View File

@@ -0,0 +1,752 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_BLOCK_H
#define EIGEN_BLOCK_H
/** \class Block
*
* \brief Expression of a fixed-size or dynamic-size block
*
* \param MatrixType the type of the object in which we are taking a block
* \param BlockRows the number of rows of the block we are taking at compile time (optional)
* \param BlockCols the number of columns of the block we are taking at compile time (optional)
* \param _PacketAccess allows to enforce aligned loads and stores if set to ForceAligned.
* The default is AsRequested. This parameter is internaly used by Eigen
* in expressions such as \code mat.block() += other; \endcode and most of
* the time this is the only way it is used.
* \param _DirectAccessStatus \internal used for partial specialization
*
* This class represents an expression of either a fixed-size or dynamic-size block. It is the return
* type of MatrixBase::block(int,int,int,int) and MatrixBase::block<int,int>(int,int) and
* most of the time this is the only way it is used.
*
* However, if you want to directly maniputate block expressions,
* for instance if you want to write a function returning such an expression, you
* will need to use this class.
*
* Here is an example illustrating the dynamic case:
* \include class_Block.cpp
* Output: \verbinclude class_Block.out
*
* \note Even though this expression has dynamic size, in the case where \a MatrixType
* has fixed size, this expression inherits a fixed maximal size which means that evaluating
* it does not cause a dynamic memory allocation.
*
* Here is an example illustrating the fixed-size case:
* \include class_FixedBlock.cpp
* Output: \verbinclude class_FixedBlock.out
*
* \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
*/
template<typename MatrixType, int BlockRows, int BlockCols, int _PacketAccess, int _DirectAccessStatus>
struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectAccessStatus> >
{
typedef typename ei_traits<MatrixType>::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum{
RowsAtCompileTime = ei_traits<MatrixType>::RowsAtCompileTime == 1 ? 1 : BlockRows,
ColsAtCompileTime = ei_traits<MatrixType>::ColsAtCompileTime == 1 ? 1 : BlockCols,
MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1
: (BlockRows==Dynamic ? int(ei_traits<MatrixType>::MaxRowsAtCompileTime) : BlockRows),
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
: (BlockCols==Dynamic ? int(ei_traits<MatrixType>::MaxColsAtCompileTime) : BlockCols),
RowMajor = int(ei_traits<MatrixType>::Flags)&RowMajorBit,
InnerSize = RowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
InnerMaxSize = RowMajor ? int(MaxColsAtCompileTime) : int(MaxRowsAtCompileTime),
MaskPacketAccessBit = (InnerMaxSize == Dynamic || (InnerSize >= ei_packet_traits<Scalar>::size))
? PacketAccessBit : 0,
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
Flags = (ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit,
CoeffReadCost = ei_traits<MatrixType>::CoeffReadCost,
PacketAccess = _PacketAccess
};
typedef typename ei_meta_if<int(PacketAccess)==ForceAligned,
Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectAccessStatus>&,
Block<MatrixType, BlockRows, BlockCols, ForceAligned, _DirectAccessStatus> >::ret AlignedDerivedType;
};
template<typename MatrixType, int BlockRows, int BlockCols, int PacketAccess, int _DirectAccessStatus> class Block
: public MatrixBase<Block<MatrixType, BlockRows, BlockCols, PacketAccess, _DirectAccessStatus> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Block)
class InnerIterator;
/** Column or Row constructor
*/
inline Block(const MatrixType& matrix, int i)
: m_matrix(matrix),
// It is a row if and only if BlockRows==1 and BlockCols==MatrixType::ColsAtCompileTime,
// and it is a column if and only if BlockRows==MatrixType::RowsAtCompileTime and BlockCols==1,
// all other cases are invalid.
// The case a 1x1 matrix seems ambiguous, but the result is the same anyway.
m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0),
m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it
m_blockCols(matrix.cols()) // same for m_blockCols
{
ei_assert( (i>=0) && (
((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i<matrix.rows())
||((BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) && i<matrix.cols())));
}
/** Fixed-size constructor
*/
inline Block(const MatrixType& matrix, int startRow, int startCol)
: m_matrix(matrix), m_startRow(startRow), m_startCol(startCol),
m_blockRows(matrix.rows()), m_blockCols(matrix.cols())
{
EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows()
&& startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols());
}
/** Dynamic-size constructor
*/
inline Block(const MatrixType& matrix,
int startRow, int startCol,
int blockRows, int blockCols)
: m_matrix(matrix), m_startRow(startRow), m_startCol(startCol),
m_blockRows(blockRows), m_blockCols(blockCols)
{
ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)
&& (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols));
ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows()
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
inline int rows() const { return m_blockRows.value(); }
inline int cols() const { return m_blockCols.value(); }
inline Scalar& coeffRef(int row, int col)
{
return m_matrix.const_cast_derived()
.coeffRef(row + m_startRow.value(), col + m_startCol.value());
}
inline const Scalar coeff(int row, int col) const
{
return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value());
}
inline Scalar& coeffRef(int index)
{
return m_matrix.const_cast_derived()
.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
}
inline const Scalar coeff(int index) const
{
return m_matrix
.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
}
template<int LoadMode>
inline PacketScalar packet(int row, int col) const
{
return m_matrix.template packet<Unaligned>
(row + m_startRow.value(), col + m_startCol.value());
}
template<int LoadMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<Unaligned>
(row + m_startRow.value(), col + m_startCol.value(), x);
}
template<int LoadMode>
inline PacketScalar packet(int index) const
{
return m_matrix.template packet<Unaligned>
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
}
template<int LoadMode>
inline void writePacket(int index, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<Unaligned>
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), x);
}
protected:
const typename MatrixType::Nested m_matrix;
const ei_int_if_dynamic<MatrixType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
const ei_int_if_dynamic<MatrixType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;
const ei_int_if_dynamic<RowsAtCompileTime> m_blockRows;
const ei_int_if_dynamic<ColsAtCompileTime> m_blockCols;
};
/** \internal */
template<typename MatrixType, int BlockRows, int BlockCols, int PacketAccess>
class Block<MatrixType,BlockRows,BlockCols,PacketAccess,HasDirectAccess>
: public MapBase<Block<MatrixType, BlockRows, BlockCols,PacketAccess,HasDirectAccess> >
{
public:
_EIGEN_GENERIC_PUBLIC_INTERFACE(Block, MapBase<Block>)
class InnerIterator;
typedef typename ei_traits<Block>::AlignedDerivedType AlignedDerivedType;
friend class Block<MatrixType,BlockRows,BlockCols,PacketAccess==AsRequested?ForceAligned:AsRequested,HasDirectAccess>;
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
AlignedDerivedType _convertToForceAligned()
{
return Block<MatrixType,BlockRows,BlockCols,ForceAligned,HasDirectAccess>
(m_matrix, Base::m_data, Base::m_rows.value(), Base::m_cols.value());
}
/** Column or Row constructor
*/
inline Block(const MatrixType& matrix, int i)
: Base(&matrix.const_cast_derived().coeffRef(
(BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0,
(BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
BlockRows==1 ? 1 : matrix.rows(),
BlockCols==1 ? 1 : matrix.cols()),
m_matrix(matrix)
{
ei_assert( (i>=0) && (
((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i<matrix.rows())
||((BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) && i<matrix.cols())));
}
/** Fixed-size constructor
*/
inline Block(const MatrixType& matrix, int startRow, int startCol)
: Base(&matrix.const_cast_derived().coeffRef(startRow,startCol)), m_matrix(matrix)
{
ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows()
&& startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols());
}
/** Dynamic-size constructor
*/
inline Block(const MatrixType& matrix,
int startRow, int startCol,
int blockRows, int blockCols)
: Base(&matrix.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols),
m_matrix(matrix)
{
ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)
&& (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols));
ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows()
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
}
inline int stride(void) const { return m_matrix.stride(); }
protected:
/** \internal used by allowAligned() */
inline Block(const MatrixType& matrix, const Scalar* data, int blockRows, int blockCols)
: Base(data, blockRows, blockCols), m_matrix(matrix)
{}
const typename MatrixType::Nested m_matrix;
};
/** \returns a dynamic-size expression of a block in *this.
*
* \param startRow the first row in the block
* \param startCol the first column in the block
* \param blockRows the number of rows in the block
* \param blockCols the number of columns in the block
*
* \addexample BlockIntIntIntInt \label How to reference a sub-matrix (dynamic-size)
*
* Example: \include MatrixBase_block_int_int_int_int.cpp
* Output: \verbinclude MatrixBase_block_int_int_int_int.out
*
* \note Even though the returned expression has dynamic size, in the case
* when it is applied to a fixed-size matrix, it inherits a fixed maximal size,
* which means that evaluating it does not cause a dynamic memory allocation.
*
* \sa class Block, block(int,int)
*/
template<typename Derived>
inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
::block(int startRow, int startCol, int blockRows, int blockCols)
{
return typename BlockReturnType<Derived>::Type(derived(), startRow, startCol, blockRows, blockCols);
}
/** This is the const version of block(int,int,int,int). */
template<typename Derived>
inline const typename BlockReturnType<Derived>::Type MatrixBase<Derived>
::block(int startRow, int startCol, int blockRows, int blockCols) const
{
return typename BlockReturnType<Derived>::Type(derived(), startRow, startCol, blockRows, blockCols);
}
/** \returns a dynamic-size expression of a segment (i.e. a vector block) in *this.
*
* \only_for_vectors
*
* \addexample SegmentIntInt \label How to reference a sub-vector (dynamic size)
*
* \param start the first coefficient in the segment
* \param size the number of coefficients in the segment
*
* Example: \include MatrixBase_segment_int_int.cpp
* Output: \verbinclude MatrixBase_segment_int_int.out
*
* \note Even though the returned expression has dynamic size, in the case
* when it is applied to a fixed-size vector, it inherits a fixed maximal size,
* which means that evaluating it does not cause a dynamic memory allocation.
*
* \sa class Block, segment(int)
*/
template<typename Derived>
inline typename BlockReturnType<Derived>::SubVectorType MatrixBase<Derived>
::segment(int start, int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename BlockReturnType<Derived>::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** This is the const version of segment(int,int).*/
template<typename Derived>
inline const typename BlockReturnType<Derived>::SubVectorType
MatrixBase<Derived>::segment(int start, int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return typename BlockReturnType<Derived>::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** \returns a dynamic-size expression of the first coefficients of *this.
*
* \only_for_vectors
*
* \param size the number of coefficients in the block
*
* \addexample BlockInt \label How to reference a sub-vector (fixed-size)
*
* Example: \include MatrixBase_start_int.cpp
* Output: \verbinclude MatrixBase_start_int.out
*
* \note Even though the returned expression has dynamic size, in the case
* when it is applied to a fixed-size vector, it inherits a fixed maximal size,
* which means that evaluating it does not cause a dynamic memory allocation.
*
* \sa class Block, block(int,int)
*/
template<typename Derived>
inline typename BlockReturnType<Derived,Dynamic>::SubVectorType
MatrixBase<Derived>::start(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived,
RowsAtCompileTime == 1 ? 1 : Dynamic,
ColsAtCompileTime == 1 ? 1 : Dynamic>
(derived(), 0, 0,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** This is the const version of start(int).*/
template<typename Derived>
inline const typename BlockReturnType<Derived,Dynamic>::SubVectorType
MatrixBase<Derived>::start(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived,
RowsAtCompileTime == 1 ? 1 : Dynamic,
ColsAtCompileTime == 1 ? 1 : Dynamic>
(derived(), 0, 0,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** \returns a dynamic-size expression of the last coefficients of *this.
*
* \only_for_vectors
*
* \param size the number of coefficients in the block
*
* \addexample BlockEnd \label How to reference the end of a vector (fixed-size)
*
* Example: \include MatrixBase_end_int.cpp
* Output: \verbinclude MatrixBase_end_int.out
*
* \note Even though the returned expression has dynamic size, in the case
* when it is applied to a fixed-size vector, it inherits a fixed maximal size,
* which means that evaluating it does not cause a dynamic memory allocation.
*
* \sa class Block, block(int,int)
*/
template<typename Derived>
inline typename BlockReturnType<Derived,Dynamic>::SubVectorType
MatrixBase<Derived>::end(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived,
RowsAtCompileTime == 1 ? 1 : Dynamic,
ColsAtCompileTime == 1 ? 1 : Dynamic>
(derived(),
RowsAtCompileTime == 1 ? 0 : rows() - size,
ColsAtCompileTime == 1 ? 0 : cols() - size,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** This is the const version of end(int).*/
template<typename Derived>
inline const typename BlockReturnType<Derived,Dynamic>::SubVectorType
MatrixBase<Derived>::end(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived,
RowsAtCompileTime == 1 ? 1 : Dynamic,
ColsAtCompileTime == 1 ? 1 : Dynamic>
(derived(),
RowsAtCompileTime == 1 ? 0 : rows() - size,
ColsAtCompileTime == 1 ? 0 : cols() - size,
RowsAtCompileTime == 1 ? 1 : size,
ColsAtCompileTime == 1 ? 1 : size);
}
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
*
* \only_for_vectors
*
* The template parameter \a Size is the number of coefficients in the block
*
* \param start the index of the first element of the sub-vector
*
* Example: \include MatrixBase_template_int_segment.cpp
* Output: \verbinclude MatrixBase_template_int_segment.out
*
* \sa class Block
*/
template<typename Derived>
template<int Size>
inline typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::segment(int start)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>
(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start);
}
/** This is the const version of segment<int>(int).*/
template<typename Derived>
template<int Size>
inline const typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::segment(int start) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>
(derived(), RowsAtCompileTime == 1 ? 0 : start,
ColsAtCompileTime == 1 ? 0 : start);
}
/** \returns a fixed-size expression of the first coefficients of *this.
*
* \only_for_vectors
*
* The template parameter \a Size is the number of coefficients in the block
*
* \addexample BlockStart \label How to reference the start of a vector (fixed-size)
*
* Example: \include MatrixBase_template_int_start.cpp
* Output: \verbinclude MatrixBase_template_int_start.out
*
* \sa class Block
*/
template<typename Derived>
template<int Size>
inline typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::start()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>(derived(), 0, 0);
}
/** This is the const version of start<int>().*/
template<typename Derived>
template<int Size>
inline const typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::start() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
(ColsAtCompileTime == 1 ? 1 : Size)>(derived(), 0, 0);
}
/** \returns a fixed-size expression of the last coefficients of *this.
*
* \only_for_vectors
*
* The template parameter \a Size is the number of coefficients in the block
*
* Example: \include MatrixBase_template_int_end.cpp
* Output: \verbinclude MatrixBase_template_int_end.out
*
* \sa class Block
*/
template<typename Derived>
template<int Size>
inline typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::end()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, RowsAtCompileTime == 1 ? 1 : Size,
ColsAtCompileTime == 1 ? 1 : Size>
(derived(),
RowsAtCompileTime == 1 ? 0 : rows() - Size,
ColsAtCompileTime == 1 ? 0 : cols() - Size);
}
/** This is the const version of end<int>.*/
template<typename Derived>
template<int Size>
inline const typename BlockReturnType<Derived,Size>::SubVectorType
MatrixBase<Derived>::end() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return Block<Derived, RowsAtCompileTime == 1 ? 1 : Size,
ColsAtCompileTime == 1 ? 1 : Size>
(derived(),
RowsAtCompileTime == 1 ? 0 : rows() - Size,
ColsAtCompileTime == 1 ? 0 : cols() - Size);
}
/** \returns a dynamic-size expression of a corner of *this.
*
* \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
* \a Eigen::BottomLeft, \a Eigen::BottomRight.
* \param cRows the number of rows in the corner
* \param cCols the number of columns in the corner
*
* \addexample BlockCornerDynamicSize \label How to reference a sub-corner of a matrix
*
* Example: \include MatrixBase_corner_enum_int_int.cpp
* Output: \verbinclude MatrixBase_corner_enum_int_int.out
*
* \note Even though the returned expression has dynamic size, in the case
* when it is applied to a fixed-size matrix, it inherits a fixed maximal size,
* which means that evaluating it does not cause a dynamic memory allocation.
*
* \sa class Block, block(int,int,int,int)
*/
template<typename Derived>
inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
::corner(CornerType type, int cRows, int cCols)
{
switch(type)
{
default:
ei_assert(false && "Bad corner type.");
case TopLeft:
return typename BlockReturnType<Derived>::Type(derived(), 0, 0, cRows, cCols);
case TopRight:
return typename BlockReturnType<Derived>::Type(derived(), 0, cols() - cCols, cRows, cCols);
case BottomLeft:
return typename BlockReturnType<Derived>::Type(derived(), rows() - cRows, 0, cRows, cCols);
case BottomRight:
return typename BlockReturnType<Derived>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
}
}
/** This is the const version of corner(CornerType, int, int).*/
template<typename Derived>
inline const typename BlockReturnType<Derived>::Type
MatrixBase<Derived>::corner(CornerType type, int cRows, int cCols) const
{
switch(type)
{
default:
ei_assert(false && "Bad corner type.");
case TopLeft:
return typename BlockReturnType<Derived>::Type(derived(), 0, 0, cRows, cCols);
case TopRight:
return typename BlockReturnType<Derived>::Type(derived(), 0, cols() - cCols, cRows, cCols);
case BottomLeft:
return typename BlockReturnType<Derived>::Type(derived(), rows() - cRows, 0, cRows, cCols);
case BottomRight:
return typename BlockReturnType<Derived>::Type(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
}
}
/** \returns a fixed-size expression of a corner of *this.
*
* \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
* \a Eigen::BottomLeft, \a Eigen::BottomRight.
*
* The template parameters CRows and CCols arethe number of rows and columns in the corner.
*
* Example: \include MatrixBase_template_int_int_corner_enum.cpp
* Output: \verbinclude MatrixBase_template_int_int_corner_enum.out
*
* \sa class Block, block(int,int,int,int)
*/
template<typename Derived>
template<int CRows, int CCols>
inline typename BlockReturnType<Derived, CRows, CCols>::Type
MatrixBase<Derived>::corner(CornerType type)
{
switch(type)
{
default:
ei_assert(false && "Bad corner type.");
case TopLeft:
return Block<Derived, CRows, CCols>(derived(), 0, 0);
case TopRight:
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
case BottomLeft:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
case BottomRight:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
}
}
/** This is the const version of corner<int, int>(CornerType).*/
template<typename Derived>
template<int CRows, int CCols>
inline const typename BlockReturnType<Derived, CRows, CCols>::Type
MatrixBase<Derived>::corner(CornerType type) const
{
switch(type)
{
default:
ei_assert(false && "Bad corner type.");
case TopLeft:
return Block<Derived, CRows, CCols>(derived(), 0, 0);
case TopRight:
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
case BottomLeft:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
case BottomRight:
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
}
}
/** \returns a fixed-size expression of a block in *this.
*
* The template parameters \a BlockRows and \a BlockCols are the number of
* rows and columns in the block.
*
* \param startRow the first row in the block
* \param startCol the first column in the block
*
* \addexample BlockSubMatrixFixedSize \label How to reference a sub-matrix (fixed-size)
*
* Example: \include MatrixBase_block_int_int.cpp
* Output: \verbinclude MatrixBase_block_int_int.out
*
* \note since block is a templated member, the keyword template has to be used
* if the matrix type is also a template parameter: \code m.template block<3,3>(1,1); \endcode
*
* \sa class Block, block(int,int,int,int)
*/
template<typename Derived>
template<int BlockRows, int BlockCols>
inline typename BlockReturnType<Derived, BlockRows, BlockCols>::Type
MatrixBase<Derived>::block(int startRow, int startCol)
{
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
}
/** This is the const version of block<>(int, int). */
template<typename Derived>
template<int BlockRows, int BlockCols>
inline const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type
MatrixBase<Derived>::block(int startRow, int startCol) const
{
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
}
/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
*
* \addexample BlockColumn \label How to reference a single column of a matrix
*
* Example: \include MatrixBase_col.cpp
* Output: \verbinclude MatrixBase_col.out
*
* \sa row(), class Block */
template<typename Derived>
inline typename MatrixBase<Derived>::ColXpr
MatrixBase<Derived>::col(int i)
{
return ColXpr(derived(), i);
}
/** This is the const version of col(). */
template<typename Derived>
inline const typename MatrixBase<Derived>::ColXpr
MatrixBase<Derived>::col(int i) const
{
return ColXpr(derived(), i);
}
/** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0.
*
* \addexample BlockRow \label How to reference a single row of a matrix
*
* Example: \include MatrixBase_row.cpp
* Output: \verbinclude MatrixBase_row.out
*
* \sa col(), class Block */
template<typename Derived>
inline typename MatrixBase<Derived>::RowXpr
MatrixBase<Derived>::row(int i)
{
return RowXpr(derived(), i);
}
/** This is the const version of row(). */
template<typename Derived>
inline const typename MatrixBase<Derived>::RowXpr
MatrixBase<Derived>::row(int i) const
{
return RowXpr(derived(), i);
}
#endif // EIGEN_BLOCK_H

View File

@@ -0,0 +1,753 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CACHE_FRIENDLY_PRODUCT_H
#define EIGEN_CACHE_FRIENDLY_PRODUCT_H
template <int L2MemorySize,typename Scalar>
struct ei_L2_block_traits {
enum {width = 8 * ei_meta_sqrt<L2MemorySize/(64*sizeof(Scalar))>::ret };
};
#ifndef EIGEN_EXTERN_INSTANTIATIONS
template<typename Scalar>
static void ei_cache_friendly_product(
int _rows, int _cols, int depth,
bool _lhsRowMajor, const Scalar* _lhs, int _lhsStride,
bool _rhsRowMajor, const Scalar* _rhs, int _rhsStride,
bool resRowMajor, Scalar* res, int resStride)
{
const Scalar* EIGEN_RESTRICT lhs;
const Scalar* EIGEN_RESTRICT rhs;
int lhsStride, rhsStride, rows, cols;
bool lhsRowMajor;
if (resRowMajor)
{
lhs = _rhs;
rhs = _lhs;
lhsStride = _rhsStride;
rhsStride = _lhsStride;
cols = _rows;
rows = _cols;
lhsRowMajor = !_rhsRowMajor;
ei_assert(_lhsRowMajor);
}
else
{
lhs = _lhs;
rhs = _rhs;
lhsStride = _lhsStride;
rhsStride = _rhsStride;
rows = _rows;
cols = _cols;
lhsRowMajor = _lhsRowMajor;
ei_assert(!_rhsRowMajor);
}
typedef typename ei_packet_traits<Scalar>::type PacketType;
enum {
PacketSize = sizeof(PacketType)/sizeof(Scalar),
#if (defined __i386__)
// i386 architecture provides only 8 xmm registers,
// so let's reduce the max number of rows processed at once.
MaxBlockRows = 4,
MaxBlockRows_ClampingMask = 0xFFFFFC,
#else
MaxBlockRows = 8,
MaxBlockRows_ClampingMask = 0xFFFFF8,
#endif
// maximal size of the blocks fitted in L2 cache
MaxL2BlockSize = ei_L2_block_traits<EIGEN_TUNE_FOR_CPU_CACHE_SIZE,Scalar>::width
};
const bool resIsAligned = (PacketSize==1) || (((resStride%PacketSize) == 0) && (size_t(res)%16==0));
const int remainingSize = depth % PacketSize;
const int size = depth - remainingSize; // third dimension of the product clamped to packet boundaries
const int l2BlockRows = MaxL2BlockSize > rows ? rows : MaxL2BlockSize;
const int l2BlockCols = MaxL2BlockSize > cols ? cols : MaxL2BlockSize;
const int l2BlockSize = MaxL2BlockSize > size ? size : MaxL2BlockSize;
const int l2BlockSizeAligned = (1 + std::max(l2BlockSize,l2BlockCols)/PacketSize)*PacketSize;
const bool needRhsCopy = (PacketSize>1) && ((rhsStride%PacketSize!=0) || (size_t(rhs)%16!=0));
Scalar* EIGEN_RESTRICT block = 0;
const int allocBlockSize = l2BlockRows*size;
block = ei_aligned_stack_new(Scalar, allocBlockSize);
Scalar* EIGEN_RESTRICT rhsCopy
= ei_aligned_stack_new(Scalar, l2BlockSizeAligned*l2BlockSizeAligned);
// loops on each L2 cache friendly blocks of the result
for(int l2i=0; l2i<rows; l2i+=l2BlockRows)
{
const int l2blockRowEnd = std::min(l2i+l2BlockRows, rows);
const int l2blockRowEndBW = l2blockRowEnd & MaxBlockRows_ClampingMask; // end of the rows aligned to bw
const int l2blockRemainingRows = l2blockRowEnd - l2blockRowEndBW; // number of remaining rows
//const int l2blockRowEndBWPlusOne = l2blockRowEndBW + (l2blockRemainingRows?0:MaxBlockRows);
// build a cache friendly blocky matrix
int count = 0;
// copy l2blocksize rows of m_lhs to blocks of ps x bw
for(int l2k=0; l2k<size; l2k+=l2BlockSize)
{
const int l2blockSizeEnd = std::min(l2k+l2BlockSize, size);
for (int i = l2i; i<l2blockRowEndBW/*PlusOne*/; i+=MaxBlockRows)
{
// TODO merge the "if l2blockRemainingRows" using something like:
// const int blockRows = std::min(i+MaxBlockRows, rows) - i;
for (int k=l2k; k<l2blockSizeEnd; k+=PacketSize)
{
// TODO write these loops using meta unrolling
// negligible for large matrices but useful for small ones
if (lhsRowMajor)
{
for (int w=0; w<MaxBlockRows; ++w)
for (int s=0; s<PacketSize; ++s)
block[count++] = lhs[(i+w)*lhsStride + (k+s)];
}
else
{
for (int w=0; w<MaxBlockRows; ++w)
for (int s=0; s<PacketSize; ++s)
block[count++] = lhs[(i+w) + (k+s)*lhsStride];
}
}
}
if (l2blockRemainingRows>0)
{
for (int k=l2k; k<l2blockSizeEnd; k+=PacketSize)
{
if (lhsRowMajor)
{
for (int w=0; w<l2blockRemainingRows; ++w)
for (int s=0; s<PacketSize; ++s)
block[count++] = lhs[(l2blockRowEndBW+w)*lhsStride + (k+s)];
}
else
{
for (int w=0; w<l2blockRemainingRows; ++w)
for (int s=0; s<PacketSize; ++s)
block[count++] = lhs[(l2blockRowEndBW+w) + (k+s)*lhsStride];
}
}
}
}
for(int l2j=0; l2j<cols; l2j+=l2BlockCols)
{
int l2blockColEnd = std::min(l2j+l2BlockCols, cols);
for(int l2k=0; l2k<size; l2k+=l2BlockSize)
{
// acumulate bw rows of lhs time a single column of rhs to a bw x 1 block of res
int l2blockSizeEnd = std::min(l2k+l2BlockSize, size);
// if not aligned, copy the rhs block
if (needRhsCopy)
for(int l1j=l2j; l1j<l2blockColEnd; l1j+=1)
{
ei_internal_assert(l2BlockSizeAligned*(l1j-l2j)+(l2blockSizeEnd-l2k) < l2BlockSizeAligned*l2BlockSizeAligned);
memcpy(rhsCopy+l2BlockSizeAligned*(l1j-l2j),&(rhs[l1j*rhsStride+l2k]),(l2blockSizeEnd-l2k)*sizeof(Scalar));
}
// for each bw x 1 result's block
for(int l1i=l2i; l1i<l2blockRowEndBW; l1i+=MaxBlockRows)
{
int offsetblock = l2k * (l2blockRowEnd-l2i) + (l1i-l2i)*(l2blockSizeEnd-l2k) - l2k*MaxBlockRows;
const Scalar* EIGEN_RESTRICT localB = &block[offsetblock];
for(int l1j=l2j; l1j<l2blockColEnd; l1j+=1)
{
const Scalar* EIGEN_RESTRICT rhsColumn;
if (needRhsCopy)
rhsColumn = &(rhsCopy[l2BlockSizeAligned*(l1j-l2j)-l2k]);
else
rhsColumn = &(rhs[l1j*rhsStride]);
PacketType dst[MaxBlockRows];
dst[3] = dst[2] = dst[1] = dst[0] = ei_pset1(Scalar(0.));
if (MaxBlockRows==8)
dst[7] = dst[6] = dst[5] = dst[4] = dst[0];
PacketType tmp;
for(int k=l2k; k<l2blockSizeEnd; k+=PacketSize)
{
tmp = ei_ploadu(&rhsColumn[k]);
PacketType A0, A1, A2, A3, A4, A5;
A0 = ei_pload(localB + k*MaxBlockRows);
A1 = ei_pload(localB + k*MaxBlockRows+1*PacketSize);
A2 = ei_pload(localB + k*MaxBlockRows+2*PacketSize);
A3 = ei_pload(localB + k*MaxBlockRows+3*PacketSize);
if (MaxBlockRows==8) A4 = ei_pload(localB + k*MaxBlockRows+4*PacketSize);
if (MaxBlockRows==8) A5 = ei_pload(localB + k*MaxBlockRows+5*PacketSize);
dst[0] = ei_pmadd(tmp, A0, dst[0]);
if (MaxBlockRows==8) A0 = ei_pload(localB + k*MaxBlockRows+6*PacketSize);
dst[1] = ei_pmadd(tmp, A1, dst[1]);
if (MaxBlockRows==8) A1 = ei_pload(localB + k*MaxBlockRows+7*PacketSize);
dst[2] = ei_pmadd(tmp, A2, dst[2]);
dst[3] = ei_pmadd(tmp, A3, dst[3]);
if (MaxBlockRows==8)
{
dst[4] = ei_pmadd(tmp, A4, dst[4]);
dst[5] = ei_pmadd(tmp, A5, dst[5]);
dst[6] = ei_pmadd(tmp, A0, dst[6]);
dst[7] = ei_pmadd(tmp, A1, dst[7]);
}
}
Scalar* EIGEN_RESTRICT localRes = &(res[l1i + l1j*resStride]);
if (PacketSize>1 && resIsAligned)
{
// the result is aligned: let's do packet reduction
ei_pstore(&(localRes[0]), ei_padd(ei_pload(&(localRes[0])), ei_preduxp(&dst[0])));
if (PacketSize==2)
ei_pstore(&(localRes[2]), ei_padd(ei_pload(&(localRes[2])), ei_preduxp(&(dst[2]))));
if (MaxBlockRows==8)
{
ei_pstore(&(localRes[4]), ei_padd(ei_pload(&(localRes[4])), ei_preduxp(&(dst[4]))));
if (PacketSize==2)
ei_pstore(&(localRes[6]), ei_padd(ei_pload(&(localRes[6])), ei_preduxp(&(dst[6]))));
}
}
else
{
// not aligned => per coeff packet reduction
localRes[0] += ei_predux(dst[0]);
localRes[1] += ei_predux(dst[1]);
localRes[2] += ei_predux(dst[2]);
localRes[3] += ei_predux(dst[3]);
if (MaxBlockRows==8)
{
localRes[4] += ei_predux(dst[4]);
localRes[5] += ei_predux(dst[5]);
localRes[6] += ei_predux(dst[6]);
localRes[7] += ei_predux(dst[7]);
}
}
}
}
if (l2blockRemainingRows>0)
{
int offsetblock = l2k * (l2blockRowEnd-l2i) + (l2blockRowEndBW-l2i)*(l2blockSizeEnd-l2k) - l2k*l2blockRemainingRows;
const Scalar* localB = &block[offsetblock];
for(int l1j=l2j; l1j<l2blockColEnd; l1j+=1)
{
const Scalar* EIGEN_RESTRICT rhsColumn;
if (needRhsCopy)
rhsColumn = &(rhsCopy[l2BlockSizeAligned*(l1j-l2j)-l2k]);
else
rhsColumn = &(rhs[l1j*rhsStride]);
PacketType dst[MaxBlockRows];
dst[3] = dst[2] = dst[1] = dst[0] = ei_pset1(Scalar(0.));
if (MaxBlockRows==8)
dst[7] = dst[6] = dst[5] = dst[4] = dst[0];
// let's declare a few other temporary registers
PacketType tmp;
for(int k=l2k; k<l2blockSizeEnd; k+=PacketSize)
{
tmp = ei_pload(&rhsColumn[k]);
dst[0] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows ])), dst[0]);
if (l2blockRemainingRows>=2) dst[1] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+ PacketSize])), dst[1]);
if (l2blockRemainingRows>=3) dst[2] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+2*PacketSize])), dst[2]);
if (l2blockRemainingRows>=4) dst[3] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+3*PacketSize])), dst[3]);
if (MaxBlockRows==8)
{
if (l2blockRemainingRows>=5) dst[4] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+4*PacketSize])), dst[4]);
if (l2blockRemainingRows>=6) dst[5] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+5*PacketSize])), dst[5]);
if (l2blockRemainingRows>=7) dst[6] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+6*PacketSize])), dst[6]);
if (l2blockRemainingRows>=8) dst[7] = ei_pmadd(tmp, ei_pload(&(localB[k*l2blockRemainingRows+7*PacketSize])), dst[7]);
}
}
Scalar* EIGEN_RESTRICT localRes = &(res[l2blockRowEndBW + l1j*resStride]);
// process the remaining rows once at a time
localRes[0] += ei_predux(dst[0]);
if (l2blockRemainingRows>=2) localRes[1] += ei_predux(dst[1]);
if (l2blockRemainingRows>=3) localRes[2] += ei_predux(dst[2]);
if (l2blockRemainingRows>=4) localRes[3] += ei_predux(dst[3]);
if (MaxBlockRows==8)
{
if (l2blockRemainingRows>=5) localRes[4] += ei_predux(dst[4]);
if (l2blockRemainingRows>=6) localRes[5] += ei_predux(dst[5]);
if (l2blockRemainingRows>=7) localRes[6] += ei_predux(dst[6]);
if (l2blockRemainingRows>=8) localRes[7] += ei_predux(dst[7]);
}
}
}
}
}
}
if (PacketSize>1 && remainingSize)
{
if (lhsRowMajor)
{
for (int j=0; j<cols; ++j)
for (int i=0; i<rows; ++i)
{
Scalar tmp = lhs[i*lhsStride+size] * rhs[j*rhsStride+size];
// FIXME this loop get vectorized by the compiler !
for (int k=1; k<remainingSize; ++k)
tmp += lhs[i*lhsStride+size+k] * rhs[j*rhsStride+size+k];
res[i+j*resStride] += tmp;
}
}
else
{
for (int j=0; j<cols; ++j)
for (int i=0; i<rows; ++i)
{
Scalar tmp = lhs[i+size*lhsStride] * rhs[j*rhsStride+size];
for (int k=1; k<remainingSize; ++k)
tmp += lhs[i+(size+k)*lhsStride] * rhs[j*rhsStride+size+k];
res[i+j*resStride] += tmp;
}
}
}
ei_aligned_stack_delete(Scalar, block, allocBlockSize);
ei_aligned_stack_delete(Scalar, rhsCopy, l2BlockSizeAligned*l2BlockSizeAligned);
}
#endif // EIGEN_EXTERN_INSTANTIATIONS
/* Optimized col-major matrix * vector product:
* This algorithm processes 4 columns at onces that allows to both reduce
* the number of load/stores of the result by a factor 4 and to reduce
* the instruction dependency. Moreover, we know that all bands have the
* same alignment pattern.
* TODO: since rhs gets evaluated only once, no need to evaluate it
*/
template<typename Scalar, typename RhsType>
static EIGEN_DONT_INLINE void ei_cache_friendly_product_colmajor_times_vector(
int size,
const Scalar* lhs, int lhsStride,
const RhsType& rhs,
Scalar* res)
{
#ifdef _EIGEN_ACCUMULATE_PACKETS
#error _EIGEN_ACCUMULATE_PACKETS has already been defined
#endif
#define _EIGEN_ACCUMULATE_PACKETS(A0,A13,A2) \
ei_pstore(&res[j], \
ei_padd(ei_pload(&res[j]), \
ei_padd( \
ei_padd(ei_pmul(ptmp0,EIGEN_CAT(ei_ploa , A0)(&lhs0[j])), \
ei_pmul(ptmp1,EIGEN_CAT(ei_ploa , A13)(&lhs1[j]))), \
ei_padd(ei_pmul(ptmp2,EIGEN_CAT(ei_ploa , A2)(&lhs2[j])), \
ei_pmul(ptmp3,EIGEN_CAT(ei_ploa , A13)(&lhs3[j]))) )))
typedef typename ei_packet_traits<Scalar>::type Packet;
const int PacketSize = sizeof(Packet)/sizeof(Scalar);
enum { AllAligned = 0, EvenAligned, FirstAligned, NoneAligned };
const int columnsAtOnce = 4;
const int peels = 2;
const int PacketAlignedMask = PacketSize-1;
const int PeelAlignedMask = PacketSize*peels-1;
// How many coeffs of the result do we have to skip to be aligned.
// Here we assume data are at least aligned on the base scalar type that is mandatory anyway.
const int alignedStart = ei_alignmentOffset(res,size);
const int alignedSize = PacketSize>1 ? alignedStart + ((size-alignedStart) & ~PacketAlignedMask) : 0;
const int peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart;
const int alignmentStep = PacketSize>1 ? (PacketSize - lhsStride % PacketSize) & PacketAlignedMask : 0;
int alignmentPattern = alignmentStep==0 ? AllAligned
: alignmentStep==(PacketSize/2) ? EvenAligned
: FirstAligned;
// we cannot assume the first element is aligned because of sub-matrices
const int lhsAlignmentOffset = ei_alignmentOffset(lhs,size);
// find how many columns do we have to skip to be aligned with the result (if possible)
int skipColumns = 0;
if (PacketSize>1)
{
ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(Packet)==0 || size<PacketSize);
while (skipColumns<PacketSize &&
alignedStart != ((lhsAlignmentOffset + alignmentStep*skipColumns)%PacketSize))
++skipColumns;
if (skipColumns==PacketSize)
{
// nothing can be aligned, no need to skip any column
alignmentPattern = NoneAligned;
skipColumns = 0;
}
else
{
skipColumns = std::min(skipColumns,rhs.size());
// note that the skiped columns are processed later.
}
ei_internal_assert((alignmentPattern==NoneAligned) || (size_t(lhs+alignedStart+lhsStride*skipColumns)%sizeof(Packet))==0);
}
int offset1 = (FirstAligned && alignmentStep==1?3:1);
int offset3 = (FirstAligned && alignmentStep==1?1:3);
int columnBound = ((rhs.size()-skipColumns)/columnsAtOnce)*columnsAtOnce + skipColumns;
for (int i=skipColumns; i<columnBound; i+=columnsAtOnce)
{
Packet ptmp0 = ei_pset1(rhs[i]), ptmp1 = ei_pset1(rhs[i+offset1]),
ptmp2 = ei_pset1(rhs[i+2]), ptmp3 = ei_pset1(rhs[i+offset3]);
// this helps a lot generating better binary code
const Scalar *lhs0 = lhs + i*lhsStride, *lhs1 = lhs + (i+offset1)*lhsStride,
*lhs2 = lhs + (i+2)*lhsStride, *lhs3 = lhs + (i+offset3)*lhsStride;
if (PacketSize>1)
{
/* explicit vectorization */
// process initial unaligned coeffs
for (int j=0; j<alignedStart; ++j)
res[j] += ei_pfirst(ptmp0)*lhs0[j] + ei_pfirst(ptmp1)*lhs1[j] + ei_pfirst(ptmp2)*lhs2[j] + ei_pfirst(ptmp3)*lhs3[j];
if (alignedSize>alignedStart)
{
switch(alignmentPattern)
{
case AllAligned:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,d,d);
break;
case EvenAligned:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,du,d);
break;
case FirstAligned:
if(peels>1)
{
Packet A00, A01, A02, A03, A10, A11, A12, A13;
A01 = ei_pload(&lhs1[alignedStart-1]);
A02 = ei_pload(&lhs2[alignedStart-2]);
A03 = ei_pload(&lhs3[alignedStart-3]);
for (int j = alignedStart; j<peeledSize; j+=peels*PacketSize)
{
A11 = ei_pload(&lhs1[j-1+PacketSize]); ei_palign<1>(A01,A11);
A12 = ei_pload(&lhs2[j-2+PacketSize]); ei_palign<2>(A02,A12);
A13 = ei_pload(&lhs3[j-3+PacketSize]); ei_palign<3>(A03,A13);
A00 = ei_pload (&lhs0[j]);
A10 = ei_pload (&lhs0[j+PacketSize]);
A00 = ei_pmadd(ptmp0, A00, ei_pload(&res[j]));
A10 = ei_pmadd(ptmp0, A10, ei_pload(&res[j+PacketSize]));
A00 = ei_pmadd(ptmp1, A01, A00);
A01 = ei_pload(&lhs1[j-1+2*PacketSize]); ei_palign<1>(A11,A01);
A00 = ei_pmadd(ptmp2, A02, A00);
A02 = ei_pload(&lhs2[j-2+2*PacketSize]); ei_palign<2>(A12,A02);
A00 = ei_pmadd(ptmp3, A03, A00);
ei_pstore(&res[j],A00);
A03 = ei_pload(&lhs3[j-3+2*PacketSize]); ei_palign<3>(A13,A03);
A10 = ei_pmadd(ptmp1, A11, A10);
A10 = ei_pmadd(ptmp2, A12, A10);
A10 = ei_pmadd(ptmp3, A13, A10);
ei_pstore(&res[j+PacketSize],A10);
}
}
for (int j = peeledSize; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,du,du);
break;
default:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(du,du,du);
break;
}
}
} // end explicit vectorization
/* process remaining coeffs (or all if there is no explicit vectorization) */
for (int j=alignedSize; j<size; ++j)
res[j] += ei_pfirst(ptmp0)*lhs0[j] + ei_pfirst(ptmp1)*lhs1[j] + ei_pfirst(ptmp2)*lhs2[j] + ei_pfirst(ptmp3)*lhs3[j];
}
// process remaining first and last columns (at most columnsAtOnce-1)
int end = rhs.size();
int start = columnBound;
do
{
for (int i=start; i<end; ++i)
{
Packet ptmp0 = ei_pset1(rhs[i]);
const Scalar* lhs0 = lhs + i*lhsStride;
if (PacketSize>1)
{
/* explicit vectorization */
// process first unaligned result's coeffs
for (int j=0; j<alignedStart; ++j)
res[j] += ei_pfirst(ptmp0) * lhs0[j];
// process aligned result's coeffs
if ((size_t(lhs0+alignedStart)%sizeof(Packet))==0)
for (int j = alignedStart;j<alignedSize;j+=PacketSize)
ei_pstore(&res[j], ei_pmadd(ptmp0,ei_pload(&lhs0[j]),ei_pload(&res[j])));
else
for (int j = alignedStart;j<alignedSize;j+=PacketSize)
ei_pstore(&res[j], ei_pmadd(ptmp0,ei_ploadu(&lhs0[j]),ei_pload(&res[j])));
}
// process remaining scalars (or all if no explicit vectorization)
for (int j=alignedSize; j<size; ++j)
res[j] += ei_pfirst(ptmp0) * lhs0[j];
}
if (skipColumns)
{
start = 0;
end = skipColumns;
skipColumns = 0;
}
else
break;
} while(PacketSize>1);
#undef _EIGEN_ACCUMULATE_PACKETS
}
// TODO add peeling to mask unaligned load/stores
template<typename Scalar, typename ResType>
static EIGEN_DONT_INLINE void ei_cache_friendly_product_rowmajor_times_vector(
const Scalar* lhs, int lhsStride,
const Scalar* rhs, int rhsSize,
ResType& res)
{
#ifdef _EIGEN_ACCUMULATE_PACKETS
#error _EIGEN_ACCUMULATE_PACKETS has already been defined
#endif
#define _EIGEN_ACCUMULATE_PACKETS(A0,A13,A2) {\
Packet b = ei_pload(&rhs[j]); \
ptmp0 = ei_pmadd(b, EIGEN_CAT(ei_ploa,A0) (&lhs0[j]), ptmp0); \
ptmp1 = ei_pmadd(b, EIGEN_CAT(ei_ploa,A13)(&lhs1[j]), ptmp1); \
ptmp2 = ei_pmadd(b, EIGEN_CAT(ei_ploa,A2) (&lhs2[j]), ptmp2); \
ptmp3 = ei_pmadd(b, EIGEN_CAT(ei_ploa,A13)(&lhs3[j]), ptmp3); }
typedef typename ei_packet_traits<Scalar>::type Packet;
const int PacketSize = sizeof(Packet)/sizeof(Scalar);
enum { AllAligned=0, EvenAligned=1, FirstAligned=2, NoneAligned=3 };
const int rowsAtOnce = 4;
const int peels = 2;
const int PacketAlignedMask = PacketSize-1;
const int PeelAlignedMask = PacketSize*peels-1;
const int size = rhsSize;
// How many coeffs of the result do we have to skip to be aligned.
// Here we assume data are at least aligned on the base scalar type that is mandatory anyway.
const int alignedStart = ei_alignmentOffset(rhs, size);
const int alignedSize = PacketSize>1 ? alignedStart + ((size-alignedStart) & ~PacketAlignedMask) : 0;
const int peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart;
const int alignmentStep = PacketSize>1 ? (PacketSize - lhsStride % PacketSize) & PacketAlignedMask : 0;
int alignmentPattern = alignmentStep==0 ? AllAligned
: alignmentStep==(PacketSize/2) ? EvenAligned
: FirstAligned;
// we cannot assume the first element is aligned because of sub-matrices
const int lhsAlignmentOffset = ei_alignmentOffset(lhs,size);
// find how many rows do we have to skip to be aligned with rhs (if possible)
int skipRows = 0;
if (PacketSize>1)
{
ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(Packet)==0 || size<PacketSize);
while (skipRows<PacketSize &&
alignedStart != ((lhsAlignmentOffset + alignmentStep*skipRows)%PacketSize))
++skipRows;
if (skipRows==PacketSize)
{
// nothing can be aligned, no need to skip any column
alignmentPattern = NoneAligned;
skipRows = 0;
}
else
{
skipRows = std::min(skipRows,res.size());
// note that the skiped columns are processed later.
}
ei_internal_assert((alignmentPattern==NoneAligned) || PacketSize==1
|| (size_t(lhs+alignedStart+lhsStride*skipRows)%sizeof(Packet))==0);
}
int offset1 = (FirstAligned && alignmentStep==1?3:1);
int offset3 = (FirstAligned && alignmentStep==1?1:3);
int rowBound = ((res.size()-skipRows)/rowsAtOnce)*rowsAtOnce + skipRows;
for (int i=skipRows; i<rowBound; i+=rowsAtOnce)
{
Scalar tmp0 = Scalar(0), tmp1 = Scalar(0), tmp2 = Scalar(0), tmp3 = Scalar(0);
// this helps the compiler generating good binary code
const Scalar *lhs0 = lhs + i*lhsStride, *lhs1 = lhs + (i+offset1)*lhsStride,
*lhs2 = lhs + (i+2)*lhsStride, *lhs3 = lhs + (i+offset3)*lhsStride;
if (PacketSize>1)
{
/* explicit vectorization */
Packet ptmp0 = ei_pset1(Scalar(0)), ptmp1 = ei_pset1(Scalar(0)), ptmp2 = ei_pset1(Scalar(0)), ptmp3 = ei_pset1(Scalar(0));
// process initial unaligned coeffs
// FIXME this loop get vectorized by the compiler !
for (int j=0; j<alignedStart; ++j)
{
Scalar b = rhs[j];
tmp0 += b*lhs0[j]; tmp1 += b*lhs1[j]; tmp2 += b*lhs2[j]; tmp3 += b*lhs3[j];
}
if (alignedSize>alignedStart)
{
switch(alignmentPattern)
{
case AllAligned:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,d,d);
break;
case EvenAligned:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,du,d);
break;
case FirstAligned:
if (peels>1)
{
/* Here we proccess 4 rows with with two peeled iterations to hide
* tghe overhead of unaligned loads. Moreover unaligned loads are handled
* using special shift/move operations between the two aligned packets
* overlaping the desired unaligned packet. This is *much* more efficient
* than basic unaligned loads.
*/
Packet A01, A02, A03, b, A11, A12, A13;
A01 = ei_pload(&lhs1[alignedStart-1]);
A02 = ei_pload(&lhs2[alignedStart-2]);
A03 = ei_pload(&lhs3[alignedStart-3]);
for (int j = alignedStart; j<peeledSize; j+=peels*PacketSize)
{
b = ei_pload(&rhs[j]);
A11 = ei_pload(&lhs1[j-1+PacketSize]); ei_palign<1>(A01,A11);
A12 = ei_pload(&lhs2[j-2+PacketSize]); ei_palign<2>(A02,A12);
A13 = ei_pload(&lhs3[j-3+PacketSize]); ei_palign<3>(A03,A13);
ptmp0 = ei_pmadd(b, ei_pload (&lhs0[j]), ptmp0);
ptmp1 = ei_pmadd(b, A01, ptmp1);
A01 = ei_pload(&lhs1[j-1+2*PacketSize]); ei_palign<1>(A11,A01);
ptmp2 = ei_pmadd(b, A02, ptmp2);
A02 = ei_pload(&lhs2[j-2+2*PacketSize]); ei_palign<2>(A12,A02);
ptmp3 = ei_pmadd(b, A03, ptmp3);
A03 = ei_pload(&lhs3[j-3+2*PacketSize]); ei_palign<3>(A13,A03);
b = ei_pload(&rhs[j+PacketSize]);
ptmp0 = ei_pmadd(b, ei_pload (&lhs0[j+PacketSize]), ptmp0);
ptmp1 = ei_pmadd(b, A11, ptmp1);
ptmp2 = ei_pmadd(b, A12, ptmp2);
ptmp3 = ei_pmadd(b, A13, ptmp3);
}
}
for (int j = peeledSize; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(d,du,du);
break;
default:
for (int j = alignedStart; j<alignedSize; j+=PacketSize)
_EIGEN_ACCUMULATE_PACKETS(du,du,du);
break;
}
tmp0 += ei_predux(ptmp0);
tmp1 += ei_predux(ptmp1);
tmp2 += ei_predux(ptmp2);
tmp3 += ei_predux(ptmp3);
}
} // end explicit vectorization
// process remaining coeffs (or all if no explicit vectorization)
// FIXME this loop get vectorized by the compiler !
for (int j=alignedSize; j<size; ++j)
{
Scalar b = rhs[j];
tmp0 += b*lhs0[j]; tmp1 += b*lhs1[j]; tmp2 += b*lhs2[j]; tmp3 += b*lhs3[j];
}
res[i] += tmp0; res[i+offset1] += tmp1; res[i+2] += tmp2; res[i+offset3] += tmp3;
}
// process remaining first and last rows (at most columnsAtOnce-1)
int end = res.size();
int start = rowBound;
do
{
for (int i=start; i<end; ++i)
{
Scalar tmp0 = Scalar(0);
Packet ptmp0 = ei_pset1(tmp0);
const Scalar* lhs0 = lhs + i*lhsStride;
// process first unaligned result's coeffs
// FIXME this loop get vectorized by the compiler !
for (int j=0; j<alignedStart; ++j)
tmp0 += rhs[j] * lhs0[j];
if (alignedSize>alignedStart)
{
// process aligned rhs coeffs
if ((size_t(lhs0+alignedStart)%sizeof(Packet))==0)
for (int j = alignedStart;j<alignedSize;j+=PacketSize)
ptmp0 = ei_pmadd(ei_pload(&rhs[j]), ei_pload(&lhs0[j]), ptmp0);
else
for (int j = alignedStart;j<alignedSize;j+=PacketSize)
ptmp0 = ei_pmadd(ei_pload(&rhs[j]), ei_ploadu(&lhs0[j]), ptmp0);
tmp0 += ei_predux(ptmp0);
}
// process remaining scalars
// FIXME this loop get vectorized by the compiler !
for (int j=alignedSize; j<size; ++j)
tmp0 += rhs[j] * lhs0[j];
res[i] += tmp0;
}
if (skipRows)
{
start = 0;
end = skipRows;
skipRows = 0;
}
else
break;
} while(PacketSize>1);
#undef _EIGEN_ACCUMULATE_PACKETS
}
#endif // EIGEN_CACHE_FRIENDLY_PRODUCT_H

384
extern/Eigen2/Eigen/src/Core/Coeffs.h vendored Normal file
View File

@@ -0,0 +1,384 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_COEFFS_H
#define EIGEN_COEFFS_H
/** Short version: don't use this function, use
* \link operator()(int,int) const \endlink instead.
*
* Long version: this function is similar to
* \link operator()(int,int) const \endlink, but without the assertion.
* Use this for limiting the performance cost of debugging code when doing
* repeated coefficient access. Only use this when it is guaranteed that the
* parameters \a row and \a col are in range.
*
* If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
* function equivalent to \link operator()(int,int) const \endlink.
*
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::coeff(int row, int col) const
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
return derived().coeff(row, col);
}
/** \returns the coefficient at given the given row and column.
*
* \sa operator()(int,int), operator[](int) const
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator()(int row, int col) const
{
ei_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
return derived().coeff(row, col);
}
/** Short version: don't use this function, use
* \link operator()(int,int) \endlink instead.
*
* Long version: this function is similar to
* \link operator()(int,int) \endlink, but without the assertion.
* Use this for limiting the performance cost of debugging code when doing
* repeated coefficient access. Only use this when it is guaranteed that the
* parameters \a row and \a col are in range.
*
* If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
* function equivalent to \link operator()(int,int) \endlink.
*
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::coeffRef(int row, int col)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
return derived().coeffRef(row, col);
}
/** \returns a reference to the coefficient at given the given row and column.
*
* \sa operator()(int,int) const, operator[](int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::operator()(int row, int col)
{
ei_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
return derived().coeffRef(row, col);
}
/** Short version: don't use this function, use
* \link operator[](int) const \endlink instead.
*
* Long version: this function is similar to
* \link operator[](int) const \endlink, but without the assertion.
* Use this for limiting the performance cost of debugging code when doing
* repeated coefficient access. Only use this when it is guaranteed that the
* parameter \a index is in range.
*
* If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
* function equivalent to \link operator[](int) const \endlink.
*
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::coeff(int index) const
{
ei_internal_assert(index >= 0 && index < size());
return derived().coeff(index);
}
/** \returns the coefficient at given index.
*
* This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
*
* \sa operator[](int), operator()(int,int) const, x() const, y() const,
* z() const, w() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator[](int index) const
{
ei_assert(index >= 0 && index < size());
return derived().coeff(index);
}
/** \returns the coefficient at given index.
*
* This is synonymous to operator[](int) const.
*
* This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
*
* \sa operator[](int), operator()(int,int) const, x() const, y() const,
* z() const, w() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator()(int index) const
{
ei_assert(index >= 0 && index < size());
return derived().coeff(index);
}
/** Short version: don't use this function, use
* \link operator[](int) \endlink instead.
*
* Long version: this function is similar to
* \link operator[](int) \endlink, but without the assertion.
* Use this for limiting the performance cost of debugging code when doing
* repeated coefficient access. Only use this when it is guaranteed that the
* parameters \a row and \a col are in range.
*
* If EIGEN_INTERNAL_DEBUGGING is defined, an assertion will be made, making this
* function equivalent to \link operator[](int) \endlink.
*
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::coeffRef(int index)
{
ei_internal_assert(index >= 0 && index < size());
return derived().coeffRef(index);
}
/** \returns a reference to the coefficient at given index.
*
* This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
*
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::operator[](int index)
{
ei_assert(index >= 0 && index < size());
return derived().coeffRef(index);
}
/** \returns a reference to the coefficient at given index.
*
* This is synonymous to operator[](int).
*
* This method is allowed only for vector expressions, and for matrix expressions having the LinearAccessBit.
*
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::operator()(int index)
{
ei_assert(index >= 0 && index < size());
return derived().coeffRef(index);
}
/** equivalent to operator[](0). */
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::x() const { return (*this)[0]; }
/** equivalent to operator[](1). */
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::y() const { return (*this)[1]; }
/** equivalent to operator[](2). */
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::z() const { return (*this)[2]; }
/** equivalent to operator[](3). */
template<typename Derived>
EIGEN_STRONG_INLINE const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::w() const { return (*this)[3]; }
/** equivalent to operator[](0). */
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::x() { return (*this)[0]; }
/** equivalent to operator[](1). */
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::y() { return (*this)[1]; }
/** equivalent to operator[](2). */
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::z() { return (*this)[2]; }
/** equivalent to operator[](3). */
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::w() { return (*this)[3]; }
/** \returns the packet of coefficients starting at the given row and column. It is your responsibility
* to ensure that a packet really starts there. This method is only available on expressions having the
* PacketAccessBit.
*
* The \a LoadMode parameter may have the value \a Aligned or \a Unaligned. Its effect is to select
* the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
* starting at an address which is a multiple of the packet size.
*/
template<typename Derived>
template<int LoadMode>
EIGEN_STRONG_INLINE typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type
MatrixBase<Derived>::packet(int row, int col) const
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
return derived().template packet<LoadMode>(row,col);
}
/** Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility
* to ensure that a packet really starts there. This method is only available on expressions having the
* PacketAccessBit.
*
* The \a LoadMode parameter may have the value \a Aligned or \a Unaligned. Its effect is to select
* the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
* starting at an address which is a multiple of the packet size.
*/
template<typename Derived>
template<int StoreMode>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
(int row, int col, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
derived().template writePacket<StoreMode>(row,col,x);
}
/** \returns the packet of coefficients starting at the given index. It is your responsibility
* to ensure that a packet really starts there. This method is only available on expressions having the
* PacketAccessBit and the LinearAccessBit.
*
* The \a LoadMode parameter may have the value \a Aligned or \a Unaligned. Its effect is to select
* the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
* starting at an address which is a multiple of the packet size.
*/
template<typename Derived>
template<int LoadMode>
EIGEN_STRONG_INLINE typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type
MatrixBase<Derived>::packet(int index) const
{
ei_internal_assert(index >= 0 && index < size());
return derived().template packet<LoadMode>(index);
}
/** Stores the given packet of coefficients, at the given index in this expression. It is your responsibility
* to ensure that a packet really starts there. This method is only available on expressions having the
* PacketAccessBit and the LinearAccessBit.
*
* The \a LoadMode parameter may have the value \a Aligned or \a Unaligned. Its effect is to select
* the appropriate vectorization instruction. Aligned access is faster, but is only possible for packets
* starting at an address which is a multiple of the packet size.
*/
template<typename Derived>
template<int StoreMode>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
(int index, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x)
{
ei_internal_assert(index >= 0 && index < size());
derived().template writePacket<StoreMode>(index,x);
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal Copies the coefficient at position (row,col) of other into *this.
*
* This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code
* with usual assignments.
*
* Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox.
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
derived().coeffRef(row, col) = other.derived().coeff(row, col);
}
/** \internal Copies the coefficient at the given index of other into *this.
*
* This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code
* with usual assignments.
*
* Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox.
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int index, const MatrixBase<OtherDerived>& other)
{
ei_internal_assert(index >= 0 && index < size());
derived().coeffRef(index) = other.derived().coeff(index);
}
/** \internal Copies the packet at position (row,col) of other into *this.
*
* This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code
* with usual assignments.
*
* Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox.
*/
template<typename Derived>
template<typename OtherDerived, int StoreMode, int LoadMode>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int row, int col, const MatrixBase<OtherDerived>& other)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
derived().template writePacket<StoreMode>(row, col,
other.derived().template packet<LoadMode>(row, col));
}
/** \internal Copies the packet at the given index of other into *this.
*
* This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code
* with usual assignments.
*
* Outside of this internal usage, this method has probably no usefulness. It is hidden in the public API dox.
*/
template<typename Derived>
template<typename OtherDerived, int StoreMode, int LoadMode>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int index, const MatrixBase<OtherDerived>& other)
{
ei_internal_assert(index >= 0 && index < size());
derived().template writePacket<StoreMode>(index,
other.derived().template packet<LoadMode>(index));
}
#endif
#endif // EIGEN_COEFFS_H

View File

@@ -0,0 +1,152 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_COMMAINITIALIZER_H
#define EIGEN_COMMAINITIALIZER_H
/** \class CommaInitializer
*
* \brief Helper class used by the comma initializer operator
*
* This class is internally used to implement the comma initializer feature. It is
* the return type of MatrixBase::operator<<, and most of the time this is the only
* way it is used.
*
* \sa \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished()
*/
template<typename MatrixType>
struct CommaInitializer
{
typedef typename ei_traits<MatrixType>::Scalar Scalar;
inline CommaInitializer(MatrixType& mat, const Scalar& s)
: m_matrix(mat), m_row(0), m_col(1), m_currentBlockRows(1)
{
m_matrix.coeffRef(0,0) = s;
}
template<typename OtherDerived>
inline CommaInitializer(MatrixType& mat, const MatrixBase<OtherDerived>& other)
: m_matrix(mat), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
{
m_matrix.block(0, 0, other.rows(), other.cols()) = other;
}
/* inserts a scalar value in the target matrix */
CommaInitializer& operator,(const Scalar& s)
{
if (m_col==m_matrix.cols())
{
m_row+=m_currentBlockRows;
m_col = 0;
m_currentBlockRows = 1;
ei_assert(m_row<m_matrix.rows()
&& "Too many rows passed to comma initializer (operator<<)");
}
ei_assert(m_col<m_matrix.cols()
&& "Too many coefficients passed to comma initializer (operator<<)");
ei_assert(m_currentBlockRows==1);
m_matrix.coeffRef(m_row, m_col++) = s;
return *this;
}
/* inserts a matrix expression in the target matrix */
template<typename OtherDerived>
CommaInitializer& operator,(const MatrixBase<OtherDerived>& other)
{
if (m_col==m_matrix.cols())
{
m_row+=m_currentBlockRows;
m_col = 0;
m_currentBlockRows = other.rows();
ei_assert(m_row+m_currentBlockRows<=m_matrix.rows()
&& "Too many rows passed to comma initializer (operator<<)");
}
ei_assert(m_col<m_matrix.cols()
&& "Too many coefficients passed to comma initializer (operator<<)");
ei_assert(m_currentBlockRows==other.rows());
if (OtherDerived::SizeAtCompileTime != Dynamic)
m_matrix.template block<OtherDerived::RowsAtCompileTime != Dynamic ? OtherDerived::RowsAtCompileTime : 1,
OtherDerived::ColsAtCompileTime != Dynamic ? OtherDerived::ColsAtCompileTime : 1>
(m_row, m_col) = other;
else
m_matrix.block(m_row, m_col, other.rows(), other.cols()) = other;
m_col += other.cols();
return *this;
}
inline ~CommaInitializer()
{
ei_assert((m_row+m_currentBlockRows) == m_matrix.rows()
&& m_col == m_matrix.cols()
&& "Too few coefficients passed to comma initializer (operator<<)");
}
/** \returns the built matrix once all its coefficients have been set.
* Calling finished is 100% optional. Its purpose is to write expressions
* like this:
* \code
* quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());
* \endcode
*/
inline MatrixType& finished() { return m_matrix; }
MatrixType& m_matrix; // target matrix
int m_row; // current row id
int m_col; // current col id
int m_currentBlockRows; // current block height
private:
CommaInitializer& operator=(const CommaInitializer&);
};
/** \anchor MatrixBaseCommaInitRef
* Convenient operator to set the coefficients of a matrix.
*
* The coefficients must be provided in a row major order and exactly match
* the size of the matrix. Otherwise an assertion is raised.
*
* \addexample CommaInit \label How to easily set all the coefficients of a matrix
*
* Example: \include MatrixBase_set.cpp
* Output: \verbinclude MatrixBase_set.out
*
* \sa CommaInitializer::finished(), class CommaInitializer
*/
template<typename Derived>
inline CommaInitializer<Derived> MatrixBase<Derived>::operator<< (const Scalar& s)
{
return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
}
/** \sa operator<<(const Scalar&) */
template<typename Derived>
template<typename OtherDerived>
inline CommaInitializer<Derived>
MatrixBase<Derived>::operator<<(const MatrixBase<OtherDerived>& other)
{
return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);
}
#endif // EIGEN_COMMAINITIALIZER_H

View File

@@ -0,0 +1,47 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifdef EIGEN_EXTERN_INSTANTIATIONS
#undef EIGEN_EXTERN_INSTANTIATIONS
#endif
#include "../../Core"
namespace Eigen
{
#define EIGEN_INSTANTIATE_PRODUCT(TYPE) \
template static void ei_cache_friendly_product<TYPE>( \
int _rows, int _cols, int depth, \
bool _lhsRowMajor, const TYPE* _lhs, int _lhsStride, \
bool _rhsRowMajor, const TYPE* _rhs, int _rhsStride, \
bool resRowMajor, TYPE* res, int resStride)
EIGEN_INSTANTIATE_PRODUCT(float);
EIGEN_INSTANTIATE_PRODUCT(double);
EIGEN_INSTANTIATE_PRODUCT(int);
EIGEN_INSTANTIATE_PRODUCT(std::complex<float>);
EIGEN_INSTANTIATE_PRODUCT(std::complex<double>);
}

214
extern/Eigen2/Eigen/src/Core/Cwise.h vendored Normal file
View File

@@ -0,0 +1,214 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CWISE_H
#define EIGEN_CWISE_H
/** \internal
* convenient macro to defined the return type of a cwise binary operation */
#define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
CwiseBinaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
#define EIGEN_CWISE_PRODUCT_RETURN_TYPE \
CwiseBinaryOp< \
ei_scalar_product_op< \
typename ei_scalar_product_traits< \
typename ei_traits<ExpressionType>::Scalar, \
typename ei_traits<OtherDerived>::Scalar \
>::ReturnType \
>, \
ExpressionType, \
OtherDerived \
>
/** \internal
* convenient macro to defined the return type of a cwise unary operation */
#define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
CwiseUnaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType>
/** \internal
* convenient macro to defined the return type of a cwise comparison to a scalar */
#define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
CwiseBinaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType, \
NestByValue<typename ExpressionType::ConstantReturnType> >
/** \class Cwise
*
* \brief Pseudo expression providing additional coefficient-wise operations
*
* \param ExpressionType the type of the object on which to do coefficient-wise operations
*
* This class represents an expression with additional coefficient-wise features.
* It is the return type of MatrixBase::cwise()
* and most of the time this is the only way it is used.
*
* Note that some methods are defined in the \ref Array module.
*
* Example: \include MatrixBase_cwise_const.cpp
* Output: \verbinclude MatrixBase_cwise_const.out
*
* \sa MatrixBase::cwise() const, MatrixBase::cwise()
*/
template<typename ExpressionType> class Cwise
{
public:
typedef typename ei_traits<ExpressionType>::Scalar Scalar;
typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
/** \internal */
inline const ExpressionType& _expression() const { return m_matrix; }
template<typename OtherDerived>
const EIGEN_CWISE_PRODUCT_RETURN_TYPE
operator*(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
operator/(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
min(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
max(const MatrixBase<OtherDerived> &other) const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) square() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) cube() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inverse() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) sqrt() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) exp() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) log() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) cos() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) sin() const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) pow(const Scalar& exponent) const;
const ScalarAddReturnType
operator+(const Scalar& scalar) const;
/** \relates Cwise */
friend const ScalarAddReturnType
operator+(const Scalar& scalar, const Cwise& mat)
{ return mat + scalar; }
ExpressionType& operator+=(const Scalar& scalar);
const ScalarAddReturnType
operator-(const Scalar& scalar) const;
ExpressionType& operator-=(const Scalar& scalar);
template<typename OtherDerived>
inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived>
inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
operator<(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
operator<=(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
operator>(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
operator>=(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
operator==(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
operator!=(const MatrixBase<OtherDerived>& other) const;
// comparisons to a scalar value
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
operator<(Scalar s) const;
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
operator<=(Scalar s) const;
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
operator>(Scalar s) const;
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
operator>=(Scalar s) const;
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
operator==(Scalar s) const;
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
operator!=(Scalar s) const;
// allow to extend Cwise outside Eigen
#ifdef EIGEN_CWISE_PLUGIN
#include EIGEN_CWISE_PLUGIN
#endif
protected:
ExpressionTypeNested m_matrix;
private:
Cwise& operator=(const Cwise&);
};
/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
*
* Example: \include MatrixBase_cwise_const.cpp
* Output: \verbinclude MatrixBase_cwise_const.out
*
* \sa class Cwise, cwise()
*/
template<typename Derived>
inline const Cwise<Derived>
MatrixBase<Derived>::cwise() const
{
return derived();
}
/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
*
* Example: \include MatrixBase_cwise.cpp
* Output: \verbinclude MatrixBase_cwise.out
*
* \sa class Cwise, cwise() const
*/
template<typename Derived>
inline Cwise<Derived>
MatrixBase<Derived>::cwise()
{
return derived();
}
#endif // EIGEN_CWISE_H

View File

@@ -0,0 +1,304 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CWISE_BINARY_OP_H
#define EIGEN_CWISE_BINARY_OP_H
/** \class CwiseBinaryOp
*
* \brief Generic expression of a coefficient-wise operator between two matrices or vectors
*
* \param BinaryOp template functor implementing the operator
* \param Lhs the type of the left-hand side
* \param Rhs the type of the right-hand side
*
* This class represents an expression of a generic binary operator of two matrices or vectors.
* It is the return type of the operator+, operator-, and the Cwise methods, and most
* of the time this is the only way it is used.
*
* However, if you want to write a function returning such an expression, you
* will need to use this class.
*
* \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
*/
template<typename BinaryOp, typename Lhs, typename Rhs>
struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
{
// even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
// we still want to handle the case when the result type is different.
typedef typename ei_result_of<
BinaryOp(
typename Lhs::Scalar,
typename Rhs::Scalar
)
>::type Scalar;
typedef typename Lhs::Nested LhsNested;
typedef typename Rhs::Nested RhsNested;
typedef typename ei_unref<LhsNested>::type _LhsNested;
typedef typename ei_unref<RhsNested>::type _RhsNested;
enum {
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
LhsFlags = _LhsNested::Flags,
RhsFlags = _RhsNested::Flags,
RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Lhs::ColsAtCompileTime,
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime,
Flags = (int(LhsFlags) | int(RhsFlags)) & (
HereditaryBits
| (int(LhsFlags) & int(RhsFlags) & (LinearAccessBit | AlignedBit))
| (ei_functor_traits<BinaryOp>::PacketAccess && ((int(LhsFlags) & RowMajorBit)==(int(RhsFlags) & RowMajorBit))
? (int(LhsFlags) & int(RhsFlags) & PacketAccessBit) : 0)),
CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + ei_functor_traits<BinaryOp>::Cost
};
};
template<typename BinaryOp, typename Lhs, typename Rhs>
class CwiseBinaryOp : ei_no_assignment_operator,
public MatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested;
typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested;
EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& lhs, const Rhs& rhs, const BinaryOp& func = BinaryOp())
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
{
// we require Lhs and Rhs to have the same scalar type. Currently there is no example of a binary functor
// that would take two operands of different types. If there were such an example, then this check should be
// moved to the BinaryOp functors, on a per-case basis. This would however require a change in the BinaryOp functors, as
// currently they take only one typename Scalar template parameter.
// It is tempting to always allow mixing different types but remember that this is often impossible in the vectorized paths.
// So allowing mixing different types gives very unexpected errors when enabling vectorization, when the user tries to
// add together a float matrix and a double matrix.
EIGEN_STATIC_ASSERT((ei_functor_allows_mixing_real_and_complex<BinaryOp>::ret
? int(ei_is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret)
: int(ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret)),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
// require the sizes to match
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
}
EIGEN_STRONG_INLINE int rows() const { return m_lhs.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_lhs.cols(); }
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
{
return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
{
return m_functor.packetOp(m_lhs.template packet<LoadMode>(row, col), m_rhs.template packet<LoadMode>(row, col));
}
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
return m_functor(m_lhs.coeff(index), m_rhs.coeff(index));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int index) const
{
return m_functor.packetOp(m_lhs.template packet<LoadMode>(index), m_rhs.template packet<LoadMode>(index));
}
protected:
const LhsNested m_lhs;
const RhsNested m_rhs;
const BinaryOp m_functor;
};
/**\returns an expression of the difference of \c *this and \a other
*
* \note If you want to substract a given scalar from all coefficients, see Cwise::operator-().
*
* \sa class CwiseBinaryOp, MatrixBase::operator-=(), Cwise::operator-()
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
Derived, OtherDerived>
MatrixBase<Derived>::operator-(const MatrixBase<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
Derived, OtherDerived>(derived(), other.derived());
}
/** replaces \c *this by \c *this - \a other.
*
* \returns a reference to \c *this
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
{
return *this = *this - other;
}
/** \relates MatrixBase
*
* \returns an expression of the sum of \c *this and \a other
*
* \note If you want to add a given scalar to all coefficients, see Cwise::operator+().
*
* \sa class CwiseBinaryOp, MatrixBase::operator+=(), Cwise::operator+()
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
MatrixBase<Derived>::operator+(const MatrixBase<OtherDerived> &other) const
{
return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
}
/** replaces \c *this by \c *this + \a other.
*
* \returns a reference to \c *this
*/
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
{
return *this = *this + other;
}
/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other
*
* Example: \include Cwise_product.cpp
* Output: \verbinclude Cwise_product.out
*
* \sa class CwiseBinaryOp, operator/(), square()
*/
template<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived());
}
/** \returns an expression of the coefficient-wise quotient of *this and \a other
*
* Example: \include Cwise_quotient.cpp
* Output: \verbinclude Cwise_quotient.out
*
* \sa class CwiseBinaryOp, operator*(), inverse()
*/
template<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived());
}
/** Replaces this expression by its coefficient-wise product with \a other.
*
* Example: \include Cwise_times_equal.cpp
* Output: \verbinclude Cwise_times_equal.out
*
* \sa operator*(), operator/=()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
{
return m_matrix.const_cast_derived() = *this * other;
}
/** Replaces this expression by its coefficient-wise quotient by \a other.
*
* Example: \include Cwise_slash_equal.cpp
* Output: \verbinclude Cwise_slash_equal.out
*
* \sa operator/(), operator*=()
*/
template<typename ExpressionType>
template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
{
return m_matrix.const_cast_derived() = *this / other;
}
/** \returns an expression of the coefficient-wise min of *this and \a other
*
* Example: \include Cwise_min.cpp
* Output: \verbinclude Cwise_min.out
*
* \sa class CwiseBinaryOp
*/
template<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived());
}
/** \returns an expression of the coefficient-wise max of *this and \a other
*
* Example: \include Cwise_max.cpp
* Output: \verbinclude Cwise_max.out
*
* \sa class CwiseBinaryOp
*/
template<typename ExpressionType>
template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const
{
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived());
}
/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
*
* The template parameter \a CustomBinaryOp is the type of the functor
* of the custom operator (see class CwiseBinaryOp for an example)
*
* \addexample CustomCwiseBinaryFunctors \label How to use custom coeff wise binary functors
*
* Here is an example illustrating the use of custom functors:
* \include class_CwiseBinaryOp.cpp
* Output: \verbinclude class_CwiseBinaryOp.out
*
* \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, Cwise::operator*, Cwise::operator/
*/
template<typename Derived>
template<typename CustomBinaryOp, typename OtherDerived>
EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
MatrixBase<Derived>::binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
{
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(derived(), other.derived(), func);
}
#endif // EIGEN_CWISE_BINARY_OP_H

View File

@@ -0,0 +1,763 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CWISE_NULLARY_OP_H
#define EIGEN_CWISE_NULLARY_OP_H
/** \class CwiseNullaryOp
*
* \brief Generic expression of a matrix where all coefficients are defined by a functor
*
* \param NullaryOp template functor implementing the operator
*
* This class represents an expression of a generic nullary operator.
* It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() functions,
* and most of the time this is the only way it is used.
*
* However, if you want to write a function returning such an expression, you
* will need to use this class.
*
* \sa class CwiseUnaryOp, class CwiseBinaryOp, MatrixBase::NullaryExpr()
*/
template<typename NullaryOp, typename MatrixType>
struct ei_traits<CwiseNullaryOp<NullaryOp, MatrixType> > : ei_traits<MatrixType>
{
enum {
Flags = (ei_traits<MatrixType>::Flags
& ( HereditaryBits
| (ei_functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0)
| (ei_functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0)))
| (ei_functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
CoeffReadCost = ei_functor_traits<NullaryOp>::Cost
};
};
template<typename NullaryOp, typename MatrixType>
class CwiseNullaryOp : ei_no_assignment_operator,
public MatrixBase<CwiseNullaryOp<NullaryOp, MatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseNullaryOp)
CwiseNullaryOp(int rows, int cols, const NullaryOp& func = NullaryOp())
: m_rows(rows), m_cols(cols), m_functor(func)
{
ei_assert(rows > 0
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
&& cols > 0
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
}
EIGEN_STRONG_INLINE int rows() const { return m_rows.value(); }
EIGEN_STRONG_INLINE int cols() const { return m_cols.value(); }
EIGEN_STRONG_INLINE const Scalar coeff(int rows, int cols) const
{
return m_functor(rows, cols);
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int, int) const
{
return m_functor.packetOp();
}
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
if(RowsAtCompileTime == 1)
return m_functor(0, index);
else
return m_functor(index, 0);
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int) const
{
return m_functor.packetOp();
}
protected:
const ei_int_if_dynamic<RowsAtCompileTime> m_rows;
const ei_int_if_dynamic<ColsAtCompileTime> m_cols;
const NullaryOp m_functor;
};
/** \returns an expression of a matrix defined by a custom functor \a func
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
* instead.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
MatrixBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func);
}
/** \returns an expression of a matrix defined by a custom functor \a func
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
*
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
* it is redundant to pass \a size as argument, so Zero() should be used
* instead.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
MatrixBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_assert(IsVectorAtCompileTime);
if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func);
else return CwiseNullaryOp<CustomNullaryOp, Derived>(size, 1, func);
}
/** \returns an expression of a matrix defined by a custom functor \a func
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func);
}
/** \returns an expression of a constant matrix of value \a value
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
* instead.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Constant(int rows, int cols, const Scalar& value)
{
return NullaryExpr(rows, cols, ei_scalar_constant_op<Scalar>(value));
}
/** \returns an expression of a constant matrix of value \a value
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
*
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
* it is redundant to pass \a size as argument, so Zero() should be used
* instead.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Constant(int size, const Scalar& value)
{
return NullaryExpr(size, ei_scalar_constant_op<Scalar>(value));
}
/** \returns an expression of a constant matrix of value \a value
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
*
* \sa class CwiseNullaryOp
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Constant(const Scalar& value)
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value));
}
/** \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
template<typename Derived>
bool MatrixBase<Derived>::isApproxToConstant
(const Scalar& value, RealScalar prec) const
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
if(!ei_isApprox(coeff(i, j), value, prec))
return false;
return true;
}
/** This is just an alias for isApproxToConstant().
*
* \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
template<typename Derived>
bool MatrixBase<Derived>::isConstant
(const Scalar& value, RealScalar prec) const
{
return isApproxToConstant(value, prec);
}
/** Alias for setConstant(): sets all coefficients in this expression to \a value.
*
* \sa setConstant(), Constant(), class CwiseNullaryOp
*/
template<typename Derived>
EIGEN_STRONG_INLINE void MatrixBase<Derived>::fill(const Scalar& value)
{
setConstant(value);
}
/** Sets all coefficients in this expression to \a value.
*
* \sa fill(), setConstant(int,const Scalar&), setConstant(int,int,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()
*/
template<typename Derived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setConstant(const Scalar& value)
{
return derived() = Constant(rows(), cols(), value);
}
/** Resizes to the given \a size, and sets all coefficients in this expression to the given \a value.
*
* \only_for_vectors
*
* Example: \include Matrix_set_int.cpp
* Output: \verbinclude Matrix_setConstant_int.out
*
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int size, const Scalar& value)
{
resize(size);
return setConstant(value);
}
/** Resizes to the given size, and sets all coefficients in this expression to the given \a value.
*
* \param rows the new number of rows
* \param cols the new number of columns
*
* Example: \include Matrix_setConstant_int_int.cpp
* Output: \verbinclude Matrix_setConstant_int_int.out
*
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int rows, int cols, const Scalar& value)
{
resize(rows, cols);
return setConstant(value);
}
// zero:
/** \returns an expression of a zero matrix.
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
* instead.
*
* \addexample Zero \label How to take get a zero matrix
*
* Example: \include MatrixBase_zero_int_int.cpp
* Output: \verbinclude MatrixBase_zero_int_int.out
*
* \sa Zero(), Zero(int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Zero(int rows, int cols)
{
return Constant(rows, cols, Scalar(0));
}
/** \returns an expression of a zero vector.
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
*
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
* it is redundant to pass \a size as argument, so Zero() should be used
* instead.
*
* Example: \include MatrixBase_zero_int.cpp
* Output: \verbinclude MatrixBase_zero_int.out
*
* \sa Zero(), Zero(int,int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Zero(int size)
{
return Constant(size, Scalar(0));
}
/** \returns an expression of a fixed-size zero matrix or vector.
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* Example: \include MatrixBase_zero.cpp
* Output: \verbinclude MatrixBase_zero.out
*
* \sa Zero(int), Zero(int,int)
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Zero()
{
return Constant(Scalar(0));
}
/** \returns true if *this is approximately equal to the zero matrix,
* within the precision given by \a prec.
*
* Example: \include MatrixBase_isZero.cpp
* Output: \verbinclude MatrixBase_isZero.out
*
* \sa class CwiseNullaryOp, Zero()
*/
template<typename Derived>
bool MatrixBase<Derived>::isZero(RealScalar prec) const
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<Scalar>(1), prec))
return false;
return true;
}
/** Sets all coefficients in this expression to zero.
*
* Example: \include MatrixBase_setZero.cpp
* Output: \verbinclude MatrixBase_setZero.out
*
* \sa class CwiseNullaryOp, Zero()
*/
template<typename Derived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setZero()
{
return setConstant(Scalar(0));
}
/** Resizes to the given \a size, and sets all coefficients in this expression to zero.
*
* \only_for_vectors
*
* Example: \include Matrix_setZero_int.cpp
* Output: \verbinclude Matrix_setZero_int.out
*
* \sa MatrixBase::setZero(), setZero(int,int), class CwiseNullaryOp, MatrixBase::Zero()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int size)
{
resize(size);
return setConstant(Scalar(0));
}
/** Resizes to the given size, and sets all coefficients in this expression to zero.
*
* \param rows the new number of rows
* \param cols the new number of columns
*
* Example: \include Matrix_setZero_int_int.cpp
* Output: \verbinclude Matrix_setZero_int_int.out
*
* \sa MatrixBase::setZero(), setZero(int), class CwiseNullaryOp, MatrixBase::Zero()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int rows, int cols)
{
resize(rows, cols);
return setConstant(Scalar(0));
}
// ones:
/** \returns an expression of a matrix where all coefficients equal one.
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Ones() should be used
* instead.
*
* \addexample One \label How to get a matrix with all coefficients equal one
*
* Example: \include MatrixBase_ones_int_int.cpp
* Output: \verbinclude MatrixBase_ones_int_int.out
*
* \sa Ones(), Ones(int), isOnes(), class Ones
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Ones(int rows, int cols)
{
return Constant(rows, cols, Scalar(1));
}
/** \returns an expression of a vector where all coefficients equal one.
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
*
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
* it is redundant to pass \a size as argument, so Ones() should be used
* instead.
*
* Example: \include MatrixBase_ones_int.cpp
* Output: \verbinclude MatrixBase_ones_int.out
*
* \sa Ones(), Ones(int,int), isOnes(), class Ones
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Ones(int size)
{
return Constant(size, Scalar(1));
}
/** \returns an expression of a fixed-size matrix or vector where all coefficients equal one.
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* Example: \include MatrixBase_ones.cpp
* Output: \verbinclude MatrixBase_ones.out
*
* \sa Ones(int), Ones(int,int), isOnes(), class Ones
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
MatrixBase<Derived>::Ones()
{
return Constant(Scalar(1));
}
/** \returns true if *this is approximately equal to the matrix where all coefficients
* are equal to 1, within the precision given by \a prec.
*
* Example: \include MatrixBase_isOnes.cpp
* Output: \verbinclude MatrixBase_isOnes.out
*
* \sa class CwiseNullaryOp, Ones()
*/
template<typename Derived>
bool MatrixBase<Derived>::isOnes
(RealScalar prec) const
{
return isApproxToConstant(Scalar(1), prec);
}
/** Sets all coefficients in this expression to one.
*
* Example: \include MatrixBase_setOnes.cpp
* Output: \verbinclude MatrixBase_setOnes.out
*
* \sa class CwiseNullaryOp, Ones()
*/
template<typename Derived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setOnes()
{
return setConstant(Scalar(1));
}
/** Resizes to the given \a size, and sets all coefficients in this expression to one.
*
* \only_for_vectors
*
* Example: \include Matrix_setOnes_int.cpp
* Output: \verbinclude Matrix_setOnes_int.out
*
* \sa MatrixBase::setOnes(), setOnes(int,int), class CwiseNullaryOp, MatrixBase::Ones()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int size)
{
resize(size);
return setConstant(Scalar(1));
}
/** Resizes to the given size, and sets all coefficients in this expression to one.
*
* \param rows the new number of rows
* \param cols the new number of columns
*
* Example: \include Matrix_setOnes_int_int.cpp
* Output: \verbinclude Matrix_setOnes_int_int.out
*
* \sa MatrixBase::setOnes(), setOnes(int), class CwiseNullaryOp, MatrixBase::Ones()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int rows, int cols)
{
resize(rows, cols);
return setConstant(Scalar(1));
}
// Identity:
/** \returns an expression of the identity matrix (not necessarily square).
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Identity() should be used
* instead.
*
* \addexample Identity \label How to get an identity matrix
*
* Example: \include MatrixBase_identity_int_int.cpp
* Output: \verbinclude MatrixBase_identity_int_int.out
*
* \sa Identity(), setIdentity(), isIdentity()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
MatrixBase<Derived>::Identity(int rows, int cols)
{
return NullaryExpr(rows, cols, ei_scalar_identity_op<Scalar>());
}
/** \returns an expression of the identity matrix (not necessarily square).
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variant taking size arguments.
*
* Example: \include MatrixBase_identity.cpp
* Output: \verbinclude MatrixBase_identity.out
*
* \sa Identity(int,int), setIdentity(), isIdentity()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
MatrixBase<Derived>::Identity()
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>());
}
/** \returns true if *this is approximately equal to the identity matrix
* (not necessarily square),
* within the precision given by \a prec.
*
* Example: \include MatrixBase_isIdentity.cpp
* Output: \verbinclude MatrixBase_isIdentity.out
*
* \sa class CwiseNullaryOp, Identity(), Identity(int,int), setIdentity()
*/
template<typename Derived>
bool MatrixBase<Derived>::isIdentity
(RealScalar prec) const
{
for(int j = 0; j < cols(); ++j)
{
for(int i = 0; i < rows(); ++i)
{
if(i == j)
{
if(!ei_isApprox(coeff(i, j), static_cast<Scalar>(1), prec))
return false;
}
else
{
if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<RealScalar>(1), prec))
return false;
}
}
}
return true;
}
template<typename Derived, bool Big = (Derived::SizeAtCompileTime>=16)>
struct ei_setIdentity_impl
{
static EIGEN_STRONG_INLINE Derived& run(Derived& m)
{
return m = Derived::Identity(m.rows(), m.cols());
}
};
template<typename Derived>
struct ei_setIdentity_impl<Derived, true>
{
static EIGEN_STRONG_INLINE Derived& run(Derived& m)
{
m.setZero();
const int size = std::min(m.rows(), m.cols());
for(int i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1);
return m;
}
};
/** Writes the identity expression (not necessarily square) into *this.
*
* Example: \include MatrixBase_setIdentity.cpp
* Output: \verbinclude MatrixBase_setIdentity.out
*
* \sa class CwiseNullaryOp, Identity(), Identity(int,int), isIdentity()
*/
template<typename Derived>
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity()
{
return ei_setIdentity_impl<Derived>::run(derived());
}
/** Resizes to the given size, and writes the identity expression (not necessarily square) into *this.
*
* \param rows the new number of rows
* \param cols the new number of columns
*
* Example: \include Matrix_setIdentity_int_int.cpp
* Output: \verbinclude Matrix_setIdentity_int_int.out
*
* \sa MatrixBase::setIdentity(), class CwiseNullaryOp, MatrixBase::Identity()
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setIdentity(int rows, int cols)
{
resize(rows, cols);
return setIdentity();
}
/** \returns an expression of the i-th unit (basis) vector.
*
* \only_for_vectors
*
* \sa MatrixBase::Unit(int), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(int size, int i)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return BasisReturnType(SquareMatrixType::Identity(size,size), i);
}
/** \returns an expression of the i-th unit (basis) vector.
*
* \only_for_vectors
*
* This variant is for fixed-size vector only.
*
* \sa MatrixBase::Unit(int,int), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(int i)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return BasisReturnType(SquareMatrixType::Identity(),i);
}
/** \returns an expression of the X axis unit vector (1{,0}^*)
*
* \only_for_vectors
*
* \sa MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX()
{ return Derived::Unit(0); }
/** \returns an expression of the Y axis unit vector (0,1{,0}^*)
*
* \only_for_vectors
*
* \sa MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY()
{ return Derived::Unit(1); }
/** \returns an expression of the Z axis unit vector (0,0,1{,0}^*)
*
* \only_for_vectors
*
* \sa MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ()
{ return Derived::Unit(2); }
/** \returns an expression of the W axis unit vector (0,0,0,1)
*
* \only_for_vectors
*
* \sa MatrixBase::Unit(int,int), MatrixBase::Unit(int), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
*/
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW()
{ return Derived::Unit(3); }
#endif // EIGEN_CWISE_NULLARY_OP_H

View File

@@ -0,0 +1,229 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CWISE_UNARY_OP_H
#define EIGEN_CWISE_UNARY_OP_H
/** \class CwiseUnaryOp
*
* \brief Generic expression of a coefficient-wise unary operator of a matrix or a vector
*
* \param UnaryOp template functor implementing the operator
* \param MatrixType the type of the matrix we are applying the unary operator
*
* This class represents an expression of a generic unary operator of a matrix or a vector.
* It is the return type of the unary operator-, of a matrix or a vector, and most
* of the time this is the only way it is used.
*
* \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
*/
template<typename UnaryOp, typename MatrixType>
struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
: ei_traits<MatrixType>
{
typedef typename ei_result_of<
UnaryOp(typename MatrixType::Scalar)
>::type Scalar;
typedef typename MatrixType::Nested MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
Flags = (_MatrixTypeNested::Flags & (
HereditaryBits | LinearAccessBit | AlignedBit
| (ei_functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0))),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost
};
};
template<typename UnaryOp, typename MatrixType>
class CwiseUnaryOp : ei_no_assignment_operator,
public MatrixBase<CwiseUnaryOp<UnaryOp, MatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
inline CwiseUnaryOp(const MatrixType& mat, const UnaryOp& func = UnaryOp())
: m_matrix(mat), m_functor(func) {}
EIGEN_STRONG_INLINE int rows() const { return m_matrix.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_matrix.cols(); }
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
{
return m_functor(m_matrix.coeff(row, col));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
{
return m_functor.packetOp(m_matrix.template packet<LoadMode>(row, col));
}
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
return m_functor(m_matrix.coeff(index));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int index) const
{
return m_functor.packetOp(m_matrix.template packet<LoadMode>(index));
}
protected:
const typename MatrixType::Nested m_matrix;
const UnaryOp m_functor;
};
/** \returns an expression of a custom coefficient-wise unary operator \a func of *this
*
* The template parameter \a CustomUnaryOp is the type of the functor
* of the custom unary operator.
*
* \addexample CustomCwiseUnaryFunctors \label How to use custom coeff wise unary functors
*
* Example:
* \include class_CwiseUnaryOp.cpp
* Output: \verbinclude class_CwiseUnaryOp.out
*
* \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs
*/
template<typename Derived>
template<typename CustomUnaryOp>
EIGEN_STRONG_INLINE const CwiseUnaryOp<CustomUnaryOp, Derived>
MatrixBase<Derived>::unaryExpr(const CustomUnaryOp& func) const
{
return CwiseUnaryOp<CustomUnaryOp, Derived>(derived(), func);
}
/** \returns an expression of the opposite of \c *this
*/
template<typename Derived>
EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived>
MatrixBase<Derived>::operator-() const
{
return derived();
}
/** \returns an expression of the coefficient-wise absolute value of \c *this
*
* Example: \include Cwise_abs.cpp
* Output: \verbinclude Cwise_abs.out
*
* \sa abs2()
*/
template<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
Cwise<ExpressionType>::abs() const
{
return _expression();
}
/** \returns an expression of the coefficient-wise squared absolute value of \c *this
*
* Example: \include Cwise_abs2.cpp
* Output: \verbinclude Cwise_abs2.out
*
* \sa abs(), square()
*/
template<typename ExpressionType>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
Cwise<ExpressionType>::abs2() const
{
return _expression();
}
/** \returns an expression of the complex conjugate of \c *this.
*
* \sa adjoint() */
template<typename Derived>
EIGEN_STRONG_INLINE typename MatrixBase<Derived>::ConjugateReturnType
MatrixBase<Derived>::conjugate() const
{
return ConjugateReturnType(derived());
}
/** \returns an expression of the real part of \c *this.
*
* \sa imag() */
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::RealReturnType
MatrixBase<Derived>::real() const { return derived(); }
/** \returns an expression of the imaginary part of \c *this.
*
* \sa real() */
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ImagReturnType
MatrixBase<Derived>::imag() const { return derived(); }
/** \returns an expression of *this with the \a Scalar type casted to
* \a NewScalar.
*
* The template parameter \a NewScalar is the type we are casting the scalars to.
*
* \sa class CwiseUnaryOp
*/
template<typename Derived>
template<typename NewType>
EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived>
MatrixBase<Derived>::cast() const
{
return derived();
}
/** \relates MatrixBase */
template<typename Derived>
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ScalarMultipleReturnType
MatrixBase<Derived>::operator*(const Scalar& scalar) const
{
return CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived>
(derived(), ei_scalar_multiple_op<Scalar>(scalar));
}
/** \relates MatrixBase */
template<typename Derived>
EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::operator/(const Scalar& scalar) const
{
return CwiseUnaryOp<ei_scalar_quotient1_op<Scalar>, Derived>
(derived(), ei_scalar_quotient1_op<Scalar>(scalar));
}
template<typename Derived>
EIGEN_STRONG_INLINE Derived&
MatrixBase<Derived>::operator*=(const Scalar& other)
{
return *this = *this * other;
}
template<typename Derived>
EIGEN_STRONG_INLINE Derived&
MatrixBase<Derived>::operator/=(const Scalar& other)
{
return *this = *this / other;
}
#endif // EIGEN_CWISE_UNARY_OP_H

View File

@@ -0,0 +1,124 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DIAGONALCOEFFS_H
#define EIGEN_DIAGONALCOEFFS_H
/** \class DiagonalCoeffs
*
* \brief Expression of the main diagonal of a matrix
*
* \param MatrixType the type of the object in which we are taking the main diagonal
*
* The matrix is not required to be square.
*
* This class represents an expression of the main diagonal of a square matrix.
* It is the return type of MatrixBase::diagonal() and most of the time this is
* the only way it is used.
*
* \sa MatrixBase::diagonal()
*/
template<typename MatrixType>
struct ei_traits<DiagonalCoeffs<MatrixType> >
{
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
RowsAtCompileTime = int(MatrixType::SizeAtCompileTime) == Dynamic ? Dynamic
: EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,
MatrixType::ColsAtCompileTime),
ColsAtCompileTime = 1,
MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
: EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime,
MatrixType::MaxColsAtCompileTime),
MaxColsAtCompileTime = 1,
Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
};
};
template<typename MatrixType> class DiagonalCoeffs
: public MatrixBase<DiagonalCoeffs<MatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(DiagonalCoeffs)
inline DiagonalCoeffs(const MatrixType& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
inline int rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
inline int cols() const { return 1; }
inline Scalar& coeffRef(int row, int)
{
return m_matrix.const_cast_derived().coeffRef(row, row);
}
inline const Scalar coeff(int row, int) const
{
return m_matrix.coeff(row, row);
}
inline Scalar& coeffRef(int index)
{
return m_matrix.const_cast_derived().coeffRef(index, index);
}
inline const Scalar coeff(int index) const
{
return m_matrix.coeff(index, index);
}
protected:
const typename MatrixType::Nested m_matrix;
};
/** \returns an expression of the main diagonal of the matrix \c *this
*
* \c *this is not required to be square.
*
* Example: \include MatrixBase_diagonal.cpp
* Output: \verbinclude MatrixBase_diagonal.out
*
* \sa class DiagonalCoeffs */
template<typename Derived>
inline DiagonalCoeffs<Derived>
MatrixBase<Derived>::diagonal()
{
return DiagonalCoeffs<Derived>(derived());
}
/** This is the const version of diagonal(). */
template<typename Derived>
inline const DiagonalCoeffs<Derived>
MatrixBase<Derived>::diagonal() const
{
return DiagonalCoeffs<Derived>(derived());
}
#endif // EIGEN_DIAGONALCOEFFS_H

View File

@@ -0,0 +1,144 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DIAGONALMATRIX_H
#define EIGEN_DIAGONALMATRIX_H
/** \class DiagonalMatrix
* \nonstableyet
*
* \brief Expression of a diagonal matrix
*
* \param CoeffsVectorType the type of the vector of diagonal coefficients
*
* This class is an expression of a diagonal matrix with given vector of diagonal
* coefficients. It is the return
* type of MatrixBase::diagonal(const OtherDerived&) and most of the time this is
* the only way it is used.
*
* \sa MatrixBase::diagonal(const OtherDerived&)
*/
template<typename CoeffsVectorType>
struct ei_traits<DiagonalMatrix<CoeffsVectorType> >
{
typedef typename CoeffsVectorType::Scalar Scalar;
typedef typename ei_nested<CoeffsVectorType>::type CoeffsVectorTypeNested;
typedef typename ei_unref<CoeffsVectorTypeNested>::type _CoeffsVectorTypeNested;
enum {
RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
Flags = (_CoeffsVectorTypeNested::Flags & HereditaryBits) | Diagonal,
CoeffReadCost = _CoeffsVectorTypeNested::CoeffReadCost
};
};
template<typename CoeffsVectorType>
class DiagonalMatrix : ei_no_assignment_operator,
public MatrixBase<DiagonalMatrix<CoeffsVectorType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(DiagonalMatrix)
typedef CoeffsVectorType _CoeffsVectorType;
// needed to evaluate a DiagonalMatrix<Xpr> to a DiagonalMatrix<NestByValue<Vector> >
template<typename OtherCoeffsVectorType>
inline DiagonalMatrix(const DiagonalMatrix<OtherCoeffsVectorType>& other) : m_coeffs(other.diagonal())
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(CoeffsVectorType);
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherCoeffsVectorType);
ei_assert(m_coeffs.size() > 0);
}
inline DiagonalMatrix(const CoeffsVectorType& coeffs) : m_coeffs(coeffs)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(CoeffsVectorType);
ei_assert(coeffs.size() > 0);
}
inline int rows() const { return m_coeffs.size(); }
inline int cols() const { return m_coeffs.size(); }
inline const Scalar coeff(int row, int col) const
{
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
}
inline const CoeffsVectorType& diagonal() const { return m_coeffs; }
protected:
const typename CoeffsVectorType::Nested m_coeffs;
};
/** \nonstableyet
* \returns an expression of a diagonal matrix with *this as vector of diagonal coefficients
*
* \only_for_vectors
*
* \addexample AsDiagonalExample \label How to build a diagonal matrix from a vector
*
* Example: \include MatrixBase_asDiagonal.cpp
* Output: \verbinclude MatrixBase_asDiagonal.out
*
* \sa class DiagonalMatrix, isDiagonal()
**/
template<typename Derived>
inline const DiagonalMatrix<Derived>
MatrixBase<Derived>::asDiagonal() const
{
return derived();
}
/** \nonstableyet
* \returns true if *this is approximately equal to a diagonal matrix,
* within the precision given by \a prec.
*
* Example: \include MatrixBase_isDiagonal.cpp
* Output: \verbinclude MatrixBase_isDiagonal.out
*
* \sa asDiagonal()
*/
template<typename Derived>
bool MatrixBase<Derived>::isDiagonal
(RealScalar prec) const
{
if(cols() != rows()) return false;
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);
for(int j = 0; j < cols(); ++j)
{
RealScalar absOnDiagonal = ei_abs(coeff(j,j));
if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
}
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < j; ++i)
{
if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false;
if(!ei_isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false;
}
return true;
}
#endif // EIGEN_DIAGONALMATRIX_H

View File

@@ -0,0 +1,130 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DIAGONALPRODUCT_H
#define EIGEN_DIAGONALPRODUCT_H
/** \internal Specialization of ei_nested for DiagonalMatrix.
* Unlike ei_nested, if the argument is a DiagonalMatrix and if it must be evaluated,
* then it evaluated to a DiagonalMatrix having its own argument evaluated.
*/
template<typename T, int N> struct ei_nested_diagonal : ei_nested<T,N> {};
template<typename T, int N> struct ei_nested_diagonal<DiagonalMatrix<T>,N >
: ei_nested<DiagonalMatrix<T>, N, DiagonalMatrix<NestByValue<typename ei_plain_matrix_type<T>::type> > >
{};
// specialization of ProductReturnType
template<typename Lhs, typename Rhs>
struct ProductReturnType<Lhs,Rhs,DiagonalProduct>
{
typedef typename ei_nested_diagonal<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;
typedef typename ei_nested_diagonal<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;
typedef Product<LhsNested, RhsNested, DiagonalProduct> Type;
};
template<typename LhsNested, typename RhsNested>
struct ei_traits<Product<LhsNested, RhsNested, DiagonalProduct> >
{
// clean the nested types:
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
typedef typename _LhsNested::Scalar Scalar;
enum {
LhsFlags = _LhsNested::Flags,
RhsFlags = _RhsNested::Flags,
RowsAtCompileTime = _LhsNested::RowsAtCompileTime,
ColsAtCompileTime = _RhsNested::ColsAtCompileTime,
MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime,
MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime,
LhsIsDiagonal = (_LhsNested::Flags&Diagonal)==Diagonal,
RhsIsDiagonal = (_RhsNested::Flags&Diagonal)==Diagonal,
CanVectorizeRhs = (!RhsIsDiagonal) && (RhsFlags & RowMajorBit) && (RhsFlags & PacketAccessBit)
&& (ColsAtCompileTime % ei_packet_traits<Scalar>::size == 0),
CanVectorizeLhs = (!LhsIsDiagonal) && (!(LhsFlags & RowMajorBit)) && (LhsFlags & PacketAccessBit)
&& (RowsAtCompileTime % ei_packet_traits<Scalar>::size == 0),
RemovedBits = ~((RhsFlags & RowMajorBit) && (!CanVectorizeLhs) ? 0 : RowMajorBit),
Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
| (((CanVectorizeLhs&&RhsIsDiagonal) || (CanVectorizeRhs&&LhsIsDiagonal)) ? PacketAccessBit : 0),
CoeffReadCost = NumTraits<Scalar>::MulCost + _LhsNested::CoeffReadCost + _RhsNested::CoeffReadCost
};
};
template<typename LhsNested, typename RhsNested> class Product<LhsNested, RhsNested, DiagonalProduct> : ei_no_assignment_operator,
public MatrixBase<Product<LhsNested, RhsNested, DiagonalProduct> >
{
typedef typename ei_traits<Product>::_LhsNested _LhsNested;
typedef typename ei_traits<Product>::_RhsNested _RhsNested;
enum {
RhsIsDiagonal = (_RhsNested::Flags&Diagonal)==Diagonal
};
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Product)
template<typename Lhs, typename Rhs>
inline Product(const Lhs& lhs, const Rhs& rhs)
: m_lhs(lhs), m_rhs(rhs)
{
ei_assert(lhs.cols() == rhs.rows());
}
inline int rows() const { return m_lhs.rows(); }
inline int cols() const { return m_rhs.cols(); }
const Scalar coeff(int row, int col) const
{
const int unique = RhsIsDiagonal ? col : row;
return m_lhs.coeff(row, unique) * m_rhs.coeff(unique, col);
}
template<int LoadMode>
const PacketScalar packet(int row, int col) const
{
if (RhsIsDiagonal)
{
return ei_pmul(m_lhs.template packet<LoadMode>(row, col), ei_pset1(m_rhs.coeff(col, col)));
}
else
{
return ei_pmul(ei_pset1(m_lhs.coeff(row, row)), m_rhs.template packet<LoadMode>(row, col));
}
}
protected:
const LhsNested m_lhs;
const RhsNested m_rhs;
};
#endif // EIGEN_DIAGONALPRODUCT_H

361
extern/Eigen2/Eigen/src/Core/Dot.h vendored Normal file
View File

@@ -0,0 +1,361 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DOT_H
#define EIGEN_DOT_H
/***************************************************************************
* Part 1 : the logic deciding a strategy for vectorization and unrolling
***************************************************************************/
template<typename Derived1, typename Derived2>
struct ei_dot_traits
{
public:
enum {
Vectorization = (int(Derived1::Flags)&int(Derived2::Flags)&ActualPacketAccessBit)
&& (int(Derived1::Flags)&int(Derived2::Flags)&LinearAccessBit)
? LinearVectorization
: NoVectorization
};
private:
typedef typename Derived1::Scalar Scalar;
enum {
PacketSize = ei_packet_traits<Scalar>::size,
Cost = Derived1::SizeAtCompileTime * (Derived1::CoeffReadCost + Derived2::CoeffReadCost + NumTraits<Scalar>::MulCost)
+ (Derived1::SizeAtCompileTime-1) * NumTraits<Scalar>::AddCost,
UnrollingLimit = EIGEN_UNROLLING_LIMIT * (int(Vectorization) == int(NoVectorization) ? 1 : int(PacketSize))
};
public:
enum {
Unrolling = Cost <= UnrollingLimit
? CompleteUnrolling
: NoUnrolling
};
};
/***************************************************************************
* Part 2 : unrollers
***************************************************************************/
/*** no vectorization ***/
template<typename Derived1, typename Derived2, int Start, int Length>
struct ei_dot_novec_unroller
{
enum {
HalfLength = Length/2
};
typedef typename Derived1::Scalar Scalar;
inline static Scalar run(const Derived1& v1, const Derived2& v2)
{
return ei_dot_novec_unroller<Derived1, Derived2, Start, HalfLength>::run(v1, v2)
+ ei_dot_novec_unroller<Derived1, Derived2, Start+HalfLength, Length-HalfLength>::run(v1, v2);
}
};
template<typename Derived1, typename Derived2, int Start>
struct ei_dot_novec_unroller<Derived1, Derived2, Start, 1>
{
typedef typename Derived1::Scalar Scalar;
inline static Scalar run(const Derived1& v1, const Derived2& v2)
{
return v1.coeff(Start) * ei_conj(v2.coeff(Start));
}
};
/*** vectorization ***/
template<typename Derived1, typename Derived2, int Index, int Stop,
bool LastPacket = (Stop-Index == ei_packet_traits<typename Derived1::Scalar>::size)>
struct ei_dot_vec_unroller
{
typedef typename Derived1::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
enum {
row1 = Derived1::RowsAtCompileTime == 1 ? 0 : Index,
col1 = Derived1::RowsAtCompileTime == 1 ? Index : 0,
row2 = Derived2::RowsAtCompileTime == 1 ? 0 : Index,
col2 = Derived2::RowsAtCompileTime == 1 ? Index : 0
};
inline static PacketScalar run(const Derived1& v1, const Derived2& v2)
{
return ei_pmadd(
v1.template packet<Aligned>(row1, col1),
v2.template packet<Aligned>(row2, col2),
ei_dot_vec_unroller<Derived1, Derived2, Index+ei_packet_traits<Scalar>::size, Stop>::run(v1, v2)
);
}
};
template<typename Derived1, typename Derived2, int Index, int Stop>
struct ei_dot_vec_unroller<Derived1, Derived2, Index, Stop, true>
{
enum {
row1 = Derived1::RowsAtCompileTime == 1 ? 0 : Index,
col1 = Derived1::RowsAtCompileTime == 1 ? Index : 0,
row2 = Derived2::RowsAtCompileTime == 1 ? 0 : Index,
col2 = Derived2::RowsAtCompileTime == 1 ? Index : 0,
alignment1 = (Derived1::Flags & AlignedBit) ? Aligned : Unaligned,
alignment2 = (Derived2::Flags & AlignedBit) ? Aligned : Unaligned
};
typedef typename Derived1::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
inline static PacketScalar run(const Derived1& v1, const Derived2& v2)
{
return ei_pmul(v1.template packet<alignment1>(row1, col1), v2.template packet<alignment2>(row2, col2));
}
};
/***************************************************************************
* Part 3 : implementation of all cases
***************************************************************************/
template<typename Derived1, typename Derived2,
int Vectorization = ei_dot_traits<Derived1, Derived2>::Vectorization,
int Unrolling = ei_dot_traits<Derived1, Derived2>::Unrolling
>
struct ei_dot_impl;
template<typename Derived1, typename Derived2>
struct ei_dot_impl<Derived1, Derived2, NoVectorization, NoUnrolling>
{
typedef typename Derived1::Scalar Scalar;
static Scalar run(const Derived1& v1, const Derived2& v2)
{
ei_assert(v1.size()>0 && "you are using a non initialized vector");
Scalar res;
res = v1.coeff(0) * ei_conj(v2.coeff(0));
for(int i = 1; i < v1.size(); ++i)
res += v1.coeff(i) * ei_conj(v2.coeff(i));
return res;
}
};
template<typename Derived1, typename Derived2>
struct ei_dot_impl<Derived1, Derived2, NoVectorization, CompleteUnrolling>
: public ei_dot_novec_unroller<Derived1, Derived2, 0, Derived1::SizeAtCompileTime>
{};
template<typename Derived1, typename Derived2>
struct ei_dot_impl<Derived1, Derived2, LinearVectorization, NoUnrolling>
{
typedef typename Derived1::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
static Scalar run(const Derived1& v1, const Derived2& v2)
{
const int size = v1.size();
const int packetSize = ei_packet_traits<Scalar>::size;
const int alignedSize = (size/packetSize)*packetSize;
enum {
alignment1 = (Derived1::Flags & AlignedBit) ? Aligned : Unaligned,
alignment2 = (Derived2::Flags & AlignedBit) ? Aligned : Unaligned
};
Scalar res;
// do the vectorizable part of the sum
if(size >= packetSize)
{
PacketScalar packet_res = ei_pmul(
v1.template packet<alignment1>(0),
v2.template packet<alignment2>(0)
);
for(int index = packetSize; index<alignedSize; index += packetSize)
{
packet_res = ei_pmadd(
v1.template packet<alignment1>(index),
v2.template packet<alignment2>(index),
packet_res
);
}
res = ei_predux(packet_res);
// now we must do the rest without vectorization.
if(alignedSize == size) return res;
}
else // too small to vectorize anything.
// since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.
{
res = Scalar(0);
}
// do the remainder of the vector
for(int index = alignedSize; index < size; ++index)
{
res += v1.coeff(index) * v2.coeff(index);
}
return res;
}
};
template<typename Derived1, typename Derived2>
struct ei_dot_impl<Derived1, Derived2, LinearVectorization, CompleteUnrolling>
{
typedef typename Derived1::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
enum {
PacketSize = ei_packet_traits<Scalar>::size,
Size = Derived1::SizeAtCompileTime,
VectorizationSize = (Size / PacketSize) * PacketSize
};
static Scalar run(const Derived1& v1, const Derived2& v2)
{
Scalar res = ei_predux(ei_dot_vec_unroller<Derived1, Derived2, 0, VectorizationSize>::run(v1, v2));
if (VectorizationSize != Size)
res += ei_dot_novec_unroller<Derived1, Derived2, VectorizationSize, Size-VectorizationSize>::run(v1, v2);
return res;
}
};
/***************************************************************************
* Part 4 : implementation of MatrixBase methods
***************************************************************************/
/** \returns the dot product of *this with other.
*
* \only_for_vectors
*
* \note If the scalar type is complex numbers, then this function returns the hermitian
* (sesquilinear) dot product, linear in the first variable and conjugate-linear in the
* second variable.
*
* \sa squaredNorm(), norm()
*/
template<typename Derived>
template<typename OtherDerived>
typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
ei_assert(size() == other.size());
return ei_dot_impl<Derived, OtherDerived>::run(derived(), other.derived());
}
/** \returns the squared \em l2 norm of *this, i.e., for vectors, the dot product of *this with itself.
*
* \sa dot(), norm()
*/
template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const
{
return ei_real((*this).cwise().abs2().sum());
}
/** \returns the \em l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself.
*
* \sa dot(), squaredNorm()
*/
template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
{
return ei_sqrt(squaredNorm());
}
/** \returns an expression of the quotient of *this by its own norm.
*
* \only_for_vectors
*
* \sa norm(), normalize()
*/
template<typename Derived>
inline const typename MatrixBase<Derived>::PlainMatrixType
MatrixBase<Derived>::normalized() const
{
typedef typename ei_nested<Derived>::type Nested;
typedef typename ei_unref<Nested>::type _Nested;
_Nested n(derived());
return n / n.norm();
}
/** Normalizes the vector, i.e. divides it by its own norm.
*
* \only_for_vectors
*
* \sa norm(), normalized()
*/
template<typename Derived>
inline void MatrixBase<Derived>::normalize()
{
*this /= norm();
}
/** \returns true if *this is approximately orthogonal to \a other,
* within the precision given by \a prec.
*
* Example: \include MatrixBase_isOrthogonal.cpp
* Output: \verbinclude MatrixBase_isOrthogonal.out
*/
template<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isOrthogonal
(const MatrixBase<OtherDerived>& other, RealScalar prec) const
{
typename ei_nested<Derived,2>::type nested(derived());
typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
return ei_abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
}
/** \returns true if *this is approximately an unitary matrix,
* within the precision given by \a prec. In the case where the \a Scalar
* type is real numbers, a unitary matrix is an orthogonal matrix, whence the name.
*
* \note This can be used to check whether a family of vectors forms an orthonormal basis.
* Indeed, \c m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an
* orthonormal basis.
*
* Example: \include MatrixBase_isUnitary.cpp
* Output: \verbinclude MatrixBase_isUnitary.out
*/
template<typename Derived>
bool MatrixBase<Derived>::isUnitary(RealScalar prec) const
{
typename Derived::Nested nested(derived());
for(int i = 0; i < cols(); ++i)
{
if(!ei_isApprox(nested.col(i).squaredNorm(), static_cast<Scalar>(1), prec))
return false;
for(int j = 0; j < i; ++j)
if(!ei_isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast<Scalar>(1), prec))
return false;
}
return true;
}
#endif // EIGEN_DOT_H

149
extern/Eigen2/Eigen/src/Core/Flagged.h vendored Normal file
View File

@@ -0,0 +1,149 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_FLAGGED_H
#define EIGEN_FLAGGED_H
/** \class Flagged
*
* \brief Expression with modified flags
*
* \param ExpressionType the type of the object of which we are modifying the flags
* \param Added the flags added to the expression
* \param Removed the flags removed from the expression (has priority over Added).
*
* This class represents an expression whose flags have been modified.
* It is the return type of MatrixBase::flagged()
* and most of the time this is the only way it is used.
*
* \sa MatrixBase::flagged()
*/
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
struct ei_traits<Flagged<ExpressionType, Added, Removed> > : ei_traits<ExpressionType>
{
enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
};
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged
: public MatrixBase<Flagged<ExpressionType, Added, Removed> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Flagged)
typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
typedef typename ExpressionType::InnerIterator InnerIterator;
inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {}
inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
inline int stride() const { return m_matrix.stride(); }
inline const Scalar coeff(int row, int col) const
{
return m_matrix.coeff(row, col);
}
inline Scalar& coeffRef(int row, int col)
{
return m_matrix.const_cast_derived().coeffRef(row, col);
}
inline const Scalar coeff(int index) const
{
return m_matrix.coeff(index);
}
inline Scalar& coeffRef(int index)
{
return m_matrix.const_cast_derived().coeffRef(index);
}
template<int LoadMode>
inline const PacketScalar packet(int row, int col) const
{
return m_matrix.template packet<LoadMode>(row, col);
}
template<int LoadMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
}
template<int LoadMode>
inline const PacketScalar packet(int index) const
{
return m_matrix.template packet<LoadMode>(index);
}
template<int LoadMode>
inline void writePacket(int index, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
}
const ExpressionType& _expression() const { return m_matrix; }
protected:
ExpressionTypeNested m_matrix;
private:
Flagged& operator=(const Flagged&);
};
/** \returns an expression of *this with added flags
*
* \addexample MarkExample \label How to mark a triangular matrix as triangular
*
* Example: \include MatrixBase_marked.cpp
* Output: \verbinclude MatrixBase_marked.out
*
* \sa class Flagged, extract(), part()
*/
template<typename Derived>
template<unsigned int Added>
inline const Flagged<Derived, Added, 0>
MatrixBase<Derived>::marked() const
{
return derived();
}
/** \returns an expression of *this with the following flags removed:
* EvalBeforeNestingBit and EvalBeforeAssigningBit.
*
* Example: \include MatrixBase_lazy.cpp
* Output: \verbinclude MatrixBase_lazy.out
*
* \sa class Flagged, marked()
*/
template<typename Derived>
inline const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>
MatrixBase<Derived>::lazy() const
{
return derived();
}
#endif // EIGEN_FLAGGED_H

378
extern/Eigen2/Eigen/src/Core/Functors.h vendored Normal file
View File

@@ -0,0 +1,378 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_FUNCTORS_H
#define EIGEN_FUNCTORS_H
// associative functors:
/** \internal
* \brief Template functor to compute the sum of two scalars
*
* \sa class CwiseBinaryOp, MatrixBase::operator+, class PartialRedux, MatrixBase::sum()
*/
template<typename Scalar> struct ei_scalar_sum_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_padd(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_sum_op<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
};
};
/** \internal
* \brief Template functor to compute the product of two scalars
*
* \sa class CwiseBinaryOp, Cwise::operator*(), class PartialRedux, MatrixBase::redux()
*/
template<typename Scalar> struct ei_scalar_product_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a * b; }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_pmul(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_product_op<Scalar> > {
enum {
Cost = NumTraits<Scalar>::MulCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
};
};
/** \internal
* \brief Template functor to compute the min of two scalars
*
* \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class PartialRedux, MatrixBase::minCoeff()
*/
template<typename Scalar> struct ei_scalar_min_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::min(a, b); }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_pmin(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_min_op<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
};
};
/** \internal
* \brief Template functor to compute the max of two scalars
*
* \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class PartialRedux, MatrixBase::maxCoeff()
*/
template<typename Scalar> struct ei_scalar_max_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::max(a, b); }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_pmax(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_max_op<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
};
};
// other binary functors:
/** \internal
* \brief Template functor to compute the difference of two scalars
*
* \sa class CwiseBinaryOp, MatrixBase::operator-
*/
template<typename Scalar> struct ei_scalar_difference_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_psub(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_difference_op<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
};
};
/** \internal
* \brief Template functor to compute the quotient of two scalars
*
* \sa class CwiseBinaryOp, Cwise::operator/()
*/
template<typename Scalar> struct ei_scalar_quotient_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a / b; }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a, const PacketScalar& b) const
{ return ei_pdiv(a,b); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_quotient_op<Scalar> > {
enum {
Cost = 2 * NumTraits<Scalar>::MulCost,
PacketAccess = ei_packet_traits<Scalar>::size>1
#if (defined EIGEN_VECTORIZE_SSE)
&& NumTraits<Scalar>::HasFloatingPoint
#endif
};
};
// unary functors:
/** \internal
* \brief Template functor to compute the opposite of a scalar
*
* \sa class CwiseUnaryOp, MatrixBase::operator-
*/
template<typename Scalar> struct ei_scalar_opposite_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_opposite_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false }; };
/** \internal
* \brief Template functor to compute the absolute value of a scalar
*
* \sa class CwiseUnaryOp, Cwise::abs
*/
template<typename Scalar> struct ei_scalar_abs_op EIGEN_EMPTY_STRUCT {
typedef typename NumTraits<Scalar>::Real result_type;
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return ei_abs(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_abs_op<Scalar> >
{
enum {
Cost = NumTraits<Scalar>::AddCost,
PacketAccess = false // this could actually be vectorized with SSSE3.
};
};
/** \internal
* \brief Template functor to compute the squared absolute value of a scalar
*
* \sa class CwiseUnaryOp, Cwise::abs2
*/
template<typename Scalar> struct ei_scalar_abs2_op EIGEN_EMPTY_STRUCT {
typedef typename NumTraits<Scalar>::Real result_type;
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return ei_abs2(a); }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pmul(a,a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_abs2_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
/** \internal
* \brief Template functor to compute the conjugate of a complex value
*
* \sa class CwiseUnaryOp, MatrixBase::conjugate()
*/
template<typename Scalar> struct ei_scalar_conjugate_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return ei_conj(a); }
template<typename PacketScalar>
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a) const { return a; }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_conjugate_op<Scalar> >
{
enum {
Cost = NumTraits<Scalar>::IsComplex ? NumTraits<Scalar>::AddCost : 0,
PacketAccess = int(ei_packet_traits<Scalar>::size)>1
};
};
/** \internal
* \brief Template functor to cast a scalar to another type
*
* \sa class CwiseUnaryOp, MatrixBase::cast()
*/
template<typename Scalar, typename NewType>
struct ei_scalar_cast_op EIGEN_EMPTY_STRUCT {
typedef NewType result_type;
EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return static_cast<NewType>(a); }
};
template<typename Scalar, typename NewType>
struct ei_functor_traits<ei_scalar_cast_op<Scalar,NewType> >
{ enum { Cost = ei_is_same_type<Scalar, NewType>::ret ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; };
/** \internal
* \brief Template functor to extract the real part of a complex
*
* \sa class CwiseUnaryOp, MatrixBase::real()
*/
template<typename Scalar>
struct ei_scalar_real_op EIGEN_EMPTY_STRUCT {
typedef typename NumTraits<Scalar>::Real result_type;
EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return ei_real(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_real_op<Scalar> >
{ enum { Cost = 0, PacketAccess = false }; };
/** \internal
* \brief Template functor to extract the imaginary part of a complex
*
* \sa class CwiseUnaryOp, MatrixBase::imag()
*/
template<typename Scalar>
struct ei_scalar_imag_op EIGEN_EMPTY_STRUCT {
typedef typename NumTraits<Scalar>::Real result_type;
EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return ei_imag(a); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_imag_op<Scalar> >
{ enum { Cost = 0, PacketAccess = false }; };
/** \internal
* \brief Template functor to multiply a scalar by a fixed other one
*
* \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/
*/
/* NOTE why doing the ei_pset1() in packetOp *is* an optimization ?
* indeed it seems better to declare m_other as a PacketScalar and do the ei_pset1() once
* in the constructor. However, in practice:
* - GCC does not like m_other as a PacketScalar and generate a load every time it needs it
* - one the other hand GCC is able to moves the ei_pset1() away the loop :)
* - simpler code ;)
* (ICC and gcc 4.4 seems to perform well in both cases, the issue is visible with y = a*x + b*y)
*/
template<typename Scalar>
struct ei_scalar_multiple_op {
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
// FIXME default copy constructors seems bugged with std::complex<>
EIGEN_STRONG_INLINE ei_scalar_multiple_op(const ei_scalar_multiple_op& other) : m_other(other.m_other) { }
EIGEN_STRONG_INLINE ei_scalar_multiple_op(const Scalar& other) : m_other(other) { }
EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; }
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pmul(a, ei_pset1(m_other)); }
const Scalar m_other;
private:
ei_scalar_multiple_op& operator=(const ei_scalar_multiple_op&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_multiple_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::size>1 }; };
template<typename Scalar, bool HasFloatingPoint>
struct ei_scalar_quotient1_impl {
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
// FIXME default copy constructors seems bugged with std::complex<>
EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const ei_scalar_quotient1_impl& other) : m_other(other.m_other) { }
EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const Scalar& other) : m_other(static_cast<Scalar>(1) / other) {}
EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; }
EIGEN_STRONG_INLINE const PacketScalar packetOp(const PacketScalar& a) const
{ return ei_pmul(a, ei_pset1(m_other)); }
const Scalar m_other;
private:
ei_scalar_quotient1_impl& operator=(const ei_scalar_quotient1_impl&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_quotient1_impl<Scalar,true> >
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = ei_packet_traits<Scalar>::size>1 }; };
template<typename Scalar>
struct ei_scalar_quotient1_impl<Scalar,false> {
// FIXME default copy constructors seems bugged with std::complex<>
EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const ei_scalar_quotient1_impl& other) : m_other(other.m_other) { }
EIGEN_STRONG_INLINE ei_scalar_quotient1_impl(const Scalar& other) : m_other(other) {}
EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a / m_other; }
const Scalar m_other;
private:
ei_scalar_quotient1_impl& operator=(const ei_scalar_quotient1_impl&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_quotient1_impl<Scalar,false> >
{ enum { Cost = 2 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
/** \internal
* \brief Template functor to divide a scalar by a fixed other one
*
* This functor is used to implement the quotient of a matrix by
* a scalar where the scalar type is not necessarily a floating point type.
*
* \sa class CwiseUnaryOp, MatrixBase::operator/
*/
template<typename Scalar>
struct ei_scalar_quotient1_op : ei_scalar_quotient1_impl<Scalar, NumTraits<Scalar>::HasFloatingPoint > {
EIGEN_STRONG_INLINE ei_scalar_quotient1_op(const Scalar& other)
: ei_scalar_quotient1_impl<Scalar, NumTraits<Scalar>::HasFloatingPoint >(other) {}
private:
ei_scalar_quotient1_op& operator=(const ei_scalar_quotient1_op&);
};
// nullary functors
template<typename Scalar>
struct ei_scalar_constant_op {
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
EIGEN_STRONG_INLINE ei_scalar_constant_op(const ei_scalar_constant_op& other) : m_other(other.m_other) { }
EIGEN_STRONG_INLINE ei_scalar_constant_op(const Scalar& other) : m_other(other) { }
EIGEN_STRONG_INLINE const Scalar operator() (int, int = 0) const { return m_other; }
EIGEN_STRONG_INLINE const PacketScalar packetOp() const { return ei_pset1(m_other); }
const Scalar m_other;
private:
ei_scalar_constant_op& operator=(const ei_scalar_constant_op&);
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_constant_op<Scalar> >
{ enum { Cost = 1, PacketAccess = ei_packet_traits<Scalar>::size>1, IsRepeatable = true }; };
template<typename Scalar> struct ei_scalar_identity_op EIGEN_EMPTY_STRUCT {
EIGEN_STRONG_INLINE ei_scalar_identity_op(void) {}
EIGEN_STRONG_INLINE const Scalar operator() (int row, int col) const { return row==col ? Scalar(1) : Scalar(0); }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_identity_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false, IsRepeatable = true }; };
// allow to add new functors and specializations of ei_functor_traits from outside Eigen.
// this macro is really needed because ei_functor_traits must be specialized after it is declared but before it is used...
#ifdef EIGEN_FUNCTORS_PLUGIN
#include EIGEN_FUNCTORS_PLUGIN
#endif
// all functors allow linear access, except ei_scalar_identity_op. So we fix here a quick meta
// to indicate whether a functor allows linear access, just always answering 'yes' except for
// ei_scalar_identity_op.
template<typename Functor> struct ei_functor_has_linear_access { enum { ret = 1 }; };
template<typename Scalar> struct ei_functor_has_linear_access<ei_scalar_identity_op<Scalar> > { enum { ret = 0 }; };
// in CwiseBinaryOp, we require the Lhs and Rhs to have the same scalar type, except for multiplication
// where we only require them to have the same _real_ scalar type so one may multiply, say, float by complex<float>.
template<typename Functor> struct ei_functor_allows_mixing_real_and_complex { enum { ret = 0 }; };
template<typename Scalar> struct ei_functor_allows_mixing_real_and_complex<ei_scalar_product_op<Scalar> > { enum { ret = 1 }; };
#endif // EIGEN_FUNCTORS_H

234
extern/Eigen2/Eigen/src/Core/Fuzzy.h vendored Normal file
View File

@@ -0,0 +1,234 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_FUZZY_H
#define EIGEN_FUZZY_H
#ifndef EIGEN_LEGACY_COMPARES
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$
* are considered to be approximately equal within precision \f$ p \f$ if
* \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f]
* For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm
* L2 norm).
*
* \note Because of the multiplicativeness of this comparison, one can't use this function
* to check whether \c *this is approximately equal to the zero matrix or vector.
* Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix
* or vector. If you want to test whether \c *this is zero, use ei_isMuchSmallerThan(const
* RealScalar&, RealScalar) instead.
*
* \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
*/
template<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isApprox(
const MatrixBase<OtherDerived>& other,
typename NumTraits<Scalar>::Real prec
) const
{
const typename ei_nested<Derived,2>::type nested(derived());
const typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
return (nested - otherNested).cwise().abs2().sum() <= prec * prec * std::min(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum());
}
/** \returns \c true if the norm of \c *this is much smaller than \a other,
* within the precision determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
* considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
*
* For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason,
* the value of the reference scalar \a other should come from the Hilbert-Schmidt norm
* of a reference matrix of same dimensions.
*
* \sa isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
*/
template<typename Derived>
bool MatrixBase<Derived>::isMuchSmallerThan(
const typename NumTraits<Scalar>::Real& other,
typename NumTraits<Scalar>::Real prec
) const
{
return cwise().abs2().sum() <= prec * prec * other * other;
}
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
* within the precision determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
* considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if
* \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f]
* For matrices, the comparison is done using the Hilbert-Schmidt norm.
*
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
*/
template<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isMuchSmallerThan(
const MatrixBase<OtherDerived>& other,
typename NumTraits<Scalar>::Real prec
) const
{
return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum();
}
#else
template<typename Derived, typename OtherDerived=Derived, bool IsVector=Derived::IsVectorAtCompileTime>
struct ei_fuzzy_selector;
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$
* are considered to be approximately equal within precision \f$ p \f$ if
* \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f]
* For matrices, the comparison is done on all columns.
*
* \note Because of the multiplicativeness of this comparison, one can't use this function
* to check whether \c *this is approximately equal to the zero matrix or vector.
* Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix
* or vector. If you want to test whether \c *this is zero, use ei_isMuchSmallerThan(const
* RealScalar&, RealScalar) instead.
*
* \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
*/
template<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isApprox(
const MatrixBase<OtherDerived>& other,
typename NumTraits<Scalar>::Real prec
) const
{
return ei_fuzzy_selector<Derived,OtherDerived>::isApprox(derived(), other.derived(), prec);
}
/** \returns \c true if the norm of \c *this is much smaller than \a other,
* within the precision determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
* considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
* For matrices, the comparison is done on all columns.
*
* \sa isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
*/
template<typename Derived>
bool MatrixBase<Derived>::isMuchSmallerThan(
const typename NumTraits<Scalar>::Real& other,
typename NumTraits<Scalar>::Real prec
) const
{
return ei_fuzzy_selector<Derived>::isMuchSmallerThan(derived(), other, prec);
}
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
* within the precision determined by \a prec.
*
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
* considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if
* \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f]
* For matrices, the comparison is done on all columns.
*
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
*/
template<typename Derived>
template<typename OtherDerived>
bool MatrixBase<Derived>::isMuchSmallerThan(
const MatrixBase<OtherDerived>& other,
typename NumTraits<Scalar>::Real prec
) const
{
return ei_fuzzy_selector<Derived,OtherDerived>::isMuchSmallerThan(derived(), other.derived(), prec);
}
template<typename Derived, typename OtherDerived>
struct ei_fuzzy_selector<Derived,OtherDerived,true>
{
typedef typename Derived::RealScalar RealScalar;
static bool isApprox(const Derived& self, const OtherDerived& other, RealScalar prec)
{
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
ei_assert(self.size() == other.size());
return((self - other).squaredNorm() <= std::min(self.squaredNorm(), other.squaredNorm()) * prec * prec);
}
static bool isMuchSmallerThan(const Derived& self, const RealScalar& other, RealScalar prec)
{
return(self.squaredNorm() <= ei_abs2(other * prec));
}
static bool isMuchSmallerThan(const Derived& self, const OtherDerived& other, RealScalar prec)
{
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
ei_assert(self.size() == other.size());
return(self.squaredNorm() <= other.squaredNorm() * prec * prec);
}
};
template<typename Derived, typename OtherDerived>
struct ei_fuzzy_selector<Derived,OtherDerived,false>
{
typedef typename Derived::RealScalar RealScalar;
static bool isApprox(const Derived& self, const OtherDerived& other, RealScalar prec)
{
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
ei_assert(self.rows() == other.rows() && self.cols() == other.cols());
typename Derived::Nested nested(self);
typename OtherDerived::Nested otherNested(other);
for(int i = 0; i < self.cols(); ++i)
if((nested.col(i) - otherNested.col(i)).squaredNorm()
> std::min(nested.col(i).squaredNorm(), otherNested.col(i).squaredNorm()) * prec * prec)
return false;
return true;
}
static bool isMuchSmallerThan(const Derived& self, const RealScalar& other, RealScalar prec)
{
typename Derived::Nested nested(self);
for(int i = 0; i < self.cols(); ++i)
if(nested.col(i).squaredNorm() > ei_abs2(other * prec))
return false;
return true;
}
static bool isMuchSmallerThan(const Derived& self, const OtherDerived& other, RealScalar prec)
{
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
ei_assert(self.rows() == other.rows() && self.cols() == other.cols());
typename Derived::Nested nested(self);
typename OtherDerived::Nested otherNested(other);
for(int i = 0; i < self.cols(); ++i)
if(nested.col(i).squaredNorm() > otherNested.col(i).squaredNorm() * prec * prec)
return false;
return true;
}
};
#endif
#endif // EIGEN_FUZZY_H

View File

@@ -0,0 +1,150 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_GENERIC_PACKET_MATH_H
#define EIGEN_GENERIC_PACKET_MATH_H
/** \internal
* \file GenericPacketMath.h
*
* Default implementation for types not supported by the vectorization.
* In practice these functions are provided to make easier the writing
* of generic vectorized code.
*/
/** \internal \returns a + b (coeff-wise) */
template<typename Packet> inline Packet
ei_padd(const Packet& a,
const Packet& b) { return a+b; }
/** \internal \returns a - b (coeff-wise) */
template<typename Packet> inline Packet
ei_psub(const Packet& a,
const Packet& b) { return a-b; }
/** \internal \returns a * b (coeff-wise) */
template<typename Packet> inline Packet
ei_pmul(const Packet& a,
const Packet& b) { return a*b; }
/** \internal \returns a / b (coeff-wise) */
template<typename Packet> inline Packet
ei_pdiv(const Packet& a,
const Packet& b) { return a/b; }
/** \internal \returns the min of \a a and \a b (coeff-wise) */
template<typename Packet> inline Packet
ei_pmin(const Packet& a,
const Packet& b) { return std::min(a, b); }
/** \internal \returns the max of \a a and \a b (coeff-wise) */
template<typename Packet> inline Packet
ei_pmax(const Packet& a,
const Packet& b) { return std::max(a, b); }
/** \internal \returns a packet version of \a *from, from must be 16 bytes aligned */
template<typename Scalar> inline typename ei_packet_traits<Scalar>::type
ei_pload(const Scalar* from) { return *from; }
/** \internal \returns a packet version of \a *from, (un-aligned load) */
template<typename Scalar> inline typename ei_packet_traits<Scalar>::type
ei_ploadu(const Scalar* from) { return *from; }
/** \internal \returns a packet with constant coefficients \a a, e.g.: (a,a,a,a) */
template<typename Scalar> inline typename ei_packet_traits<Scalar>::type
ei_pset1(const Scalar& a) { return a; }
/** \internal copy the packet \a from to \a *to, \a to must be 16 bytes aligned */
template<typename Scalar, typename Packet> inline void ei_pstore(Scalar* to, const Packet& from)
{ (*to) = from; }
/** \internal copy the packet \a from to \a *to, (un-aligned store) */
template<typename Scalar, typename Packet> inline void ei_pstoreu(Scalar* to, const Packet& from)
{ (*to) = from; }
/** \internal \returns the first element of a packet */
template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_pfirst(const Packet& a)
{ return a; }
/** \internal \returns a packet where the element i contains the sum of the packet of \a vec[i] */
template<typename Packet> inline Packet
ei_preduxp(const Packet* vecs) { return vecs[0]; }
/** \internal \returns the sum of the elements of \a a*/
template<typename Packet> inline typename ei_unpacket_traits<Packet>::type ei_predux(const Packet& a)
{ return a; }
/***************************************************************************
* The following functions might not have to be overwritten for vectorized types
***************************************************************************/
/** \internal \returns a * b + c (coeff-wise) */
template<typename Packet> inline Packet
ei_pmadd(const Packet& a,
const Packet& b,
const Packet& c)
{ return ei_padd(ei_pmul(a, b),c); }
/** \internal \returns a packet version of \a *from.
* \If LoadMode equals Aligned, \a from must be 16 bytes aligned */
template<typename Scalar, int LoadMode>
inline typename ei_packet_traits<Scalar>::type ei_ploadt(const Scalar* from)
{
if(LoadMode == Aligned)
return ei_pload(from);
else
return ei_ploadu(from);
}
/** \internal copy the packet \a from to \a *to.
* If StoreMode equals Aligned, \a to must be 16 bytes aligned */
template<typename Scalar, typename Packet, int LoadMode>
inline void ei_pstoret(Scalar* to, const Packet& from)
{
if(LoadMode == Aligned)
ei_pstore(to, from);
else
ei_pstoreu(to, from);
}
/** \internal default implementation of ei_palign() allowing partial specialization */
template<int Offset,typename PacketType>
struct ei_palign_impl
{
// by default data are aligned, so there is nothing to be done :)
inline static void run(PacketType&, const PacketType&) {}
};
/** \internal update \a first using the concatenation of the \a Offset last elements
* of \a first and packet_size minus \a Offset first elements of \a second */
template<int Offset,typename PacketType>
inline void ei_palign(PacketType& first, const PacketType& second)
{
ei_palign_impl<Offset,PacketType>::run(first,second);
}
#endif // EIGEN_GENERIC_PACKET_MATH_H

184
extern/Eigen2/Eigen/src/Core/IO.h vendored Normal file
View File

@@ -0,0 +1,184 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_IO_H
#define EIGEN_IO_H
enum { Raw, AlignCols };
/** \class IOFormat
*
* \brief Stores a set of parameters controlling the way matrices are printed
*
* List of available parameters:
* - \b precision number of digits for floating point values
* - \b flags can be either Raw (default) or AlignCols which aligns all the columns
* - \b coeffSeparator string printed between two coefficients of the same row
* - \b rowSeparator string printed between two rows
* - \b rowPrefix string printed at the beginning of each row
* - \b rowSuffix string printed at the end of each row
* - \b matPrefix string printed at the beginning of the matrix
* - \b matSuffix string printed at the end of the matrix
*
* Example: \include IOFormat.cpp
* Output: \verbinclude IOFormat.out
*
* \sa MatrixBase::format(), class WithFormat
*/
struct IOFormat
{
/** Default contructor, see class IOFormat for the meaning of the parameters */
IOFormat(int _precision=4, int _flags=Raw,
const std::string& _coeffSeparator = " ",
const std::string& _rowSeparator = "\n", const std::string& _rowPrefix="", const std::string& _rowSuffix="",
const std::string& _matPrefix="", const std::string& _matSuffix="")
: matPrefix(_matPrefix), matSuffix(_matSuffix), rowPrefix(_rowPrefix), rowSuffix(_rowSuffix), rowSeparator(_rowSeparator),
coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags)
{
rowSpacer = "";
int i = int(matSuffix.length())-1;
while (i>=0 && matSuffix[i]!='\n')
{
rowSpacer += ' ';
i--;
}
}
std::string matPrefix, matSuffix;
std::string rowPrefix, rowSuffix, rowSeparator, rowSpacer;
std::string coeffSeparator;
int precision;
int flags;
};
/** \class WithFormat
*
* \brief Pseudo expression providing matrix output with given format
*
* \param ExpressionType the type of the object on which IO stream operations are performed
*
* This class represents an expression with stream operators controlled by a given IOFormat.
* It is the return type of MatrixBase::format()
* and most of the time this is the only way it is used.
*
* See class IOFormat for some examples.
*
* \sa MatrixBase::format(), class IOFormat
*/
template<typename ExpressionType>
class WithFormat
{
public:
WithFormat(const ExpressionType& matrix, const IOFormat& format)
: m_matrix(matrix), m_format(format)
{}
friend std::ostream & operator << (std::ostream & s, const WithFormat& wf)
{
return ei_print_matrix(s, wf.m_matrix.eval(), wf.m_format);
}
protected:
const typename ExpressionType::Nested m_matrix;
IOFormat m_format;
};
/** \returns a WithFormat proxy object allowing to print a matrix the with given
* format \a fmt.
*
* See class IOFormat for some examples.
*
* \sa class IOFormat, class WithFormat
*/
template<typename Derived>
inline const WithFormat<Derived>
MatrixBase<Derived>::format(const IOFormat& fmt) const
{
return WithFormat<Derived>(derived(), fmt);
}
/** \internal
* print the matrix \a _m to the output stream \a s using the output format \a fmt */
template<typename Derived>
std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt)
{
const typename Derived::Nested m = _m;
int width = 0;
if (fmt.flags & AlignCols)
{
// compute the largest width
for(int j = 1; j < m.cols(); ++j)
for(int i = 0; i < m.rows(); ++i)
{
std::stringstream sstr;
sstr.precision(fmt.precision);
sstr << m.coeff(i,j);
width = std::max<int>(width, int(sstr.str().length()));
}
}
s.precision(fmt.precision);
s << fmt.matPrefix;
for(int i = 0; i < m.rows(); ++i)
{
if (i)
s << fmt.rowSpacer;
s << fmt.rowPrefix;
if(width) s.width(width);
s << m.coeff(i, 0);
for(int j = 1; j < m.cols(); ++j)
{
s << fmt.coeffSeparator;
if (width) s.width(width);
s << m.coeff(i, j);
}
s << fmt.rowSuffix;
if( i < m.rows() - 1)
s << fmt.rowSeparator;
}
s << fmt.matSuffix;
return s;
}
/** \relates MatrixBase
*
* Outputs the matrix, to the given stream.
*
* If you wish to print the matrix with a format different than the default, use MatrixBase::format().
*
* It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers.
* If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.
*
* \sa MatrixBase::format()
*/
template<typename Derived>
std::ostream & operator <<
(std::ostream & s,
const MatrixBase<Derived> & m)
{
return ei_print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
}
#endif // EIGEN_IO_H

111
extern/Eigen2/Eigen/src/Core/Map.h vendored Normal file
View File

@@ -0,0 +1,111 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MAP_H
#define EIGEN_MAP_H
/** \class Map
*
* \brief A matrix or vector expression mapping an existing array of data.
*
* \param MatrixType the equivalent matrix type of the mapped data
* \param _PacketAccess allows to enforce aligned loads and stores if set to ForceAligned.
* The default is AsRequested. This parameter is internaly used by Eigen
* in expressions such as \code Map<...>(...) += other; \endcode and most
* of the time this is the only way it is used.
*
* This class represents a matrix or vector expression mapping an existing array of data.
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
* such as plain C arrays or structures from other libraries.
*
* This class is the return type of Matrix::Map() but can also be used directly.
*
* \sa Matrix::Map()
*/
template<typename MatrixType, int _PacketAccess>
struct ei_traits<Map<MatrixType, _PacketAccess> > : public ei_traits<MatrixType>
{
enum {
PacketAccess = _PacketAccess,
Flags = ei_traits<MatrixType>::Flags & ~AlignedBit
};
typedef typename ei_meta_if<int(PacketAccess)==ForceAligned,
Map<MatrixType, _PacketAccess>&,
Map<MatrixType, ForceAligned> >::ret AlignedDerivedType;
};
template<typename MatrixType, int PacketAccess> class Map
: public MapBase<Map<MatrixType, PacketAccess> >
{
public:
_EIGEN_GENERIC_PUBLIC_INTERFACE(Map, MapBase<Map>)
typedef typename ei_traits<Map>::AlignedDerivedType AlignedDerivedType;
inline int stride() const { return this->innerSize(); }
AlignedDerivedType _convertToForceAligned()
{
return Map<MatrixType,ForceAligned>(Base::m_data, Base::m_rows.value(), Base::m_cols.value());
}
inline Map(const Scalar* data) : Base(data) {}
inline Map(const Scalar* data, int size) : Base(data, size) {}
inline Map(const Scalar* data, int rows, int cols) : Base(data, rows, cols) {}
inline void resize(int rows, int cols)
{
EIGEN_ONLY_USED_FOR_DEBUG(rows);
EIGEN_ONLY_USED_FOR_DEBUG(cols);
ei_assert(rows == this->rows());
ei_assert(cols == this->cols());
}
inline void resize(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(MatrixType)
EIGEN_ONLY_USED_FOR_DEBUG(size);
ei_assert(size == this->size());
}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
};
/** Constructor copying an existing array of data.
* Only for fixed-size matrices and vectors.
* \param data The array of data to copy
*
* \sa Matrix::Map(const Scalar *)
*/
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
inline Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>
::Matrix(const Scalar *data)
{
_set_noalias(Eigen::Map<Matrix>(data));
}
#endif // EIGEN_MAP_H

202
extern/Eigen2/Eigen/src/Core/MapBase.h vendored Normal file
View File

@@ -0,0 +1,202 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MAPBASE_H
#define EIGEN_MAPBASE_H
/** \class MapBase
*
* \brief Base class for Map and Block expression with direct access
*
* Expression classes inheriting MapBase must define the constant \c PacketAccess,
* and type \c AlignedDerivedType in their respective ei_traits<> specialization structure.
* The value of \c PacketAccess can be either:
* - \b ForceAligned which enforces both aligned loads and stores
* - \b AsRequested which is the default behavior
* The type \c AlignedDerivedType should correspond to the equivalent expression type
* with \c PacketAccess being \c ForceAligned.
*
* \sa class Map, class Block
*/
template<typename Derived> class MapBase
: public MatrixBase<Derived>
{
public:
typedef MatrixBase<Derived> Base;
enum {
IsRowMajor = (int(ei_traits<Derived>::Flags) & RowMajorBit) ? 1 : 0,
PacketAccess = ei_traits<Derived>::PacketAccess,
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
SizeAtCompileTime = Base::SizeAtCompileTime
};
typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType;
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename Base::PacketScalar PacketScalar;
using Base::derived;
inline int rows() const { return m_rows.value(); }
inline int cols() const { return m_cols.value(); }
inline int stride() const { return derived().stride(); }
inline const Scalar* data() const { return m_data; }
template<bool IsForceAligned,typename Dummy> struct force_aligned_impl {
AlignedDerivedType static run(MapBase& a) { return a.derived(); }
};
template<typename Dummy> struct force_aligned_impl<false,Dummy> {
AlignedDerivedType static run(MapBase& a) { return a.derived()._convertToForceAligned(); }
};
/** \returns an expression equivalent to \c *this but having the \c PacketAccess constant
* set to \c ForceAligned. Must be reimplemented by the derived class. */
AlignedDerivedType forceAligned()
{
return force_aligned_impl<int(PacketAccess)==int(ForceAligned),Derived>::run(*this);
}
inline const Scalar& coeff(int row, int col) const
{
if(IsRowMajor)
return m_data[col + row * stride()];
else // column-major
return m_data[row + col * stride()];
}
inline Scalar& coeffRef(int row, int col)
{
if(IsRowMajor)
return const_cast<Scalar*>(m_data)[col + row * stride()];
else // column-major
return const_cast<Scalar*>(m_data)[row + col * stride()];
}
inline const Scalar coeff(int index) const
{
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
if ( ((RowsAtCompileTime == 1) == IsRowMajor) )
return m_data[index];
else
return m_data[index*stride()];
}
inline Scalar& coeffRef(int index)
{
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
if ( ((RowsAtCompileTime == 1) == IsRowMajor) )
return const_cast<Scalar*>(m_data)[index];
else
return const_cast<Scalar*>(m_data)[index*stride()];
}
template<int LoadMode>
inline PacketScalar packet(int row, int col) const
{
return ei_ploadt<Scalar, int(PacketAccess) == ForceAligned ? Aligned : LoadMode>
(m_data + (IsRowMajor ? col + row * stride()
: row + col * stride()));
}
template<int LoadMode>
inline PacketScalar packet(int index) const
{
return ei_ploadt<Scalar, int(PacketAccess) == ForceAligned ? Aligned : LoadMode>(m_data + index);
}
template<int StoreMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == ForceAligned ? Aligned : StoreMode>
(const_cast<Scalar*>(m_data) + (IsRowMajor ? col + row * stride()
: row + col * stride()), x);
}
template<int StoreMode>
inline void writePacket(int index, const PacketScalar& x)
{
ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == ForceAligned ? Aligned : StoreMode>
(const_cast<Scalar*>(m_data) + index, x);
}
inline MapBase(const Scalar* data) : m_data(data), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
}
inline MapBase(const Scalar* data, int size)
: m_data(data),
m_rows(RowsAtCompileTime == Dynamic ? size : RowsAtCompileTime),
m_cols(ColsAtCompileTime == Dynamic ? size : ColsAtCompileTime)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_assert(size > 0 || data == 0);
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size);
}
inline MapBase(const Scalar* data, int rows, int cols)
: m_data(data), m_rows(rows), m_cols(cols)
{
ei_assert( (data == 0)
|| ( rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
}
Derived& operator=(const MapBase& other)
{
return Base::operator=(other);
}
template<typename OtherDerived>
Derived& operator=(const MatrixBase<OtherDerived>& other)
{
return Base::operator=(other);
}
using Base::operator*=;
template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other)
{ return derived() = forceAligned() + other; }
template<typename OtherDerived>
Derived& operator-=(const MatrixBase<OtherDerived>& other)
{ return derived() = forceAligned() - other; }
Derived& operator*=(const Scalar& other)
{ return derived() = forceAligned() * other; }
Derived& operator/=(const Scalar& other)
{ return derived() = forceAligned() / other; }
protected:
const Scalar* EIGEN_RESTRICT m_data;
const ei_int_if_dynamic<RowsAtCompileTime> m_rows;
const ei_int_if_dynamic<ColsAtCompileTime> m_cols;
};
#endif // EIGEN_MAPBASE_H

View File

@@ -0,0 +1,295 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MATHFUNCTIONS_H
#define EIGEN_MATHFUNCTIONS_H
template<typename T> inline typename NumTraits<T>::Real precision();
template<typename T> inline typename NumTraits<T>::Real machine_epsilon();
template<typename T> inline T ei_random(T a, T b);
template<typename T> inline T ei_random();
template<typename T> inline T ei_random_amplitude()
{
if(NumTraits<T>::HasFloatingPoint) return static_cast<T>(1);
else return static_cast<T>(10);
}
template<typename T> inline T ei_hypot(T x, T y)
{
T _x = ei_abs(x);
T _y = ei_abs(y);
T p = std::max(_x, _y);
T q = std::min(_x, _y);
T qp = q/p;
return p * ei_sqrt(T(1) + qp*qp);
}
/**************
*** int ***
**************/
template<> inline int precision<int>() { return 0; }
template<> inline int machine_epsilon<int>() { return 0; }
inline int ei_real(int x) { return x; }
inline int ei_imag(int) { return 0; }
inline int ei_conj(int x) { return x; }
inline int ei_abs(int x) { return abs(x); }
inline int ei_abs2(int x) { return x*x; }
inline int ei_sqrt(int) { ei_assert(false); return 0; }
inline int ei_exp(int) { ei_assert(false); return 0; }
inline int ei_log(int) { ei_assert(false); return 0; }
inline int ei_sin(int) { ei_assert(false); return 0; }
inline int ei_cos(int) { ei_assert(false); return 0; }
inline int ei_atan2(int, int) { ei_assert(false); return 0; }
inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); }
template<> inline int ei_random(int a, int b)
{
// We can't just do rand()%n as only the high-order bits are really random
return a + static_cast<int>((b-a+1) * (rand() / (RAND_MAX + 1.0)));
}
template<> inline int ei_random()
{
return ei_random<int>(-ei_random_amplitude<int>(), ei_random_amplitude<int>());
}
inline bool ei_isMuchSmallerThan(int a, int, int = precision<int>())
{
return a == 0;
}
inline bool ei_isApprox(int a, int b, int = precision<int>())
{
return a == b;
}
inline bool ei_isApproxOrLessThan(int a, int b, int = precision<int>())
{
return a <= b;
}
/**************
*** float ***
**************/
template<> inline float precision<float>() { return 1e-5f; }
template<> inline float machine_epsilon<float>() { return 1.192e-07f; }
inline float ei_real(float x) { return x; }
inline float ei_imag(float) { return 0.f; }
inline float ei_conj(float x) { return x; }
inline float ei_abs(float x) { return std::abs(x); }
inline float ei_abs2(float x) { return x*x; }
inline float ei_sqrt(float x) { return std::sqrt(x); }
inline float ei_exp(float x) { return std::exp(x); }
inline float ei_log(float x) { return std::log(x); }
inline float ei_sin(float x) { return std::sin(x); }
inline float ei_cos(float x) { return std::cos(x); }
inline float ei_atan2(float y, float x) { return std::atan2(y,x); }
inline float ei_pow(float x, float y) { return std::pow(x, y); }
template<> inline float ei_random(float a, float b)
{
#ifdef EIGEN_NICE_RANDOM
int i;
do { i = ei_random<int>(256*int(a),256*int(b));
} while(i==0);
return float(i)/256.f;
#else
return a + (b-a) * float(std::rand()) / float(RAND_MAX);
#endif
}
template<> inline float ei_random()
{
return ei_random<float>(-ei_random_amplitude<float>(), ei_random_amplitude<float>());
}
inline bool ei_isMuchSmallerThan(float a, float b, float prec = precision<float>())
{
return ei_abs(a) <= ei_abs(b) * prec;
}
inline bool ei_isApprox(float a, float b, float prec = precision<float>())
{
return ei_abs(a - b) <= std::min(ei_abs(a), ei_abs(b)) * prec;
}
inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision<float>())
{
return a <= b || ei_isApprox(a, b, prec);
}
/**************
*** double ***
**************/
template<> inline double precision<double>() { return 1e-11; }
template<> inline double machine_epsilon<double>() { return 2.220e-16; }
inline double ei_real(double x) { return x; }
inline double ei_imag(double) { return 0.; }
inline double ei_conj(double x) { return x; }
inline double ei_abs(double x) { return std::abs(x); }
inline double ei_abs2(double x) { return x*x; }
inline double ei_sqrt(double x) { return std::sqrt(x); }
inline double ei_exp(double x) { return std::exp(x); }
inline double ei_log(double x) { return std::log(x); }
inline double ei_sin(double x) { return std::sin(x); }
inline double ei_cos(double x) { return std::cos(x); }
inline double ei_atan2(double y, double x) { return std::atan2(y,x); }
inline double ei_pow(double x, double y) { return std::pow(x, y); }
template<> inline double ei_random(double a, double b)
{
#ifdef EIGEN_NICE_RANDOM
int i;
do { i= ei_random<int>(256*int(a),256*int(b));
} while(i==0);
return i/256.;
#else
return a + (b-a) * std::rand() / RAND_MAX;
#endif
}
template<> inline double ei_random()
{
return ei_random<double>(-ei_random_amplitude<double>(), ei_random_amplitude<double>());
}
inline bool ei_isMuchSmallerThan(double a, double b, double prec = precision<double>())
{
return ei_abs(a) <= ei_abs(b) * prec;
}
inline bool ei_isApprox(double a, double b, double prec = precision<double>())
{
return ei_abs(a - b) <= std::min(ei_abs(a), ei_abs(b)) * prec;
}
inline bool ei_isApproxOrLessThan(double a, double b, double prec = precision<double>())
{
return a <= b || ei_isApprox(a, b, prec);
}
/*********************
*** complex<float> ***
*********************/
template<> inline float precision<std::complex<float> >() { return precision<float>(); }
template<> inline float machine_epsilon<std::complex<float> >() { return machine_epsilon<float>(); }
inline float ei_real(const std::complex<float>& x) { return std::real(x); }
inline float ei_imag(const std::complex<float>& x) { return std::imag(x); }
inline std::complex<float> ei_conj(const std::complex<float>& x) { return std::conj(x); }
inline float ei_abs(const std::complex<float>& x) { return std::abs(x); }
inline float ei_abs2(const std::complex<float>& x) { return std::norm(x); }
inline std::complex<float> ei_exp(std::complex<float> x) { return std::exp(x); }
inline std::complex<float> ei_sin(std::complex<float> x) { return std::sin(x); }
inline std::complex<float> ei_cos(std::complex<float> x) { return std::cos(x); }
inline std::complex<float> ei_atan2(std::complex<float>, std::complex<float> ) { ei_assert(false); return 0; }
template<> inline std::complex<float> ei_random()
{
return std::complex<float>(ei_random<float>(), ei_random<float>());
}
inline bool ei_isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>())
{
return ei_abs2(a) <= ei_abs2(b) * prec * prec;
}
inline bool ei_isMuchSmallerThan(const std::complex<float>& a, float b, float prec = precision<float>())
{
return ei_abs2(a) <= ei_abs2(b) * prec * prec;
}
inline bool ei_isApprox(const std::complex<float>& a, const std::complex<float>& b, float prec = precision<float>())
{
return ei_isApprox(ei_real(a), ei_real(b), prec)
&& ei_isApprox(ei_imag(a), ei_imag(b), prec);
}
// ei_isApproxOrLessThan wouldn't make sense for complex numbers
/**********************
*** complex<double> ***
**********************/
template<> inline double precision<std::complex<double> >() { return precision<double>(); }
template<> inline double machine_epsilon<std::complex<double> >() { return machine_epsilon<double>(); }
inline double ei_real(const std::complex<double>& x) { return std::real(x); }
inline double ei_imag(const std::complex<double>& x) { return std::imag(x); }
inline std::complex<double> ei_conj(const std::complex<double>& x) { return std::conj(x); }
inline double ei_abs(const std::complex<double>& x) { return std::abs(x); }
inline double ei_abs2(const std::complex<double>& x) { return std::norm(x); }
inline std::complex<double> ei_exp(std::complex<double> x) { return std::exp(x); }
inline std::complex<double> ei_sin(std::complex<double> x) { return std::sin(x); }
inline std::complex<double> ei_cos(std::complex<double> x) { return std::cos(x); }
inline std::complex<double> ei_atan2(std::complex<double>, std::complex<double>) { ei_assert(false); return 0; }
template<> inline std::complex<double> ei_random()
{
return std::complex<double>(ei_random<double>(), ei_random<double>());
}
inline bool ei_isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>())
{
return ei_abs2(a) <= ei_abs2(b) * prec * prec;
}
inline bool ei_isMuchSmallerThan(const std::complex<double>& a, double b, double prec = precision<double>())
{
return ei_abs2(a) <= ei_abs2(b) * prec * prec;
}
inline bool ei_isApprox(const std::complex<double>& a, const std::complex<double>& b, double prec = precision<double>())
{
return ei_isApprox(ei_real(a), ei_real(b), prec)
&& ei_isApprox(ei_imag(a), ei_imag(b), prec);
}
// ei_isApproxOrLessThan wouldn't make sense for complex numbers
/******************
*** long double ***
******************/
template<> inline long double precision<long double>() { return precision<double>(); }
template<> inline long double machine_epsilon<long double>() { return 1.084e-19l; }
inline long double ei_real(long double x) { return x; }
inline long double ei_imag(long double) { return 0.; }
inline long double ei_conj(long double x) { return x; }
inline long double ei_abs(long double x) { return std::abs(x); }
inline long double ei_abs2(long double x) { return x*x; }
inline long double ei_sqrt(long double x) { return std::sqrt(x); }
inline long double ei_exp(long double x) { return std::exp(x); }
inline long double ei_log(long double x) { return std::log(x); }
inline long double ei_sin(long double x) { return std::sin(x); }
inline long double ei_cos(long double x) { return std::cos(x); }
inline long double ei_atan2(long double y, long double x) { return std::atan2(y,x); }
inline long double ei_pow(long double x, long double y) { return std::pow(x, y); }
template<> inline long double ei_random(long double a, long double b)
{
return ei_random<double>(static_cast<double>(a),static_cast<double>(b));
}
template<> inline long double ei_random()
{
return ei_random<double>(-ei_random_amplitude<double>(), ei_random_amplitude<double>());
}
inline bool ei_isMuchSmallerThan(long double a, long double b, long double prec = precision<long double>())
{
return ei_abs(a) <= ei_abs(b) * prec;
}
inline bool ei_isApprox(long double a, long double b, long double prec = precision<long double>())
{
return ei_abs(a - b) <= std::min(ei_abs(a), ei_abs(b)) * prec;
}
inline bool ei_isApproxOrLessThan(long double a, long double b, long double prec = precision<long double>())
{
return a <= b || ei_isApprox(a, b, prec);
}
#endif // EIGEN_MATHFUNCTIONS_H

639
extern/Eigen2/Eigen/src/Core/Matrix.h vendored Normal file
View File

@@ -0,0 +1,639 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
/** \class Matrix
*
* \brief The matrix class, also used for vectors and row-vectors
*
* The %Matrix class is the work-horse for all \em dense (\ref dense "note") matrices and vectors within Eigen.
* Vectors are matrices with one column, and row-vectors are matrices with one row.
*
* The %Matrix class encompasses \em both fixed-size and dynamic-size objects (\ref fixedsize "note").
*
* The first three template parameters are required:
* \param _Scalar Numeric type, i.e. float, double, int
* \param _Rows Number of rows, or \b Dynamic
* \param _Cols Number of columns, or \b Dynamic
*
* The remaining template parameters are optional -- in most cases you don't have to worry about them.
* \param _Options A combination of either \b RowMajor or \b ColMajor, and of either
* \b AutoAlign or \b DontAlign.
* The former controls storage order, and defaults to column-major. The latter controls alignment, which is required
* for vectorization. It defaults to aligning matrices except for fixed sizes that aren't a multiple of the packet size.
* \param _MaxRows Maximum number of rows. Defaults to \a _Rows (\ref maxrows "note").
* \param _MaxCols Maximum number of columns. Defaults to \a _Cols (\ref maxrows "note").
*
* Eigen provides a number of typedefs covering the usual cases. Here are some examples:
*
* \li \c Matrix2d is a 2x2 square matrix of doubles (\c Matrix<double, 2, 2>)
* \li \c Vector4f is a vector of 4 floats (\c Matrix<float, 4, 1>)
* \li \c RowVector3i is a row-vector of 3 ints (\c Matrix<int, 1, 3>)
*
* \li \c MatrixXf is a dynamic-size matrix of floats (\c Matrix<float, Dynamic, Dynamic>)
* \li \c VectorXf is a dynamic-size vector of floats (\c Matrix<float, Dynamic, 1>)
*
* See \link matrixtypedefs this page \endlink for a complete list of predefined \em %Matrix and \em Vector typedefs.
*
* You can access elements of vectors and matrices using normal subscripting:
*
* \code
* Eigen::VectorXd v(10);
* v[0] = 0.1;
* v[1] = 0.2;
* v(0) = 0.3;
* v(1) = 0.4;
*
* Eigen::MatrixXi m(10, 10);
* m(0, 1) = 1;
* m(0, 2) = 2;
* m(0, 3) = 3;
* \endcode
*
* <i><b>Some notes:</b></i>
*
* <dl>
* <dt><b>\anchor dense Dense versus sparse:</b></dt>
* <dd>This %Matrix class handles dense, not sparse matrices and vectors. For sparse matrices and vectors, see the Sparse module.
*
* Dense matrices and vectors are plain usual arrays of coefficients. All the coefficients are stored, in an ordinary contiguous array.
* This is unlike Sparse matrices and vectors where the coefficients are stored as a list of nonzero coefficients.</dd>
*
* <dt><b>\anchor fixedsize Fixed-size versus dynamic-size:</b></dt>
* <dd>Fixed-size means that the numbers of rows and columns are known are compile-time. In this case, Eigen allocates the array
* of coefficients as a fixed-size array, as a class member. This makes sense for very small matrices, typically up to 4x4, sometimes up
* to 16x16. Larger matrices should be declared as dynamic-size even if one happens to know their size at compile-time.
*
* Dynamic-size means that the numbers of rows or columns are not necessarily known at compile-time. In this case they are runtime
* variables, and the array of coefficients is allocated dynamically on the heap.
*
* Note that \em dense matrices, be they Fixed-size or Dynamic-size, <em>do not</em> expand dynamically in the sense of a std::map.
* If you want this behavior, see the Sparse module.</dd>
*
* <dt><b>\anchor maxrows _MaxRows and _MaxCols:</b></dt>
* <dd>In most cases, one just leaves these parameters to the default values.
* These parameters mean the maximum size of rows and columns that the matrix may have. They are useful in cases
* when the exact numbers of rows and columns are not known are compile-time, but it is known at compile-time that they cannot
* exceed a certain value. This happens when taking dynamic-size blocks inside fixed-size matrices: in this case _MaxRows and _MaxCols
* are the dimensions of the original matrix, while _Rows and _Cols are Dynamic.</dd>
* </dl>
*
* \see MatrixBase for the majority of the API methods for matrices
*/
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
{
typedef _Scalar Scalar;
enum {
RowsAtCompileTime = _Rows,
ColsAtCompileTime = _Cols,
MaxRowsAtCompileTime = _MaxRows,
MaxColsAtCompileTime = _MaxCols,
Flags = ei_compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
CoeffReadCost = NumTraits<Scalar>::ReadCost
};
};
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
class Matrix
: public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
enum { Options = _Options };
friend class Eigen::Map<Matrix, Unaligned>;
typedef class Eigen::Map<Matrix, Unaligned> UnalignedMapType;
friend class Eigen::Map<Matrix, Aligned>;
typedef class Eigen::Map<Matrix, Aligned> AlignedMapType;
protected:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
public:
enum { NeedsToAlign = (Options&AutoAlign) == AutoAlign
&& SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 };
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Base& base() { return *static_cast<Base*>(this); }
const Base& base() const { return *static_cast<const Base*>(this); }
EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_storage.cols(); }
EIGEN_STRONG_INLINE int stride(void) const
{
if(Flags & RowMajorBit)
return m_storage.cols();
else
return m_storage.rows();
}
EIGEN_STRONG_INLINE const Scalar& coeff(int row, int col) const
{
if(Flags & RowMajorBit)
return m_storage.data()[col + row * m_storage.cols()];
else // column-major
return m_storage.data()[row + col * m_storage.rows()];
}
EIGEN_STRONG_INLINE const Scalar& coeff(int index) const
{
return m_storage.data()[index];
}
EIGEN_STRONG_INLINE Scalar& coeffRef(int row, int col)
{
if(Flags & RowMajorBit)
return m_storage.data()[col + row * m_storage.cols()];
else // column-major
return m_storage.data()[row + col * m_storage.rows()];
}
EIGEN_STRONG_INLINE Scalar& coeffRef(int index)
{
return m_storage.data()[index];
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
{
return ei_ploadt<Scalar, LoadMode>
(m_storage.data() + (Flags & RowMajorBit
? col + row * m_storage.cols()
: row + col * m_storage.rows()));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int index) const
{
return ei_ploadt<Scalar, LoadMode>(m_storage.data() + index);
}
template<int StoreMode>
EIGEN_STRONG_INLINE void writePacket(int row, int col, const PacketScalar& x)
{
ei_pstoret<Scalar, PacketScalar, StoreMode>
(m_storage.data() + (Flags & RowMajorBit
? col + row * m_storage.cols()
: row + col * m_storage.rows()), x);
}
template<int StoreMode>
EIGEN_STRONG_INLINE void writePacket(int index, const PacketScalar& x)
{
ei_pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x);
}
/** \returns a const pointer to the data array of this matrix */
EIGEN_STRONG_INLINE const Scalar *data() const
{ return m_storage.data(); }
/** \returns a pointer to the data array of this matrix */
EIGEN_STRONG_INLINE Scalar *data()
{ return m_storage.data(); }
/** Resizes \c *this to a \a rows x \a cols matrix.
*
* Makes sense for dynamic-size matrices only.
*
* If the current number of coefficients of \c *this exactly matches the
* product \a rows * \a cols, then no memory allocation is performed and
* the current values are left unchanged. In all other cases, including
* shrinking, the data is reallocated and all previous values are lost.
*
* \sa resize(int) for vectors.
*/
inline void resize(int rows, int cols)
{
ei_assert((MaxRowsAtCompileTime == Dynamic || MaxRowsAtCompileTime >= rows)
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
&& (MaxColsAtCompileTime == Dynamic || MaxColsAtCompileTime >= cols)
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
m_storage.resize(rows * cols, rows, cols);
}
/** Resizes \c *this to a vector of length \a size
*
* \sa resize(int,int) for the details.
*/
inline void resize(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
if(RowsAtCompileTime == 1)
m_storage.resize(size, 1, size);
else
m_storage.resize(size, size, 1);
}
/** Copies the value of the expression \a other into \c *this with automatic resizing.
*
* *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
* it will be initialized.
*
* Note that copying a row-vector into a vector (and conversely) is allowed.
* The resizing, if any, is then done in the appropriate way so that row-vectors
* remain row-vectors and vectors remain vectors.
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase<OtherDerived>& other)
{
return _set(other);
}
/** This is a special case of the templated operator=. Its purpose is to
* prevent a default operator= from hiding the templated operator=.
*/
EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
{
return _set(other);
}
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=)
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=)
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=)
/** Default constructor.
*
* For fixed-size matrices, does nothing.
*
* For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix
* is called a null matrix. This constructor is the unique way to create null matrices: resizing
* a matrix to 0 is not supported.
*
* \sa resize(int,int)
*/
EIGEN_STRONG_INLINE explicit Matrix() : m_storage()
{
_check_template_params();
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal */
Matrix(ei_constructor_without_unaligned_array_assert)
: m_storage(ei_constructor_without_unaligned_array_assert())
{}
#endif
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
*
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
* it is redundant to pass the dimension here, so it makes more sense to use the default
* constructor Matrix() instead.
*/
EIGEN_STRONG_INLINE explicit Matrix(int dim)
: m_storage(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
ei_assert(dim > 0);
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
}
/** This constructor has two very different behaviors, depending on the type of *this.
*
* \li When Matrix is a fixed-size vector type of size 2, this constructor constructs
* an initialized vector. The parameters \a x, \a y are copied into the first and second
* coords of the vector respectively.
* \li Otherwise, this constructor constructs an uninitialized matrix with \a x rows and
* \a y columns. This is useful for dynamic-size matrices. For fixed-size matrices,
* it is redundant to pass these parameters, so one should use the default constructor
* Matrix() instead.
*/
EIGEN_STRONG_INLINE Matrix(int x, int y) : m_storage(x*y, x, y)
{
_check_template_params();
if((RowsAtCompileTime == 1 && ColsAtCompileTime == 2)
|| (RowsAtCompileTime == 2 && ColsAtCompileTime == 1))
{
m_storage.data()[0] = Scalar(x);
m_storage.data()[1] = Scalar(y);
}
else
{
ei_assert(x > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x)
&& y > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == y));
}
}
/** constructs an initialized 2D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const float& x, const float& y)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 2)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
}
/** constructs an initialized 2D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const double& x, const double& y)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 2)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
}
/** constructs an initialized 3D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
m_storage.data()[2] = z;
}
/** constructs an initialized 4D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
{
_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
m_storage.data()[2] = z;
m_storage.data()[3] = w;
}
explicit Matrix(const Scalar *data);
/** Constructor copying the value of the expression \a other */
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
: m_storage(other.rows() * other.cols(), other.rows(), other.cols())
{
_check_template_params();
_set_noalias(other);
}
/** Copy constructor */
EIGEN_STRONG_INLINE Matrix(const Matrix& other)
: Base(), m_storage(other.rows() * other.cols(), other.rows(), other.cols())
{
_check_template_params();
_set_noalias(other);
}
/** Destructor */
inline ~Matrix() {}
/** Override MatrixBase::swap() since for dynamic-sized matrices of same type it is enough to swap the
* data pointers.
*/
template<typename OtherDerived>
void swap(const MatrixBase<OtherDerived>& other);
/** \name Map
* These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects,
* while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned
* \a data pointers.
*
* \see class Map
*/
//@{
inline static const UnalignedMapType Map(const Scalar* data)
{ return UnalignedMapType(data); }
inline static UnalignedMapType Map(Scalar* data)
{ return UnalignedMapType(data); }
inline static const UnalignedMapType Map(const Scalar* data, int size)
{ return UnalignedMapType(data, size); }
inline static UnalignedMapType Map(Scalar* data, int size)
{ return UnalignedMapType(data, size); }
inline static const UnalignedMapType Map(const Scalar* data, int rows, int cols)
{ return UnalignedMapType(data, rows, cols); }
inline static UnalignedMapType Map(Scalar* data, int rows, int cols)
{ return UnalignedMapType(data, rows, cols); }
inline static const AlignedMapType MapAligned(const Scalar* data)
{ return AlignedMapType(data); }
inline static AlignedMapType MapAligned(Scalar* data)
{ return AlignedMapType(data); }
inline static const AlignedMapType MapAligned(const Scalar* data, int size)
{ return AlignedMapType(data, size); }
inline static AlignedMapType MapAligned(Scalar* data, int size)
{ return AlignedMapType(data, size); }
inline static const AlignedMapType MapAligned(const Scalar* data, int rows, int cols)
{ return AlignedMapType(data, rows, cols); }
inline static AlignedMapType MapAligned(Scalar* data, int rows, int cols)
{ return AlignedMapType(data, rows, cols); }
//@}
using Base::setConstant;
Matrix& setConstant(int size, const Scalar& value);
Matrix& setConstant(int rows, int cols, const Scalar& value);
using Base::setZero;
Matrix& setZero(int size);
Matrix& setZero(int rows, int cols);
using Base::setOnes;
Matrix& setOnes(int size);
Matrix& setOnes(int rows, int cols);
using Base::setRandom;
Matrix& setRandom(int size);
Matrix& setRandom(int rows, int cols);
using Base::setIdentity;
Matrix& setIdentity(int rows, int cols);
/////////// Geometry module ///////////
template<typename OtherDerived>
explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
template<typename OtherDerived>
Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
// allow to extend Matrix outside Eigen
#ifdef EIGEN_MATRIX_PLUGIN
#include EIGEN_MATRIX_PLUGIN
#endif
private:
/** \internal Resizes *this in preparation for assigning \a other to it.
* Takes care of doing all the checking that's needed.
*
* Note that copying a row-vector into a vector (and conversely) is allowed.
* The resizing, if any, is then done in the appropriate way so that row-vectors
* remain row-vectors and vectors remain vectors.
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE void _resize_to_match(const MatrixBase<OtherDerived>& other)
{
if(RowsAtCompileTime == 1)
{
ei_assert(other.isVector());
resize(1, other.size());
}
else if(ColsAtCompileTime == 1)
{
ei_assert(other.isVector());
resize(other.size(), 1);
}
else resize(other.rows(), other.cols());
}
/** \internal Copies the value of the expression \a other into \c *this with automatic resizing.
*
* *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
* it will be initialized.
*
* Note that copying a row-vector into a vector (and conversely) is allowed.
* The resizing, if any, is then done in the appropriate way so that row-vectors
* remain row-vectors and vectors remain vectors.
*
* \sa operator=(const MatrixBase<OtherDerived>&), _set_noalias()
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix& _set(const MatrixBase<OtherDerived>& other)
{
// this enum introduced to fix compilation with gcc 3.3
enum { cond = int(OtherDerived::Flags) & EvalBeforeAssigningBit };
_set_selector(other.derived(), typename ei_meta_if<bool(cond), ei_meta_true, ei_meta_false>::ret());
return *this;
}
template<typename OtherDerived>
EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_true&) { _set_noalias(other.eval()); }
template<typename OtherDerived>
EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_false&) { _set_noalias(other); }
/** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which
* is the case when creating a new matrix) so one can enforce lazy evaluation.
*
* \sa operator=(const MatrixBase<OtherDerived>&), _set()
*/
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix& _set_noalias(const MatrixBase<OtherDerived>& other)
{
_resize_to_match(other);
// the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
// it wouldn't allow to copy a row-vector into a column-vector.
return ei_assign_selector<Matrix,OtherDerived,false>::run(*this, other.derived());
}
static EIGEN_STRONG_INLINE void _check_template_params()
{
EIGEN_STATIC_ASSERT((_Rows > 0
&& _Cols > 0
&& _MaxRows <= _Rows
&& _MaxCols <= _Cols
&& (_Options & (AutoAlign|RowMajor)) == _Options),
INVALID_MATRIX_TEMPLATE_PARAMETERS)
}
template<typename MatrixType, typename OtherDerived, bool IsSameType, bool IsDynamicSize>
friend struct ei_matrix_swap_impl;
};
template<typename MatrixType, typename OtherDerived,
bool IsSameType = ei_is_same_type<MatrixType, OtherDerived>::ret,
bool IsDynamicSize = MatrixType::SizeAtCompileTime==Dynamic>
struct ei_matrix_swap_impl
{
static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
{
matrix.base().swap(other);
}
};
template<typename MatrixType, typename OtherDerived>
struct ei_matrix_swap_impl<MatrixType, OtherDerived, true, true>
{
static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
{
matrix.m_storage.swap(other.derived().m_storage);
}
};
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(const MatrixBase<OtherDerived>& other)
{
ei_matrix_swap_impl<Matrix, OtherDerived>::run(*this, *const_cast<MatrixBase<OtherDerived>*>(&other));
}
/** \defgroup matrixtypedefs Global matrix typedefs
*
* \ingroup Core_Module
*
* Eigen defines several typedef shortcuts for most common matrix and vector types.
*
* The general patterns are the following:
*
* \c MatrixSizeType where \c Size can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for dynamic size,
* and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c cd
* for complex double.
*
* For example, \c Matrix3d is a fixed-size 3x3 matrix type of doubles, and \c MatrixXf is a dynamic-size matrix of floats.
*
* There are also \c VectorSizeType and \c RowVectorSizeType which are self-explanatory. For example, \c Vector4cf is
* a fixed-size vector of 4 complex floats.
*
* \sa class Matrix
*/
#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
/** \ingroup matrixtypedefs */ \
typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
/** \ingroup matrixtypedefs */ \
typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
/** \ingroup matrixtypedefs */ \
typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
#undef EIGEN_MAKE_TYPEDEFS
#undef EIGEN_MAKE_TYPEDEFS_LARGE
#define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
using Eigen::Matrix##SizeSuffix##TypeSuffix; \
using Eigen::Vector##SizeSuffix##TypeSuffix; \
using Eigen::RowVector##SizeSuffix##TypeSuffix;
#define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
#define EIGEN_USING_MATRIX_TYPEDEFS \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \
EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd)
#endif // EIGEN_MATRIX_H

View File

@@ -0,0 +1,632 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MATRIXBASE_H
#define EIGEN_MATRIXBASE_H
/** \class MatrixBase
*
* \brief Base class for all matrices, vectors, and expressions
*
* This class is the base that is inherited by all matrix, vector, and expression
* types. Most of the Eigen API is contained in this class. Other important classes for
* the Eigen API are Matrix, Cwise, and PartialRedux.
*
* Note that some methods are defined in the \ref Array module.
*
* \param Derived is the derived type, e.g. a matrix type, or an expression, etc.
*
* When writing a function taking Eigen objects as argument, if you want your function
* to take as argument any matrix, vector, or expression, just let it take a
* MatrixBase argument. As an example, here is a function printFirstRow which, given
* a matrix, vector, or expression \a x, prints the first row of \a x.
*
* \code
template<typename Derived>
void printFirstRow(const Eigen::MatrixBase<Derived>& x)
{
cout << x.row(0) << endl;
}
* \endcode
*
*/
template<typename Derived> class MatrixBase
{
public:
#ifndef EIGEN_PARSED_BY_DOXYGEN
class InnerIterator;
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
#endif // not EIGEN_PARSED_BY_DOXYGEN
enum {
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
/**< The number of rows at compile-time. This is just a copy of the value provided
* by the \a Derived type. If a value is not known at compile-time,
* it is set to the \a Dynamic constant.
* \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
/**< The number of columns at compile-time. This is just a copy of the value provided
* by the \a Derived type. If a value is not known at compile-time,
* it is set to the \a Dynamic constant.
* \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime,
ei_traits<Derived>::ColsAtCompileTime>::ret),
/**< This is equal to the number of coefficients, i.e. the number of
* rows times the number of columns, or to \a Dynamic if this is not
* known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime,
/**< This value is equal to the maximum possible number of rows that this expression
* might have. If this expression might have an arbitrarily high number of rows,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
*/
MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime,
/**< This value is equal to the maximum possible number of columns that this expression
* might have. If this expression might have an arbitrarily high number of columns,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
*/
MaxSizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::MaxRowsAtCompileTime,
ei_traits<Derived>::MaxColsAtCompileTime>::ret),
/**< This value is equal to the maximum possible number of coefficients that this expression
* might have. If this expression might have an arbitrarily high number of coefficients,
* this value is set to \a Dynamic.
*
* This value is useful to know when evaluating an expression, in order to determine
* whether it is possible to avoid doing a dynamic memory allocation.
*
* \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
*/
IsVectorAtCompileTime = ei_traits<Derived>::RowsAtCompileTime == 1
|| ei_traits<Derived>::ColsAtCompileTime == 1,
/**< This is set to true if either the number of rows or the number of
* columns is known at compile-time to be equal to 1. Indeed, in that case,
* we are dealing with a column-vector (if there is only one column) or with
* a row-vector (if there is only one row). */
Flags = ei_traits<Derived>::Flags,
/**< This stores expression \ref flags flags which may or may not be inherited by new expressions
* constructed from this one. See the \ref flags "list of flags".
*/
CoeffReadCost = ei_traits<Derived>::CoeffReadCost
/**< This is a rough measure of how expensive it is to read one coefficient from
* this expression.
*/
};
/** Default constructor. Just checks at compile-time for self-consistency of the flags. */
MatrixBase()
{
ei_assert(ei_are_flags_consistent<Flags>::ret);
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** This is the "real scalar" type; if the \a Scalar type is already real numbers
* (e.g. int, float or double) then \a RealScalar is just the same as \a Scalar. If
* \a Scalar is \a std::complex<T> then RealScalar is \a T.
*
* \sa class NumTraits
*/
typedef typename NumTraits<Scalar>::Real RealScalar;
/** type of the equivalent square matrix */
typedef Matrix<Scalar,EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime),
EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
inline int cols() const { return derived().cols(); }
/** \returns the number of coefficients, which is \a rows()*cols().
* \sa rows(), cols(), SizeAtCompileTime. */
inline int size() const { return rows() * cols(); }
/** \returns the number of nonzero coefficients which is in practice the number
* of stored coefficients. */
inline int nonZeros() const { return derived.nonZeros(); }
/** \returns true if either the number of rows or the number of columns is equal to 1.
* In other words, this function returns
* \code rows()==1 || cols()==1 \endcode
* \sa rows(), cols(), IsVectorAtCompileTime. */
inline bool isVector() const { return rows()==1 || cols()==1; }
/** \returns the size of the storage major dimension,
* i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
int outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
/** \returns the size of the inner dimension according to the storage order,
* i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal the plain matrix type corresponding to this expression. Note that is not necessarily
* exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
* reference to a matrix, not a matrix! It guaranteed however, that the return type of eval() is either
* PlainMatrixType or const PlainMatrixType&.
*/
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
/** \internal the column-major plain matrix type corresponding to this expression. Note that is not necessarily
* exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
* reference to a matrix, not a matrix!
* The only difference from PlainMatrixType is that PlainMatrixType_ColMajor is guaranteed to be column-major.
*/
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType_ColMajor;
/** \internal Represents a matrix with all coefficients equal to one another*/
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
/** \internal Represents a scalar multiple of a matrix */
typedef CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived> ScalarMultipleReturnType;
/** \internal Represents a quotient of a matrix by a scalar*/
typedef CwiseUnaryOp<ei_scalar_quotient1_op<Scalar>, Derived> ScalarQuotient1ReturnType;
/** \internal the return type of MatrixBase::conjugate() */
typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
const CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Derived>,
const Derived&
>::ret ConjugateReturnType;
/** \internal the return type of MatrixBase::real() */
typedef CwiseUnaryOp<ei_scalar_real_op<Scalar>, Derived> RealReturnType;
/** \internal the return type of MatrixBase::imag() */
typedef CwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
/** \internal the return type of MatrixBase::adjoint() */
typedef Eigen::Transpose<NestByValue<typename ei_cleantype<ConjugateReturnType>::type> >
AdjointReturnType;
/** \internal the return type of MatrixBase::eigenvalues() */
typedef Matrix<typename NumTraits<typename ei_traits<Derived>::Scalar>::Real, ei_traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
/** \internal expression tyepe of a column */
typedef Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1> ColXpr;
/** \internal expression tyepe of a column */
typedef Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime> RowXpr;
/** \internal the return type of identity */
typedef CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> IdentityReturnType;
/** \internal the return type of unit vectors */
typedef Block<CwiseNullaryOp<ei_scalar_identity_op<Scalar>, SquareMatrixType>,
ei_traits<Derived>::RowsAtCompileTime,
ei_traits<Derived>::ColsAtCompileTime> BasisReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
/** Copies \a other into *this. \returns a reference to *this. */
template<typename OtherDerived>
Derived& operator=(const MatrixBase<OtherDerived>& other);
/** Special case of the template operator=, in order to prevent the compiler
* from generating a default operator= (issue hit with g++ 4.1)
*/
inline Derived& operator=(const MatrixBase& other)
{
return this->operator=<Derived>(other);
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** Copies \a other into *this without evaluating other. \returns a reference to *this. */
template<typename OtherDerived>
Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
/** Overloaded for cache friendly product evaluation */
template<typename Lhs, typename Rhs>
Derived& lazyAssign(const Product<Lhs,Rhs,CacheFriendlyProduct>& product);
/** Overloaded for cache friendly product evaluation */
template<typename OtherDerived>
Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
{ return lazyAssign(other._expression()); }
#endif // not EIGEN_PARSED_BY_DOXYGEN
CommaInitializer<Derived> operator<< (const Scalar& s);
template<typename OtherDerived>
CommaInitializer<Derived> operator<< (const MatrixBase<OtherDerived>& other);
const Scalar coeff(int row, int col) const;
const Scalar operator()(int row, int col) const;
Scalar& coeffRef(int row, int col);
Scalar& operator()(int row, int col);
const Scalar coeff(int index) const;
const Scalar operator[](int index) const;
const Scalar operator()(int index) const;
Scalar& coeffRef(int index);
Scalar& operator[](int index);
Scalar& operator()(int index);
#ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename OtherDerived>
void copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other);
template<typename OtherDerived>
void copyCoeff(int index, const MatrixBase<OtherDerived>& other);
template<typename OtherDerived, int StoreMode, int LoadMode>
void copyPacket(int row, int col, const MatrixBase<OtherDerived>& other);
template<typename OtherDerived, int StoreMode, int LoadMode>
void copyPacket(int index, const MatrixBase<OtherDerived>& other);
#endif // not EIGEN_PARSED_BY_DOXYGEN
template<int LoadMode>
PacketScalar packet(int row, int col) const;
template<int StoreMode>
void writePacket(int row, int col, const PacketScalar& x);
template<int LoadMode>
PacketScalar packet(int index) const;
template<int StoreMode>
void writePacket(int index, const PacketScalar& x);
const Scalar x() const;
const Scalar y() const;
const Scalar z() const;
const Scalar w() const;
Scalar& x();
Scalar& y();
Scalar& z();
Scalar& w();
const CwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived> operator-() const;
template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator+(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
operator-(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other);
template<typename OtherDerived>
Derived& operator-=(const MatrixBase<OtherDerived>& other);
template<typename Lhs,typename Rhs>
Derived& operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other);
Derived& operator*=(const Scalar& other);
Derived& operator/=(const Scalar& other);
const ScalarMultipleReturnType operator*(const Scalar& scalar) const;
const CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, Derived>
operator/(const Scalar& scalar) const;
inline friend const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived>
operator*(const Scalar& scalar, const MatrixBase& matrix)
{ return matrix*scalar; }
template<typename OtherDerived>
const typename ProductReturnType<Derived,OtherDerived>::Type
operator*(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
Derived& operator*=(const MatrixBase<OtherDerived>& other);
template<typename OtherDerived>
typename ei_plain_matrix_type_column_major<OtherDerived>::type
solveTriangular(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived>
void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
template<typename OtherDerived>
Scalar dot(const MatrixBase<OtherDerived>& other) const;
RealScalar squaredNorm() const;
RealScalar norm() const;
const PlainMatrixType normalized() const;
void normalize();
Eigen::Transpose<Derived> transpose();
const Eigen::Transpose<Derived> transpose() const;
void transposeInPlace();
const AdjointReturnType adjoint() const;
RowXpr row(int i);
const RowXpr row(int i) const;
ColXpr col(int i);
const ColXpr col(int i) const;
Minor<Derived> minor(int row, int col);
const Minor<Derived> minor(int row, int col) const;
typename BlockReturnType<Derived>::Type block(int startRow, int startCol, int blockRows, int blockCols);
const typename BlockReturnType<Derived>::Type
block(int startRow, int startCol, int blockRows, int blockCols) const;
typename BlockReturnType<Derived>::SubVectorType segment(int start, int size);
const typename BlockReturnType<Derived>::SubVectorType segment(int start, int size) const;
typename BlockReturnType<Derived,Dynamic>::SubVectorType start(int size);
const typename BlockReturnType<Derived,Dynamic>::SubVectorType start(int size) const;
typename BlockReturnType<Derived,Dynamic>::SubVectorType end(int size);
const typename BlockReturnType<Derived,Dynamic>::SubVectorType end(int size) const;
typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols);
const typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols) const;
template<int BlockRows, int BlockCols>
typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol);
template<int BlockRows, int BlockCols>
const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol) const;
template<int CRows, int CCols>
typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type);
template<int CRows, int CCols>
const typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type) const;
template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType start(void);
template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType start() const;
template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType end();
template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType end() const;
template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType segment(int start);
template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType segment(int start) const;
DiagonalCoeffs<Derived> diagonal();
const DiagonalCoeffs<Derived> diagonal() const;
template<unsigned int Mode> Part<Derived, Mode> part();
template<unsigned int Mode> const Part<Derived, Mode> part() const;
static const ConstantReturnType
Constant(int rows, int cols, const Scalar& value);
static const ConstantReturnType
Constant(int size, const Scalar& value);
static const ConstantReturnType
Constant(const Scalar& value);
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
NullaryExpr(int rows, int cols, const CustomNullaryOp& func);
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
NullaryExpr(int size, const CustomNullaryOp& func);
template<typename CustomNullaryOp>
static const CwiseNullaryOp<CustomNullaryOp, Derived>
NullaryExpr(const CustomNullaryOp& func);
static const ConstantReturnType Zero(int rows, int cols);
static const ConstantReturnType Zero(int size);
static const ConstantReturnType Zero();
static const ConstantReturnType Ones(int rows, int cols);
static const ConstantReturnType Ones(int size);
static const ConstantReturnType Ones();
static const IdentityReturnType Identity();
static const IdentityReturnType Identity(int rows, int cols);
static const BasisReturnType Unit(int size, int i);
static const BasisReturnType Unit(int i);
static const BasisReturnType UnitX();
static const BasisReturnType UnitY();
static const BasisReturnType UnitZ();
static const BasisReturnType UnitW();
const DiagonalMatrix<Derived> asDiagonal() const;
void fill(const Scalar& value);
Derived& setConstant(const Scalar& value);
Derived& setZero();
Derived& setOnes();
Derived& setRandom();
Derived& setIdentity();
template<typename OtherDerived>
bool isApprox(const MatrixBase<OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const;
bool isMuchSmallerThan(const RealScalar& other,
RealScalar prec = precision<Scalar>()) const;
template<typename OtherDerived>
bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const;
bool isApproxToConstant(const Scalar& value, RealScalar prec = precision<Scalar>()) const;
bool isConstant(const Scalar& value, RealScalar prec = precision<Scalar>()) const;
bool isZero(RealScalar prec = precision<Scalar>()) const;
bool isOnes(RealScalar prec = precision<Scalar>()) const;
bool isIdentity(RealScalar prec = precision<Scalar>()) const;
bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
bool isUpperTriangular(RealScalar prec = precision<Scalar>()) const;
bool isLowerTriangular(RealScalar prec = precision<Scalar>()) const;
template<typename OtherDerived>
bool isOrthogonal(const MatrixBase<OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const;
bool isUnitary(RealScalar prec = precision<Scalar>()) const;
template<typename OtherDerived>
inline bool operator==(const MatrixBase<OtherDerived>& other) const
{ return (cwise() == other).all(); }
template<typename OtherDerived>
inline bool operator!=(const MatrixBase<OtherDerived>& other) const
{ return (cwise() != other).any(); }
template<typename NewType>
const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived> cast() const;
/** \returns the matrix or vector obtained by evaluating this expression.
*
* Notice that in the case of a plain matrix or vector (not an expression) this function just returns
* a const reference, in order to avoid a useless copy.
*/
EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const
{ return typename ei_eval<Derived>::type(derived()); }
template<typename OtherDerived>
void swap(const MatrixBase<OtherDerived>& other);
template<unsigned int Added>
const Flagged<Derived, Added, 0> marked() const;
const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit> lazy() const;
/** \returns number of elements to skip to pass from one row (resp. column) to another
* for a row-major (resp. column-major) matrix.
* Combined with coeffRef() and the \ref flags flags, it allows a direct access to the data
* of the underlying matrix.
*/
inline int stride(void) const { return derived().stride(); }
inline const NestByValue<Derived> nestByValue() const;
ConjugateReturnType conjugate() const;
const RealReturnType real() const;
const ImagReturnType imag() const;
template<typename CustomUnaryOp>
const CwiseUnaryOp<CustomUnaryOp, Derived> unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const;
template<typename CustomBinaryOp, typename OtherDerived>
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
Scalar sum() const;
Scalar trace() const;
typename ei_traits<Derived>::Scalar minCoeff() const;
typename ei_traits<Derived>::Scalar maxCoeff() const;
typename ei_traits<Derived>::Scalar minCoeff(int* row, int* col) const;
typename ei_traits<Derived>::Scalar maxCoeff(int* row, int* col) const;
typename ei_traits<Derived>::Scalar minCoeff(int* index) const;
typename ei_traits<Derived>::Scalar maxCoeff(int* index) const;
template<typename BinaryOp>
typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
redux(const BinaryOp& func) const;
template<typename Visitor>
void visit(Visitor& func) const;
#ifndef EIGEN_PARSED_BY_DOXYGEN
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
inline Derived& derived() { return *static_cast<Derived*>(this); }
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<MatrixBase*>(this)); }
#endif // not EIGEN_PARSED_BY_DOXYGEN
const Cwise<Derived> cwise() const;
Cwise<Derived> cwise();
inline const WithFormat<Derived> format(const IOFormat& fmt) const;
/////////// Array module ///////////
bool all(void) const;
bool any(void) const;
int count() const;
const PartialRedux<Derived,Horizontal> rowwise() const;
const PartialRedux<Derived,Vertical> colwise() const;
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int rows, int cols);
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int size);
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random();
template<typename ThenDerived,typename ElseDerived>
const Select<Derived,ThenDerived,ElseDerived>
select(const MatrixBase<ThenDerived>& thenMatrix,
const MatrixBase<ElseDerived>& elseMatrix) const;
template<typename ThenDerived>
inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
select(const MatrixBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
template<typename ElseDerived>
inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
select(typename ElseDerived::Scalar thenScalar, const MatrixBase<ElseDerived>& elseMatrix) const;
template<int p> RealScalar lpNorm() const;
/////////// LU module ///////////
const LU<PlainMatrixType> lu() const;
const PlainMatrixType inverse() const;
void computeInverse(PlainMatrixType *result) const;
Scalar determinant() const;
/////////// Cholesky module ///////////
const LLT<PlainMatrixType> llt() const;
const LDLT<PlainMatrixType> ldlt() const;
/////////// QR module ///////////
const QR<PlainMatrixType> qr() const;
EigenvaluesReturnType eigenvalues() const;
RealScalar operatorNorm() const;
/////////// SVD module ///////////
SVD<PlainMatrixType> svd() const;
/////////// Geometry module ///////////
template<typename OtherDerived>
PlainMatrixType cross(const MatrixBase<OtherDerived>& other) const;
PlainMatrixType unitOrthogonal(void) const;
Matrix<Scalar,3,1> eulerAngles(int a0, int a1, int a2) const;
/////////// Sparse module ///////////
// dense = spasre * dense
template<typename Derived1, typename Derived2>
Derived& lazyAssign(const SparseProduct<Derived1,Derived2,SparseTimeDenseProduct>& product);
// dense = dense * spasre
template<typename Derived1, typename Derived2>
Derived& lazyAssign(const SparseProduct<Derived1,Derived2,DenseTimeSparseProduct>& product);
#ifdef EIGEN_MATRIXBASE_PLUGIN
#include EIGEN_MATRIXBASE_PLUGIN
#endif
};
#endif // EIGEN_MATRIXBASE_H

View File

@@ -0,0 +1,249 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MATRIXSTORAGE_H
#define EIGEN_MATRIXSTORAGE_H
struct ei_constructor_without_unaligned_array_assert {};
/** \internal
* Static array automatically aligned if the total byte size is a multiple of 16 and the matrix options require auto alignment
*/
template <typename T, int Size, int MatrixOptions,
bool Align = (MatrixOptions&AutoAlign) && (((Size*sizeof(T))&0xf)==0)
> struct ei_matrix_array
{
EIGEN_ALIGN_128 T array[Size];
ei_matrix_array()
{
#ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
ei_assert((reinterpret_cast<size_t>(array) & 0xf) == 0
&& "this assertion is explained here: http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html **** READ THIS WEB PAGE !!! ****");
#endif
}
ei_matrix_array(ei_constructor_without_unaligned_array_assert) {}
};
template <typename T, int Size, int MatrixOptions> struct ei_matrix_array<T,Size,MatrixOptions,false>
{
T array[Size];
ei_matrix_array() {}
ei_matrix_array(ei_constructor_without_unaligned_array_assert) {}
};
/** \internal
*
* \class ei_matrix_storage
*
* \brief Stores the data of a matrix
*
* This class stores the data of fixed-size, dynamic-size or mixed matrices
* in a way as compact as possible.
*
* \sa Matrix
*/
template<typename T, int Size, int _Rows, int _Cols, int _Options> class ei_matrix_storage;
// purely fixed-size matrix
template<typename T, int Size, int _Rows, int _Cols, int _Options> class ei_matrix_storage
{
ei_matrix_array<T,Size,_Options> m_data;
public:
inline explicit ei_matrix_storage() {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert)
: m_data(ei_constructor_without_unaligned_array_assert()) {}
inline ei_matrix_storage(int,int,int) {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); }
inline static int rows(void) {return _Rows;}
inline static int cols(void) {return _Cols;}
inline void resize(int,int,int) {}
inline const T *data() const { return m_data.array; }
inline T *data() { return m_data.array; }
};
// dynamic-size matrix with fixed-size storage
template<typename T, int Size, int _Options> class ei_matrix_storage<T, Size, Dynamic, Dynamic, _Options>
{
ei_matrix_array<T,Size,_Options> m_data;
int m_rows;
int m_cols;
public:
inline explicit ei_matrix_storage() : m_rows(0), m_cols(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert)
: m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
inline ei_matrix_storage(int, int rows, int cols) : m_rows(rows), m_cols(cols) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
inline int rows(void) const {return m_rows;}
inline int cols(void) const {return m_cols;}
inline void resize(int, int rows, int cols)
{
m_rows = rows;
m_cols = cols;
}
inline const T *data() const { return m_data.array; }
inline T *data() { return m_data.array; }
};
// dynamic-size matrix with fixed-size storage and fixed width
template<typename T, int Size, int _Cols, int _Options> class ei_matrix_storage<T, Size, Dynamic, _Cols, _Options>
{
ei_matrix_array<T,Size,_Options> m_data;
int m_rows;
public:
inline explicit ei_matrix_storage() : m_rows(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert)
: m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0) {}
inline ei_matrix_storage(int, int rows, int) : m_rows(rows) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
inline int rows(void) const {return m_rows;}
inline int cols(void) const {return _Cols;}
inline void resize(int /*size*/, int rows, int)
{
m_rows = rows;
}
inline const T *data() const { return m_data.array; }
inline T *data() { return m_data.array; }
};
// dynamic-size matrix with fixed-size storage and fixed height
template<typename T, int Size, int _Rows, int _Options> class ei_matrix_storage<T, Size, _Rows, Dynamic, _Options>
{
ei_matrix_array<T,Size,_Options> m_data;
int m_cols;
public:
inline explicit ei_matrix_storage() : m_cols(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert)
: m_data(ei_constructor_without_unaligned_array_assert()), m_cols(0) {}
inline ei_matrix_storage(int, int, int cols) : m_cols(cols) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
inline int rows(void) const {return _Rows;}
inline int cols(void) const {return m_cols;}
inline void resize(int, int, int cols)
{
m_cols = cols;
}
inline const T *data() const { return m_data.array; }
inline T *data() { return m_data.array; }
};
// purely dynamic matrix.
template<typename T, int _Options> class ei_matrix_storage<T, Dynamic, Dynamic, Dynamic, _Options>
{
T *m_data;
int m_rows;
int m_cols;
public:
inline explicit ei_matrix_storage() : m_data(0), m_rows(0), m_cols(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert)
: m_data(0), m_rows(0), m_cols(0) {}
inline ei_matrix_storage(int size, int rows, int cols)
: m_data(ei_aligned_new<T>(size)), m_rows(rows), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, m_rows*m_cols); }
inline void swap(ei_matrix_storage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
inline int rows(void) const {return m_rows;}
inline int cols(void) const {return m_cols;}
void resize(int size, int rows, int cols)
{
if(size != m_rows*m_cols)
{
ei_aligned_delete(m_data, m_rows*m_cols);
if (size)
m_data = ei_aligned_new<T>(size);
else
m_data = 0;
}
m_rows = rows;
m_cols = cols;
}
inline const T *data() const { return m_data; }
inline T *data() { return m_data; }
};
// matrix with dynamic width and fixed height (so that matrix has dynamic size).
template<typename T, int _Rows, int _Options> class ei_matrix_storage<T, Dynamic, _Rows, Dynamic, _Options>
{
T *m_data;
int m_cols;
public:
inline explicit ei_matrix_storage() : m_data(0), m_cols(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
inline ei_matrix_storage(int size, int, int cols) : m_data(ei_aligned_new<T>(size)), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Rows*m_cols); }
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
inline static int rows(void) {return _Rows;}
inline int cols(void) const {return m_cols;}
void resize(int size, int, int cols)
{
if(size != _Rows*m_cols)
{
ei_aligned_delete(m_data, _Rows*m_cols);
if (size)
m_data = ei_aligned_new<T>(size);
else
m_data = 0;
}
m_cols = cols;
}
inline const T *data() const { return m_data; }
inline T *data() { return m_data; }
};
// matrix with dynamic height and fixed width (so that matrix has dynamic size).
template<typename T, int _Cols, int _Options> class ei_matrix_storage<T, Dynamic, Dynamic, _Cols, _Options>
{
T *m_data;
int m_rows;
public:
inline explicit ei_matrix_storage() : m_data(0), m_rows(0) {}
inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
inline ei_matrix_storage(int size, int rows, int) : m_data(ei_aligned_new<T>(size)), m_rows(rows) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Cols*m_rows); }
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
inline int rows(void) const {return m_rows;}
inline static int cols(void) {return _Cols;}
void resize(int size, int rows, int)
{
if(size != m_rows*_Cols)
{
ei_aligned_delete(m_data, _Cols*m_rows);
if (size)
m_data = ei_aligned_new<T>(size);
else
m_data = 0;
}
m_rows = rows;
}
inline const T *data() const { return m_data; }
inline T *data() { return m_data; }
};
#endif // EIGEN_MATRIX_H

122
extern/Eigen2/Eigen/src/Core/Minor.h vendored Normal file
View File

@@ -0,0 +1,122 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MINOR_H
#define EIGEN_MINOR_H
/** \nonstableyet
* \class Minor
*
* \brief Expression of a minor
*
* \param MatrixType the type of the object in which we are taking a minor
*
* This class represents an expression of a minor. It is the return
* type of MatrixBase::minor() and most of the time this is the only way it
* is used.
*
* \sa MatrixBase::minor()
*/
template<typename MatrixType>
struct ei_traits<Minor<MatrixType> >
{
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
Flags = _MatrixTypeNested::Flags & HereditaryBits,
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
};
};
template<typename MatrixType> class Minor
: public MatrixBase<Minor<MatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Minor)
inline Minor(const MatrixType& matrix,
int row, int col)
: m_matrix(matrix), m_row(row), m_col(col)
{
ei_assert(row >= 0 && row < matrix.rows()
&& col >= 0 && col < matrix.cols());
}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
inline int rows() const { return m_matrix.rows() - 1; }
inline int cols() const { return m_matrix.cols() - 1; }
inline Scalar& coeffRef(int row, int col)
{
return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
}
inline const Scalar coeff(int row, int col) const
{
return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
}
protected:
const typename MatrixType::Nested m_matrix;
const int m_row, m_col;
};
/** \nonstableyet
* \return an expression of the (\a row, \a col)-minor of *this,
* i.e. an expression constructed from *this by removing the specified
* row and column.
*
* Example: \include MatrixBase_minor.cpp
* Output: \verbinclude MatrixBase_minor.out
*
* \sa class Minor
*/
template<typename Derived>
inline Minor<Derived>
MatrixBase<Derived>::minor(int row, int col)
{
return Minor<Derived>(derived(), row, col);
}
/** \nonstableyet
* This is the const version of minor(). */
template<typename Derived>
inline const Minor<Derived>
MatrixBase<Derived>::minor(int row, int col) const
{
return Minor<Derived>(derived(), row, col);
}
#endif // EIGEN_MINOR_H

View File

@@ -0,0 +1,117 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_NESTBYVALUE_H
#define EIGEN_NESTBYVALUE_H
/** \class NestByValue
*
* \brief Expression which must be nested by value
*
* \param ExpressionType the type of the object of which we are requiring nesting-by-value
*
* This class is the return type of MatrixBase::nestByValue()
* and most of the time this is the only way it is used.
*
* \sa MatrixBase::nestByValue()
*/
template<typename ExpressionType>
struct ei_traits<NestByValue<ExpressionType> > : public ei_traits<ExpressionType>
{};
template<typename ExpressionType> class NestByValue
: public MatrixBase<NestByValue<ExpressionType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(NestByValue)
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
inline int rows() const { return m_expression.rows(); }
inline int cols() const { return m_expression.cols(); }
inline int stride() const { return m_expression.stride(); }
inline const Scalar coeff(int row, int col) const
{
return m_expression.coeff(row, col);
}
inline Scalar& coeffRef(int row, int col)
{
return m_expression.const_cast_derived().coeffRef(row, col);
}
inline const Scalar coeff(int index) const
{
return m_expression.coeff(index);
}
inline Scalar& coeffRef(int index)
{
return m_expression.const_cast_derived().coeffRef(index);
}
template<int LoadMode>
inline const PacketScalar packet(int row, int col) const
{
return m_expression.template packet<LoadMode>(row, col);
}
template<int LoadMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
}
template<int LoadMode>
inline const PacketScalar packet(int index) const
{
return m_expression.template packet<LoadMode>(index);
}
template<int LoadMode>
inline void writePacket(int index, const PacketScalar& x)
{
m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
}
protected:
const ExpressionType m_expression;
private:
NestByValue& operator=(const NestByValue&);
};
/** \returns an expression of the temporary version of *this.
*/
template<typename Derived>
inline const NestByValue<Derived>
MatrixBase<Derived>::nestByValue() const
{
return NestByValue<Derived>(derived());
}
#endif // EIGEN_NESTBYVALUE_H

142
extern/Eigen2/Eigen/src/Core/NumTraits.h vendored Normal file
View File

@@ -0,0 +1,142 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_NUMTRAITS_H
#define EIGEN_NUMTRAITS_H
/** \class NumTraits
*
* \brief Holds some data about the various numeric (i.e. scalar) types allowed by Eigen.
*
* \param T the numeric type about which this class provides data. Recall that Eigen allows
* only the following types for \a T: \c int, \c float, \c double,
* \c std::complex<float>, \c std::complex<double>, and \c long \c double (especially
* useful to enforce x87 arithmetics when SSE is the default).
*
* The provided data consists of:
* \li A typedef \a Real, giving the "real part" type of \a T. If \a T is already real,
* then \a Real is just a typedef to \a T. If \a T is \c std::complex<U> then \a Real
* is a typedef to \a U.
* \li A typedef \a FloatingPoint, giving the "floating-point type" of \a T. If \a T is
* \c int, then \a FloatingPoint is a typedef to \c double. Otherwise, \a FloatingPoint
* is a typedef to \a T.
* \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex
* type, and to 0 otherwise.
* \li An enum \a HasFloatingPoint. It is equal to \c 0 if \a T is \c int,
* and to \c 1 otherwise.
*/
template<typename T> struct NumTraits;
template<> struct NumTraits<int>
{
typedef int Real;
typedef double FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 0,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
template<> struct NumTraits<float>
{
typedef float Real;
typedef float FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 1,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
template<> struct NumTraits<double>
{
typedef double Real;
typedef double FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 1,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
template<typename _Real> struct NumTraits<std::complex<_Real> >
{
typedef _Real Real;
typedef std::complex<_Real> FloatingPoint;
enum {
IsComplex = 1,
HasFloatingPoint = NumTraits<Real>::HasFloatingPoint,
ReadCost = 2,
AddCost = 2 * NumTraits<Real>::AddCost,
MulCost = 4 * NumTraits<Real>::MulCost + 2 * NumTraits<Real>::AddCost
};
};
template<> struct NumTraits<long long int>
{
typedef long long int Real;
typedef long double FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 0,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
template<> struct NumTraits<long double>
{
typedef long double Real;
typedef long double FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 1,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
template<> struct NumTraits<bool>
{
typedef bool Real;
typedef float FloatingPoint;
enum {
IsComplex = 0,
HasFloatingPoint = 0,
ReadCost = 1,
AddCost = 1,
MulCost = 1
};
};
#endif // EIGEN_NUMTRAITS_H

377
extern/Eigen2/Eigen/src/Core/Part.h vendored Normal file
View File

@@ -0,0 +1,377 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PART_H
#define EIGEN_PART_H
/** \nonstableyet
* \class Part
*
* \brief Expression of a triangular matrix extracted from a given matrix
*
* \param MatrixType the type of the object in which we are taking the triangular part
* \param Mode the kind of triangular matrix expression to construct. Can be UpperTriangular, StrictlyUpperTriangular,
* UnitUpperTriangular, LowerTriangular, StrictlyLowerTriangular, UnitLowerTriangular. This is in fact a bit field; it must have either
* UpperTriangularBit or LowerTriangularBit, and additionnaly it may have either ZeroDiagBit or
* UnitDiagBit.
*
* This class represents an expression of the upper or lower triangular part of
* a square matrix, possibly with a further assumption on the diagonal. It is the return type
* of MatrixBase::part() and most of the time this is the only way it is used.
*
* \sa MatrixBase::part()
*/
template<typename MatrixType, unsigned int Mode>
struct ei_traits<Part<MatrixType, Mode> > : ei_traits<MatrixType>
{
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
Flags = (_MatrixTypeNested::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode,
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
};
};
template<typename MatrixType, unsigned int Mode> class Part
: public MatrixBase<Part<MatrixType, Mode> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Part)
inline Part(const MatrixType& matrix) : m_matrix(matrix)
{ ei_assert(ei_are_flags_consistent<Mode>::ret); }
/** \sa MatrixBase::operator+=() */
template<typename Other> Part& operator+=(const Other& other);
/** \sa MatrixBase::operator-=() */
template<typename Other> Part& operator-=(const Other& other);
/** \sa MatrixBase::operator*=() */
Part& operator*=(const typename ei_traits<MatrixType>::Scalar& other);
/** \sa MatrixBase::operator/=() */
Part& operator/=(const typename ei_traits<MatrixType>::Scalar& other);
/** \sa operator=(), MatrixBase::lazyAssign() */
template<typename Other> void lazyAssign(const Other& other);
/** \sa MatrixBase::operator=() */
template<typename Other> Part& operator=(const Other& other);
inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
inline int stride() const { return m_matrix.stride(); }
inline Scalar coeff(int row, int col) const
{
// SelfAdjointBit doesn't play any role here: just because a matrix is selfadjoint doesn't say anything about
// each individual coefficient, except for the not-very-useful-here fact that diagonal coefficients are real.
if( ((Flags & LowerTriangularBit) && (col>row)) || ((Flags & UpperTriangularBit) && (row>col)) )
return (Scalar)0;
if(Flags & UnitDiagBit)
return col==row ? (Scalar)1 : m_matrix.coeff(row, col);
else if(Flags & ZeroDiagBit)
return col==row ? (Scalar)0 : m_matrix.coeff(row, col);
else
return m_matrix.coeff(row, col);
}
inline Scalar& coeffRef(int row, int col)
{
EIGEN_STATIC_ASSERT(!(Flags & UnitDiagBit), WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED)
EIGEN_STATIC_ASSERT(!(Flags & SelfAdjointBit), COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED)
ei_assert( (Mode==UpperTriangular && col>=row)
|| (Mode==LowerTriangular && col<=row)
|| (Mode==StrictlyUpperTriangular && col>row)
|| (Mode==StrictlyLowerTriangular && col<row));
return m_matrix.const_cast_derived().coeffRef(row, col);
}
/** \internal */
const MatrixType& _expression() const { return m_matrix; }
/** discard any writes to a row */
const Block<Part, 1, ColsAtCompileTime> row(int i) { return Base::row(i); }
const Block<Part, 1, ColsAtCompileTime> row(int i) const { return Base::row(i); }
/** discard any writes to a column */
const Block<Part, RowsAtCompileTime, 1> col(int i) { return Base::col(i); }
const Block<Part, RowsAtCompileTime, 1> col(int i) const { return Base::col(i); }
template<typename OtherDerived>
void swap(const MatrixBase<OtherDerived>& other)
{
Part<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(m_matrix)).lazyAssign(other.derived());
}
protected:
const typename MatrixType::Nested m_matrix;
private:
Part& operator=(const Part&);
};
/** \nonstableyet
* \returns an expression of a triangular matrix extracted from the current matrix
*
* The parameter \a Mode can have the following values: \c UpperTriangular, \c StrictlyUpperTriangular, \c UnitUpperTriangular,
* \c LowerTriangular, \c StrictlyLowerTriangular, \c UnitLowerTriangular.
*
* \addexample PartExample \label How to extract a triangular part of an arbitrary matrix
*
* Example: \include MatrixBase_extract.cpp
* Output: \verbinclude MatrixBase_extract.out
*
* \sa class Part, part(), marked()
*/
template<typename Derived>
template<unsigned int Mode>
const Part<Derived, Mode> MatrixBase<Derived>::part() const
{
return derived();
}
template<typename MatrixType, unsigned int Mode>
template<typename Other>
inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator=(const Other& other)
{
if(Other::Flags & EvalBeforeAssigningBit)
{
typename MatrixBase<Other>::PlainMatrixType other_evaluated(other.rows(), other.cols());
other_evaluated.template part<Mode>().lazyAssign(other);
lazyAssign(other_evaluated);
}
else
lazyAssign(other.derived());
return *this;
}
template<typename Derived1, typename Derived2, unsigned int Mode, int UnrollCount>
struct ei_part_assignment_impl
{
enum {
col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
row = (UnrollCount-1) % Derived1::RowsAtCompileTime
};
inline static void run(Derived1 &dst, const Derived2 &src)
{
ei_part_assignment_impl<Derived1, Derived2, Mode, UnrollCount-1>::run(dst, src);
if(Mode == SelfAdjoint)
{
if(row == col)
dst.coeffRef(row, col) = ei_real(src.coeff(row, col));
else if(row < col)
dst.coeffRef(col, row) = ei_conj(dst.coeffRef(row, col) = src.coeff(row, col));
}
else
{
ei_assert(Mode == UpperTriangular || Mode == LowerTriangular || Mode == StrictlyUpperTriangular || Mode == StrictlyLowerTriangular);
if((Mode == UpperTriangular && row <= col)
|| (Mode == LowerTriangular && row >= col)
|| (Mode == StrictlyUpperTriangular && row < col)
|| (Mode == StrictlyLowerTriangular && row > col))
dst.copyCoeff(row, col, src);
}
}
};
template<typename Derived1, typename Derived2, unsigned int Mode>
struct ei_part_assignment_impl<Derived1, Derived2, Mode, 1>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
if(!(Mode & ZeroDiagBit))
dst.copyCoeff(0, 0, src);
}
};
// prevent buggy user code from causing an infinite recursion
template<typename Derived1, typename Derived2, unsigned int Mode>
struct ei_part_assignment_impl<Derived1, Derived2, Mode, 0>
{
inline static void run(Derived1 &, const Derived2 &) {}
};
template<typename Derived1, typename Derived2>
struct ei_part_assignment_impl<Derived1, Derived2, UpperTriangular, Dynamic>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
for(int j = 0; j < dst.cols(); ++j)
for(int i = 0; i <= j; ++i)
dst.copyCoeff(i, j, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_part_assignment_impl<Derived1, Derived2, LowerTriangular, Dynamic>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
for(int j = 0; j < dst.cols(); ++j)
for(int i = j; i < dst.rows(); ++i)
dst.copyCoeff(i, j, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_part_assignment_impl<Derived1, Derived2, StrictlyUpperTriangular, Dynamic>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
for(int j = 0; j < dst.cols(); ++j)
for(int i = 0; i < j; ++i)
dst.copyCoeff(i, j, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_part_assignment_impl<Derived1, Derived2, StrictlyLowerTriangular, Dynamic>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
for(int j = 0; j < dst.cols(); ++j)
for(int i = j+1; i < dst.rows(); ++i)
dst.copyCoeff(i, j, src);
}
};
template<typename Derived1, typename Derived2>
struct ei_part_assignment_impl<Derived1, Derived2, SelfAdjoint, Dynamic>
{
inline static void run(Derived1 &dst, const Derived2 &src)
{
for(int j = 0; j < dst.cols(); ++j)
{
for(int i = 0; i < j; ++i)
dst.coeffRef(j, i) = ei_conj(dst.coeffRef(i, j) = src.coeff(i, j));
dst.coeffRef(j, j) = ei_real(src.coeff(j, j));
}
}
};
template<typename MatrixType, unsigned int Mode>
template<typename Other>
void Part<MatrixType, Mode>::lazyAssign(const Other& other)
{
const bool unroll = MatrixType::SizeAtCompileTime * Other::CoeffReadCost / 2 <= EIGEN_UNROLLING_LIMIT;
ei_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols());
ei_part_assignment_impl
<MatrixType, Other, Mode,
unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic
>::run(m_matrix.const_cast_derived(), other.derived());
}
/** \nonstableyet
* \returns a lvalue pseudo-expression allowing to perform special operations on \c *this.
*
* The \a Mode parameter can have the following values: \c UpperTriangular, \c StrictlyUpperTriangular, \c LowerTriangular,
* \c StrictlyLowerTriangular, \c SelfAdjoint.
*
* \addexample PartExample \label How to write to a triangular part of a matrix
*
* Example: \include MatrixBase_part.cpp
* Output: \verbinclude MatrixBase_part.out
*
* \sa class Part, MatrixBase::extract(), MatrixBase::marked()
*/
template<typename Derived>
template<unsigned int Mode>
inline Part<Derived, Mode> MatrixBase<Derived>::part()
{
return Part<Derived, Mode>(derived());
}
/** \returns true if *this is approximately equal to an upper triangular matrix,
* within the precision given by \a prec.
*
* \sa isLowerTriangular(), extract(), part(), marked()
*/
template<typename Derived>
bool MatrixBase<Derived>::isUpperTriangular(RealScalar prec) const
{
if(cols() != rows()) return false;
RealScalar maxAbsOnUpperTriangularPart = static_cast<RealScalar>(-1);
for(int j = 0; j < cols(); ++j)
for(int i = 0; i <= j; ++i)
{
RealScalar absValue = ei_abs(coeff(i,j));
if(absValue > maxAbsOnUpperTriangularPart) maxAbsOnUpperTriangularPart = absValue;
}
for(int j = 0; j < cols()-1; ++j)
for(int i = j+1; i < rows(); ++i)
if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnUpperTriangularPart, prec)) return false;
return true;
}
/** \returns true if *this is approximately equal to a lower triangular matrix,
* within the precision given by \a prec.
*
* \sa isUpperTriangular(), extract(), part(), marked()
*/
template<typename Derived>
bool MatrixBase<Derived>::isLowerTriangular(RealScalar prec) const
{
if(cols() != rows()) return false;
RealScalar maxAbsOnLowerTriangularPart = static_cast<RealScalar>(-1);
for(int j = 0; j < cols(); ++j)
for(int i = j; i < rows(); ++i)
{
RealScalar absValue = ei_abs(coeff(i,j));
if(absValue > maxAbsOnLowerTriangularPart) maxAbsOnLowerTriangularPart = absValue;
}
for(int j = 1; j < cols(); ++j)
for(int i = 0; i < j; ++i)
if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnLowerTriangularPart, prec)) return false;
return true;
}
template<typename MatrixType, unsigned int Mode>
template<typename Other>
inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator+=(const Other& other)
{
return *this = m_matrix + other;
}
template<typename MatrixType, unsigned int Mode>
template<typename Other>
inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator-=(const Other& other)
{
return *this = m_matrix - other;
}
template<typename MatrixType, unsigned int Mode>
inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator*=
(const typename ei_traits<MatrixType>::Scalar& other)
{
return *this = m_matrix * other;
}
template<typename MatrixType, unsigned int Mode>
inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator/=
(const typename ei_traits<MatrixType>::Scalar& other)
{
return *this = m_matrix / other;
}
#endif // EIGEN_PART_H

769
extern/Eigen2/Eigen/src/Core/Product.h vendored Normal file
View File

@@ -0,0 +1,769 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PRODUCT_H
#define EIGEN_PRODUCT_H
/***************************
*** Forward declarations ***
***************************/
template<int VectorizationMode, int Index, typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl;
template<int StorageOrder, int Index, typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl;
/** \class ProductReturnType
*
* \brief Helper class to get the correct and optimized returned type of operator*
*
* \param Lhs the type of the left-hand side
* \param Rhs the type of the right-hand side
* \param ProductMode the type of the product (determined automatically by ei_product_mode)
*
* This class defines the typename Type representing the optimized product expression
* between two matrix expressions. In practice, using ProductReturnType<Lhs,Rhs>::Type
* is the recommended way to define the result type of a function returning an expression
* which involve a matrix product. The class Product or DiagonalProduct should never be
* used directly.
*
* \sa class Product, class DiagonalProduct, MatrixBase::operator*(const MatrixBase<OtherDerived>&)
*/
template<typename Lhs, typename Rhs, int ProductMode>
struct ProductReturnType
{
typedef typename ei_nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;
typedef typename ei_nested<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;
typedef Product<LhsNested, RhsNested, ProductMode> Type;
};
// cache friendly specialization
// note that there is a DiagonalProduct specialization in DiagonalProduct.h
template<typename Lhs, typename Rhs>
struct ProductReturnType<Lhs,Rhs,CacheFriendlyProduct>
{
typedef typename ei_nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;
typedef typename ei_nested<Rhs,Lhs::RowsAtCompileTime,
typename ei_plain_matrix_type_column_major<Rhs>::type
>::type RhsNested;
typedef Product<LhsNested, RhsNested, CacheFriendlyProduct> Type;
};
/* Helper class to determine the type of the product, can be either:
* - NormalProduct
* - CacheFriendlyProduct
* - DiagonalProduct
*/
template<typename Lhs, typename Rhs> struct ei_product_mode
{
enum{
value = ((Rhs::Flags&Diagonal)==Diagonal) || ((Lhs::Flags&Diagonal)==Diagonal)
? DiagonalProduct
: Lhs::MaxColsAtCompileTime == Dynamic
&& ( Lhs::MaxRowsAtCompileTime == Dynamic
|| Rhs::MaxColsAtCompileTime == Dynamic )
&& (!(Rhs::IsVectorAtCompileTime && (Lhs::Flags&RowMajorBit) && (!(Lhs::Flags&DirectAccessBit))))
&& (!(Lhs::IsVectorAtCompileTime && (!(Rhs::Flags&RowMajorBit)) && (!(Rhs::Flags&DirectAccessBit))))
&& (ei_is_same_type<typename Lhs::Scalar, typename Rhs::Scalar>::ret)
? CacheFriendlyProduct
: NormalProduct };
};
/** \class Product
*
* \brief Expression of the product of two matrices
*
* \param LhsNested the type used to store the left-hand side
* \param RhsNested the type used to store the right-hand side
* \param ProductMode the type of the product
*
* This class represents an expression of the product of two matrices.
* It is the return type of the operator* between matrices. Its template
* arguments are determined automatically by ProductReturnType. Therefore,
* Product should never be used direclty. To determine the result type of a
* function which involves a matrix product, use ProductReturnType::Type.
*
* \sa ProductReturnType, MatrixBase::operator*(const MatrixBase<OtherDerived>&)
*/
template<typename LhsNested, typename RhsNested, int ProductMode>
struct ei_traits<Product<LhsNested, RhsNested, ProductMode> >
{
// clean the nested types:
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;
enum {
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
LhsFlags = _LhsNested::Flags,
RhsFlags = _RhsNested::Flags,
RowsAtCompileTime = _LhsNested::RowsAtCompileTime,
ColsAtCompileTime = _RhsNested::ColsAtCompileTime,
InnerSize = EIGEN_ENUM_MIN(_LhsNested::ColsAtCompileTime, _RhsNested::RowsAtCompileTime),
MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime,
MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime,
LhsRowMajor = LhsFlags & RowMajorBit,
RhsRowMajor = RhsFlags & RowMajorBit,
CanVectorizeRhs = RhsRowMajor && (RhsFlags & PacketAccessBit)
&& (ColsAtCompileTime % ei_packet_traits<Scalar>::size == 0),
CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags & PacketAccessBit)
&& (RowsAtCompileTime % ei_packet_traits<Scalar>::size == 0),
EvalToRowMajor = RhsRowMajor && (ProductMode==(int)CacheFriendlyProduct ? LhsRowMajor : (!CanVectorizeLhs)),
RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit),
Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
| EvalBeforeAssigningBit
| EvalBeforeNestingBit
| (CanVectorizeLhs || CanVectorizeRhs ? PacketAccessBit : 0)
| (LhsFlags & RhsFlags & AlignedBit),
CoeffReadCost = InnerSize == Dynamic ? Dynamic
: InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost)
+ (InnerSize - 1) * NumTraits<Scalar>::AddCost,
/* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside
* of Product. If the Product itself is not a packet-access expression, there is still a chance that the inner
* loop of the product might be vectorized. This is the meaning of CanVectorizeInner. Since it doesn't affect
* the Flags, it is safe to make this value depend on ActualPacketAccessBit, that doesn't affect the ABI.
*/
CanVectorizeInner = LhsRowMajor && (!RhsRowMajor) && (LhsFlags & RhsFlags & ActualPacketAccessBit)
&& (InnerSize % ei_packet_traits<Scalar>::size == 0)
};
};
template<typename LhsNested, typename RhsNested, int ProductMode> class Product : ei_no_assignment_operator,
public MatrixBase<Product<LhsNested, RhsNested, ProductMode> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Product)
private:
typedef typename ei_traits<Product>::_LhsNested _LhsNested;
typedef typename ei_traits<Product>::_RhsNested _RhsNested;
enum {
PacketSize = ei_packet_traits<Scalar>::size,
InnerSize = ei_traits<Product>::InnerSize,
Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT,
CanVectorizeInner = ei_traits<Product>::CanVectorizeInner
};
typedef ei_product_coeff_impl<CanVectorizeInner ? InnerVectorization : NoVectorization,
Unroll ? InnerSize-1 : Dynamic,
_LhsNested, _RhsNested, Scalar> ScalarCoeffImpl;
public:
template<typename Lhs, typename Rhs>
inline Product(const Lhs& lhs, const Rhs& rhs)
: m_lhs(lhs), m_rhs(rhs)
{
// we don't allow taking products of matrices of different real types, as that wouldn't be vectorizable.
// We still allow to mix T and complex<T>.
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Lhs::RealScalar, typename Rhs::RealScalar>::ret),
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
ei_assert(lhs.cols() == rhs.rows()
&& "invalid matrix product"
&& "if you wanted a coeff-wise or a dot product use the respective explicit functions");
}
/** \internal
* compute \a res += \c *this using the cache friendly product.
*/
template<typename DestDerived>
void _cacheFriendlyEvalAndAdd(DestDerived& res) const;
/** \internal
* \returns whether it is worth it to use the cache friendly product.
*/
EIGEN_STRONG_INLINE bool _useCacheFriendlyProduct() const
{
return m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
&& ( rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
|| cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD);
}
EIGEN_STRONG_INLINE int rows() const { return m_lhs.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_rhs.cols(); }
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
{
Scalar res;
ScalarCoeffImpl::run(row, col, m_lhs, m_rhs, res);
return res;
}
/* Allow index-based non-packet access. It is impossible though to allow index-based packed access,
* which is why we don't set the LinearAccessBit.
*/
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
Scalar res;
const int row = RowsAtCompileTime == 1 ? 0 : index;
const int col = RowsAtCompileTime == 1 ? index : 0;
ScalarCoeffImpl::run(row, col, m_lhs, m_rhs, res);
return res;
}
template<int LoadMode>
EIGEN_STRONG_INLINE const PacketScalar packet(int row, int col) const
{
PacketScalar res;
ei_product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor,
Unroll ? InnerSize-1 : Dynamic,
_LhsNested, _RhsNested, PacketScalar, LoadMode>
::run(row, col, m_lhs, m_rhs, res);
return res;
}
EIGEN_STRONG_INLINE const _LhsNested& lhs() const { return m_lhs; }
EIGEN_STRONG_INLINE const _RhsNested& rhs() const { return m_rhs; }
protected:
const LhsNested m_lhs;
const RhsNested m_rhs;
};
/** \returns the matrix product of \c *this and \a other.
*
* \note If instead of the matrix product you want the coefficient-wise product, see Cwise::operator*().
*
* \sa lazy(), operator*=(const MatrixBase&), Cwise::operator*()
*/
template<typename Derived>
template<typename OtherDerived>
inline const typename ProductReturnType<Derived,OtherDerived>::Type
MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
{
enum {
ProductIsValid = Derived::ColsAtCompileTime==Dynamic
|| OtherDerived::RowsAtCompileTime==Dynamic
|| int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)
};
// note to the lost user:
// * for a dot product use: v1.dot(v2)
// * for a coeff-wise product use: v1.cwise()*v2
EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
return typename ProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived());
}
/** replaces \c *this by \c *this * \a other.
*
* \returns a reference to \c *this
*/
template<typename Derived>
template<typename OtherDerived>
inline Derived &
MatrixBase<Derived>::operator*=(const MatrixBase<OtherDerived> &other)
{
return derived() = derived() * other.derived();
}
/***************************************************************************
* Normal product .coeff() implementation (with meta-unrolling)
***************************************************************************/
/**************************************
*** Scalar path - no vectorization ***
**************************************/
template<int Index, typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<NoVectorization, Index, Lhs, Rhs, RetScalar>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
{
ei_product_coeff_impl<NoVectorization, Index-1, Lhs, Rhs, RetScalar>::run(row, col, lhs, rhs, res);
res += lhs.coeff(row, Index) * rhs.coeff(Index, col);
}
};
template<typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<NoVectorization, 0, Lhs, Rhs, RetScalar>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
{
res = lhs.coeff(row, 0) * rhs.coeff(0, col);
}
};
template<typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<NoVectorization, Dynamic, Lhs, Rhs, RetScalar>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, RetScalar& res)
{
ei_assert(lhs.cols()>0 && "you are using a non initialized matrix");
res = lhs.coeff(row, 0) * rhs.coeff(0, col);
for(int i = 1; i < lhs.cols(); ++i)
res += lhs.coeff(row, i) * rhs.coeff(i, col);
}
};
// prevent buggy user code from causing an infinite recursion
template<typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<NoVectorization, -1, Lhs, Rhs, RetScalar>
{
EIGEN_STRONG_INLINE static void run(int, int, const Lhs&, const Rhs&, RetScalar&) {}
};
/*******************************************
*** Scalar path with inner vectorization ***
*******************************************/
template<int Index, typename Lhs, typename Rhs, typename PacketScalar>
struct ei_product_coeff_vectorized_unroller
{
enum { PacketSize = ei_packet_traits<typename Lhs::Scalar>::size };
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
{
ei_product_coeff_vectorized_unroller<Index-PacketSize, Lhs, Rhs, PacketScalar>::run(row, col, lhs, rhs, pres);
pres = ei_padd(pres, ei_pmul( lhs.template packet<Aligned>(row, Index) , rhs.template packet<Aligned>(Index, col) ));
}
};
template<typename Lhs, typename Rhs, typename PacketScalar>
struct ei_product_coeff_vectorized_unroller<0, Lhs, Rhs, PacketScalar>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::PacketScalar &pres)
{
pres = ei_pmul(lhs.template packet<Aligned>(row, 0) , rhs.template packet<Aligned>(0, col));
}
};
template<int Index, typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<InnerVectorization, Index, Lhs, Rhs, RetScalar>
{
typedef typename Lhs::PacketScalar PacketScalar;
enum { PacketSize = ei_packet_traits<typename Lhs::Scalar>::size };
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
{
PacketScalar pres;
ei_product_coeff_vectorized_unroller<Index+1-PacketSize, Lhs, Rhs, PacketScalar>::run(row, col, lhs, rhs, pres);
ei_product_coeff_impl<NoVectorization,Index,Lhs,Rhs,RetScalar>::run(row, col, lhs, rhs, res);
res = ei_predux(pres);
}
};
template<typename Lhs, typename Rhs, int LhsRows = Lhs::RowsAtCompileTime, int RhsCols = Rhs::ColsAtCompileTime>
struct ei_product_coeff_vectorized_dyn_selector
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
{
res = ei_dot_impl<
Block<Lhs, 1, ei_traits<Lhs>::ColsAtCompileTime>,
Block<Rhs, ei_traits<Rhs>::RowsAtCompileTime, 1>,
LinearVectorization, NoUnrolling>::run(lhs.row(row), rhs.col(col));
}
};
// NOTE the 3 following specializations are because taking .col(0) on a vector is a bit slower
// NOTE maybe they are now useless since we have a specialization for Block<Matrix>
template<typename Lhs, typename Rhs, int RhsCols>
struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,RhsCols>
{
EIGEN_STRONG_INLINE static void run(int /*row*/, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
{
res = ei_dot_impl<
Lhs,
Block<Rhs, ei_traits<Rhs>::RowsAtCompileTime, 1>,
LinearVectorization, NoUnrolling>::run(lhs, rhs.col(col));
}
};
template<typename Lhs, typename Rhs, int LhsRows>
struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,LhsRows,1>
{
EIGEN_STRONG_INLINE static void run(int row, int /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
{
res = ei_dot_impl<
Block<Lhs, 1, ei_traits<Lhs>::ColsAtCompileTime>,
Rhs,
LinearVectorization, NoUnrolling>::run(lhs.row(row), rhs);
}
};
template<typename Lhs, typename Rhs>
struct ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs,1,1>
{
EIGEN_STRONG_INLINE static void run(int /*row*/, int /*col*/, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
{
res = ei_dot_impl<
Lhs,
Rhs,
LinearVectorization, NoUnrolling>::run(lhs, rhs);
}
};
template<typename Lhs, typename Rhs, typename RetScalar>
struct ei_product_coeff_impl<InnerVectorization, Dynamic, Lhs, Rhs, RetScalar>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res)
{
ei_product_coeff_vectorized_dyn_selector<Lhs,Rhs>::run(row, col, lhs, rhs, res);
}
};
/*******************
*** Packet path ***
*******************/
template<int Index, typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<RowMajor, Index, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar &res)
{
ei_product_packet_impl<RowMajor, Index-1, Lhs, Rhs, PacketScalar, LoadMode>::run(row, col, lhs, rhs, res);
res = ei_pmadd(ei_pset1(lhs.coeff(row, Index)), rhs.template packet<LoadMode>(Index, col), res);
}
};
template<int Index, typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<ColMajor, Index, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar &res)
{
ei_product_packet_impl<ColMajor, Index-1, Lhs, Rhs, PacketScalar, LoadMode>::run(row, col, lhs, rhs, res);
res = ei_pmadd(lhs.template packet<LoadMode>(row, Index), ei_pset1(rhs.coeff(Index, col)), res);
}
};
template<typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<RowMajor, 0, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar &res)
{
res = ei_pmul(ei_pset1(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col));
}
};
template<typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<ColMajor, 0, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar &res)
{
res = ei_pmul(lhs.template packet<LoadMode>(row, 0), ei_pset1(rhs.coeff(0, col)));
}
};
template<typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar& res)
{
ei_assert(lhs.cols()>0 && "you are using a non initialized matrix");
res = ei_pmul(ei_pset1(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col));
for(int i = 1; i < lhs.cols(); ++i)
res = ei_pmadd(ei_pset1(lhs.coeff(row, i)), rhs.template packet<LoadMode>(i, col), res);
}
};
template<typename Lhs, typename Rhs, typename PacketScalar, int LoadMode>
struct ei_product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, PacketScalar, LoadMode>
{
EIGEN_STRONG_INLINE static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, PacketScalar& res)
{
ei_assert(lhs.cols()>0 && "you are using a non initialized matrix");
res = ei_pmul(lhs.template packet<LoadMode>(row, 0), ei_pset1(rhs.coeff(0, col)));
for(int i = 1; i < lhs.cols(); ++i)
res = ei_pmadd(lhs.template packet<LoadMode>(row, i), ei_pset1(rhs.coeff(i, col)), res);
}
};
/***************************************************************************
* Cache friendly product callers and specific nested evaluation strategies
***************************************************************************/
template<typename Scalar, typename RhsType>
static void ei_cache_friendly_product_colmajor_times_vector(
int size, const Scalar* lhs, int lhsStride, const RhsType& rhs, Scalar* res);
template<typename Scalar, typename ResType>
static void ei_cache_friendly_product_rowmajor_times_vector(
const Scalar* lhs, int lhsStride, const Scalar* rhs, int rhsSize, ResType& res);
template<typename ProductType,
int LhsRows = ei_traits<ProductType>::RowsAtCompileTime,
int LhsOrder = int(ei_traits<ProductType>::LhsFlags)&RowMajorBit ? RowMajor : ColMajor,
int LhsHasDirectAccess = int(ei_traits<ProductType>::LhsFlags)&DirectAccessBit? HasDirectAccess : NoDirectAccess,
int RhsCols = ei_traits<ProductType>::ColsAtCompileTime,
int RhsOrder = int(ei_traits<ProductType>::RhsFlags)&RowMajorBit ? RowMajor : ColMajor,
int RhsHasDirectAccess = int(ei_traits<ProductType>::RhsFlags)&DirectAccessBit? HasDirectAccess : NoDirectAccess>
struct ei_cache_friendly_product_selector
{
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
product._cacheFriendlyEvalAndAdd(res);
}
};
// optimized colmajor * vector path
template<typename ProductType, int LhsRows, int RhsOrder, int RhsAccess>
struct ei_cache_friendly_product_selector<ProductType,LhsRows,ColMajor,NoDirectAccess,1,RhsOrder,RhsAccess>
{
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
const int size = product.rhs().rows();
for (int k=0; k<size; ++k)
res += product.rhs().coeff(k) * product.lhs().col(k);
}
};
// optimized cache friendly colmajor * vector path for matrix with direct access flag
// NOTE this path could also be enabled for expressions if we add runtime align queries
template<typename ProductType, int LhsRows, int RhsOrder, int RhsAccess>
struct ei_cache_friendly_product_selector<ProductType,LhsRows,ColMajor,HasDirectAccess,1,RhsOrder,RhsAccess>
{
typedef typename ProductType::Scalar Scalar;
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
enum {
EvalToRes = (ei_packet_traits<Scalar>::size==1)
||((DestDerived::Flags&ActualPacketAccessBit) && (!(DestDerived::Flags & RowMajorBit))) };
Scalar* EIGEN_RESTRICT _res;
if (EvalToRes)
_res = &res.coeffRef(0);
else
{
_res = ei_aligned_stack_new(Scalar,res.size());
Map<Matrix<Scalar,DestDerived::RowsAtCompileTime,1> >(_res, res.size()) = res;
}
ei_cache_friendly_product_colmajor_times_vector(res.size(),
&product.lhs().const_cast_derived().coeffRef(0,0), product.lhs().stride(),
product.rhs(), _res);
if (!EvalToRes)
{
res = Map<Matrix<Scalar,DestDerived::SizeAtCompileTime,1> >(_res, res.size());
ei_aligned_stack_delete(Scalar, _res, res.size());
}
}
};
// optimized vector * rowmajor path
template<typename ProductType, int LhsOrder, int LhsAccess, int RhsCols>
struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCols,RowMajor,NoDirectAccess>
{
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
const int cols = product.lhs().cols();
for (int j=0; j<cols; ++j)
res += product.lhs().coeff(j) * product.rhs().row(j);
}
};
// optimized cache friendly vector * rowmajor path for matrix with direct access flag
// NOTE this path coul also be enabled for expressions if we add runtime align queries
template<typename ProductType, int LhsOrder, int LhsAccess, int RhsCols>
struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCols,RowMajor,HasDirectAccess>
{
typedef typename ProductType::Scalar Scalar;
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
enum {
EvalToRes = (ei_packet_traits<Scalar>::size==1)
||((DestDerived::Flags & ActualPacketAccessBit) && (DestDerived::Flags & RowMajorBit)) };
Scalar* EIGEN_RESTRICT _res;
if (EvalToRes)
_res = &res.coeffRef(0);
else
{
_res = ei_aligned_stack_new(Scalar, res.size());
Map<Matrix<Scalar,DestDerived::SizeAtCompileTime,1> >(_res, res.size()) = res;
}
ei_cache_friendly_product_colmajor_times_vector(res.size(),
&product.rhs().const_cast_derived().coeffRef(0,0), product.rhs().stride(),
product.lhs().transpose(), _res);
if (!EvalToRes)
{
res = Map<Matrix<Scalar,DestDerived::SizeAtCompileTime,1> >(_res, res.size());
ei_aligned_stack_delete(Scalar, _res, res.size());
}
}
};
// optimized rowmajor - vector product
template<typename ProductType, int LhsRows, int RhsOrder, int RhsAccess>
struct ei_cache_friendly_product_selector<ProductType,LhsRows,RowMajor,HasDirectAccess,1,RhsOrder,RhsAccess>
{
typedef typename ProductType::Scalar Scalar;
typedef typename ei_traits<ProductType>::_RhsNested Rhs;
enum {
UseRhsDirectly = ((ei_packet_traits<Scalar>::size==1) || (Rhs::Flags&ActualPacketAccessBit))
&& (!(Rhs::Flags & RowMajorBit)) };
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
Scalar* EIGEN_RESTRICT _rhs;
if (UseRhsDirectly)
_rhs = &product.rhs().const_cast_derived().coeffRef(0);
else
{
_rhs = ei_aligned_stack_new(Scalar, product.rhs().size());
Map<Matrix<Scalar,Rhs::SizeAtCompileTime,1> >(_rhs, product.rhs().size()) = product.rhs();
}
ei_cache_friendly_product_rowmajor_times_vector(&product.lhs().const_cast_derived().coeffRef(0,0), product.lhs().stride(),
_rhs, product.rhs().size(), res);
if (!UseRhsDirectly) ei_aligned_stack_delete(Scalar, _rhs, product.rhs().size());
}
};
// optimized vector - colmajor product
template<typename ProductType, int LhsOrder, int LhsAccess, int RhsCols>
struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCols,ColMajor,HasDirectAccess>
{
typedef typename ProductType::Scalar Scalar;
typedef typename ei_traits<ProductType>::_LhsNested Lhs;
enum {
UseLhsDirectly = ((ei_packet_traits<Scalar>::size==1) || (Lhs::Flags&ActualPacketAccessBit))
&& (Lhs::Flags & RowMajorBit) };
template<typename DestDerived>
inline static void run(DestDerived& res, const ProductType& product)
{
Scalar* EIGEN_RESTRICT _lhs;
if (UseLhsDirectly)
_lhs = &product.lhs().const_cast_derived().coeffRef(0);
else
{
_lhs = ei_aligned_stack_new(Scalar, product.lhs().size());
Map<Matrix<Scalar,Lhs::SizeAtCompileTime,1> >(_lhs, product.lhs().size()) = product.lhs();
}
ei_cache_friendly_product_rowmajor_times_vector(&product.rhs().const_cast_derived().coeffRef(0,0), product.rhs().stride(),
_lhs, product.lhs().size(), res);
if(!UseLhsDirectly) ei_aligned_stack_delete(Scalar, _lhs, product.lhs().size());
}
};
// discard this case which has to be handled by the default path
// (we keep it to be sure to hit a compilation error if this is not the case)
template<typename ProductType, int LhsRows, int RhsOrder, int RhsAccess>
struct ei_cache_friendly_product_selector<ProductType,LhsRows,RowMajor,NoDirectAccess,1,RhsOrder,RhsAccess>
{};
// discard this case which has to be handled by the default path
// (we keep it to be sure to hit a compilation error if this is not the case)
template<typename ProductType, int LhsOrder, int LhsAccess, int RhsCols>
struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCols,ColMajor,NoDirectAccess>
{};
/** \internal */
template<typename Derived>
template<typename Lhs,typename Rhs>
inline Derived&
MatrixBase<Derived>::operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other)
{
if (other._expression()._useCacheFriendlyProduct())
ei_cache_friendly_product_selector<Product<Lhs,Rhs,CacheFriendlyProduct> >::run(const_cast_derived(), other._expression());
else
lazyAssign(derived() + other._expression());
return derived();
}
template<typename Derived>
template<typename Lhs, typename Rhs>
inline Derived& MatrixBase<Derived>::lazyAssign(const Product<Lhs,Rhs,CacheFriendlyProduct>& product)
{
if (product._useCacheFriendlyProduct())
{
setZero();
ei_cache_friendly_product_selector<Product<Lhs,Rhs,CacheFriendlyProduct> >::run(const_cast_derived(), product);
}
else
{
lazyAssign<Product<Lhs,Rhs,CacheFriendlyProduct> >(product);
}
return derived();
}
template<typename T> struct ei_product_copy_rhs
{
typedef typename ei_meta_if<
(ei_traits<T>::Flags & RowMajorBit)
|| (!(ei_traits<T>::Flags & DirectAccessBit)),
typename ei_plain_matrix_type_column_major<T>::type,
const T&
>::ret type;
};
template<typename T> struct ei_product_copy_lhs
{
typedef typename ei_meta_if<
(!(int(ei_traits<T>::Flags) & DirectAccessBit)),
typename ei_plain_matrix_type<T>::type,
const T&
>::ret type;
};
template<typename Lhs, typename Rhs, int ProductMode>
template<typename DestDerived>
inline void Product<Lhs,Rhs,ProductMode>::_cacheFriendlyEvalAndAdd(DestDerived& res) const
{
typedef typename ei_product_copy_lhs<_LhsNested>::type LhsCopy;
typedef typename ei_unref<LhsCopy>::type _LhsCopy;
typedef typename ei_product_copy_rhs<_RhsNested>::type RhsCopy;
typedef typename ei_unref<RhsCopy>::type _RhsCopy;
LhsCopy lhs(m_lhs);
RhsCopy rhs(m_rhs);
ei_cache_friendly_product<Scalar>(
rows(), cols(), lhs.cols(),
_LhsCopy::Flags&RowMajorBit, (const Scalar*)&(lhs.const_cast_derived().coeffRef(0,0)), lhs.stride(),
_RhsCopy::Flags&RowMajorBit, (const Scalar*)&(rhs.const_cast_derived().coeffRef(0,0)), rhs.stride(),
DestDerived::Flags&RowMajorBit, (Scalar*)&(res.coeffRef(0,0)), res.stride()
);
}
#endif // EIGEN_PRODUCT_H

117
extern/Eigen2/Eigen/src/Core/Redux.h vendored Normal file
View File

@@ -0,0 +1,117 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_REDUX_H
#define EIGEN_REDUX_H
template<typename BinaryOp, typename Derived, int Start, int Length>
struct ei_redux_impl
{
enum {
HalfLength = Length/2
};
typedef typename ei_result_of<BinaryOp(typename Derived::Scalar)>::type Scalar;
static Scalar run(const Derived &mat, const BinaryOp& func)
{
return func(
ei_redux_impl<BinaryOp, Derived, Start, HalfLength>::run(mat, func),
ei_redux_impl<BinaryOp, Derived, Start+HalfLength, Length - HalfLength>::run(mat, func));
}
};
template<typename BinaryOp, typename Derived, int Start>
struct ei_redux_impl<BinaryOp, Derived, Start, 1>
{
enum {
col = Start / Derived::RowsAtCompileTime,
row = Start % Derived::RowsAtCompileTime
};
typedef typename ei_result_of<BinaryOp(typename Derived::Scalar)>::type Scalar;
static Scalar run(const Derived &mat, const BinaryOp &)
{
return mat.coeff(row, col);
}
};
template<typename BinaryOp, typename Derived, int Start>
struct ei_redux_impl<BinaryOp, Derived, Start, Dynamic>
{
typedef typename ei_result_of<BinaryOp(typename Derived::Scalar)>::type Scalar;
static Scalar run(const Derived& mat, const BinaryOp& func)
{
ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using a non initialized matrix");
Scalar res;
res = mat.coeff(0,0);
for(int i = 1; i < mat.rows(); ++i)
res = func(res, mat.coeff(i, 0));
for(int j = 1; j < mat.cols(); ++j)
for(int i = 0; i < mat.rows(); ++i)
res = func(res, mat.coeff(i, j));
return res;
}
};
/** \returns the result of a full redux operation on the whole matrix or vector using \a func
*
* The template parameter \a BinaryOp is the type of the functor \a func which must be
* an assiociative operator. Both current STL and TR1 functor styles are handled.
*
* \sa MatrixBase::sum(), MatrixBase::minCoeff(), MatrixBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()
*/
template<typename Derived>
template<typename BinaryOp>
typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
MatrixBase<Derived>::redux(const BinaryOp& func) const
{
const bool unroll = SizeAtCompileTime * CoeffReadCost
+ (SizeAtCompileTime-1) * ei_functor_traits<BinaryOp>::Cost
<= EIGEN_UNROLLING_LIMIT;
return ei_redux_impl<BinaryOp, Derived, 0, unroll ? int(SizeAtCompileTime) : Dynamic>
::run(derived(), func);
}
/** \returns the minimum of all coefficients of *this
*/
template<typename Derived>
inline typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::minCoeff() const
{
return this->redux(Eigen::ei_scalar_min_op<Scalar>());
}
/** \returns the maximum of all coefficients of *this
*/
template<typename Derived>
inline typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::maxCoeff() const
{
return this->redux(Eigen::ei_scalar_max_op<Scalar>());
}
#endif // EIGEN_REDUX_H

View File

@@ -0,0 +1,297 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_SOLVETRIANGULAR_H
#define EIGEN_SOLVETRIANGULAR_H
template<typename XprType> struct ei_is_part { enum {value=false}; };
template<typename XprType, unsigned int Mode> struct ei_is_part<Part<XprType,Mode> > { enum {value=true}; };
template<typename Lhs, typename Rhs,
int TriangularPart = (int(Lhs::Flags) & LowerTriangularBit)
? LowerTriangular
: (int(Lhs::Flags) & UpperTriangularBit)
? UpperTriangular
: -1,
int StorageOrder = ei_is_part<Lhs>::value ? -1 // this is to solve ambiguous specializations
: int(Lhs::Flags) & (RowMajorBit|SparseBit)
>
struct ei_solve_triangular_selector;
// transform a Part xpr to a Flagged xpr
template<typename Lhs, unsigned int LhsMode, typename Rhs, int UpLo, int StorageOrder>
struct ei_solve_triangular_selector<Part<Lhs,LhsMode>,Rhs,UpLo,StorageOrder>
{
static void run(const Part<Lhs,LhsMode>& lhs, Rhs& other)
{
ei_solve_triangular_selector<Flagged<Lhs,LhsMode,0>,Rhs>::run(lhs._expression(), other);
}
};
// forward substitution, row-major
template<typename Lhs, typename Rhs, int UpLo>
struct ei_solve_triangular_selector<Lhs,Rhs,UpLo,RowMajor|IsDense>
{
typedef typename Rhs::Scalar Scalar;
static void run(const Lhs& lhs, Rhs& other)
{
const bool IsLowerTriangular = (UpLo==LowerTriangular);
const int size = lhs.cols();
/* We perform the inverse product per block of 4 rows such that we perfectly match
* our optimized matrix * vector product. blockyStart represents the number of rows
* we have process first using the non-block version.
*/
int blockyStart = (std::max(size-5,0)/4)*4;
if (IsLowerTriangular)
blockyStart = size - blockyStart;
else
blockyStart -= 1;
for(int c=0 ; c<other.cols() ; ++c)
{
// process first rows using the non block version
if(!(Lhs::Flags & UnitDiagBit))
{
if (IsLowerTriangular)
other.coeffRef(0,c) = other.coeff(0,c)/lhs.coeff(0, 0);
else
other.coeffRef(size-1,c) = other.coeff(size-1, c)/lhs.coeff(size-1, size-1);
}
for(int i=(IsLowerTriangular ? 1 : size-2); IsLowerTriangular ? i<blockyStart : i>blockyStart; i += (IsLowerTriangular ? 1 : -1) )
{
Scalar tmp = other.coeff(i,c)
- (IsLowerTriangular ? ((lhs.row(i).start(i)) * other.col(c).start(i)).coeff(0,0)
: ((lhs.row(i).end(size-i-1)) * other.col(c).end(size-i-1)).coeff(0,0));
if (Lhs::Flags & UnitDiagBit)
other.coeffRef(i,c) = tmp;
else
other.coeffRef(i,c) = tmp/lhs.coeff(i,i);
}
// now let's process the remaining rows 4 at once
for(int i=blockyStart; IsLowerTriangular ? i<size : i>0; )
{
int startBlock = i;
int endBlock = startBlock + (IsLowerTriangular ? 4 : -4);
/* Process the i cols times 4 rows block, and keep the result in a temporary vector */
// FIXME use fixed size block but take care to small fixed size matrices...
Matrix<Scalar,Dynamic,1> btmp(4);
if (IsLowerTriangular)
btmp = lhs.block(startBlock,0,4,i) * other.col(c).start(i);
else
btmp = lhs.block(i-3,i+1,4,size-1-i) * other.col(c).end(size-1-i);
/* Let's process the 4x4 sub-matrix as usual.
* btmp stores the diagonal coefficients used to update the remaining part of the result.
*/
{
Scalar tmp = other.coeff(startBlock,c)-btmp.coeff(IsLowerTriangular?0:3);
if (Lhs::Flags & UnitDiagBit)
other.coeffRef(i,c) = tmp;
else
other.coeffRef(i,c) = tmp/lhs.coeff(i,i);
}
i += IsLowerTriangular ? 1 : -1;
for (;IsLowerTriangular ? i<endBlock : i>endBlock; i += IsLowerTriangular ? 1 : -1)
{
int remainingSize = IsLowerTriangular ? i-startBlock : startBlock-i;
Scalar tmp = other.coeff(i,c)
- btmp.coeff(IsLowerTriangular ? remainingSize : 3-remainingSize)
- ( lhs.row(i).segment(IsLowerTriangular ? startBlock : i+1, remainingSize)
* other.col(c).segment(IsLowerTriangular ? startBlock : i+1, remainingSize)).coeff(0,0);
if (Lhs::Flags & UnitDiagBit)
other.coeffRef(i,c) = tmp;
else
other.coeffRef(i,c) = tmp/lhs.coeff(i,i);
}
}
}
}
};
// Implements the following configurations:
// - inv(LowerTriangular, ColMajor) * Column vector
// - inv(LowerTriangular,UnitDiag,ColMajor) * Column vector
// - inv(UpperTriangular, ColMajor) * Column vector
// - inv(UpperTriangular,UnitDiag,ColMajor) * Column vector
template<typename Lhs, typename Rhs, int UpLo>
struct ei_solve_triangular_selector<Lhs,Rhs,UpLo,ColMajor|IsDense>
{
typedef typename Rhs::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type Packet;
enum { PacketSize = ei_packet_traits<Scalar>::size };
static void run(const Lhs& lhs, Rhs& other)
{
static const bool IsLowerTriangular = (UpLo==LowerTriangular);
const int size = lhs.cols();
for(int c=0 ; c<other.cols() ; ++c)
{
/* let's perform the inverse product per block of 4 columns such that we perfectly match
* our optimized matrix * vector product. blockyEnd represents the number of rows
* we can process using the block version.
*/
int blockyEnd = (std::max(size-5,0)/4)*4;
if (!IsLowerTriangular)
blockyEnd = size-1 - blockyEnd;
for(int i=IsLowerTriangular ? 0 : size-1; IsLowerTriangular ? i<blockyEnd : i>blockyEnd;)
{
/* Let's process the 4x4 sub-matrix as usual.
* btmp stores the diagonal coefficients used to update the remaining part of the result.
*/
int startBlock = i;
int endBlock = startBlock + (IsLowerTriangular ? 4 : -4);
Matrix<Scalar,4,1> btmp;
for (;IsLowerTriangular ? i<endBlock : i>endBlock;
i += IsLowerTriangular ? 1 : -1)
{
if(!(Lhs::Flags & UnitDiagBit))
other.coeffRef(i,c) /= lhs.coeff(i,i);
int remainingSize = IsLowerTriangular ? endBlock-i-1 : i-endBlock-1;
if (remainingSize>0)
other.col(c).segment((IsLowerTriangular ? i : endBlock) + 1, remainingSize) -=
other.coeffRef(i,c)
* Block<Lhs,Dynamic,1>(lhs, (IsLowerTriangular ? i : endBlock) + 1, i, remainingSize, 1);
btmp.coeffRef(IsLowerTriangular ? i-startBlock : remainingSize) = -other.coeffRef(i,c);
}
/* Now we can efficiently update the remaining part of the result as a matrix * vector product.
* NOTE in order to reduce both compilation time and binary size, let's directly call
* the fast product implementation. It is equivalent to the following code:
* other.col(c).end(size-endBlock) += (lhs.block(endBlock, startBlock, size-endBlock, endBlock-startBlock)
* * other.col(c).block(startBlock,endBlock-startBlock)).lazy();
*/
// FIXME this is cool but what about conjugate/adjoint expressions ? do we want to evaluate them ?
// this is a more general problem though.
ei_cache_friendly_product_colmajor_times_vector(
IsLowerTriangular ? size-endBlock : endBlock+1,
&(lhs.const_cast_derived().coeffRef(IsLowerTriangular ? endBlock : 0, IsLowerTriangular ? startBlock : endBlock+1)),
lhs.stride(),
btmp, &(other.coeffRef(IsLowerTriangular ? endBlock : 0, c)));
// if (IsLowerTriangular)
// other.col(c).end(size-endBlock) += (lhs.block(endBlock, startBlock, size-endBlock, endBlock-startBlock)
// * other.col(c).block(startBlock,endBlock-startBlock)).lazy();
// else
// other.col(c).end(size-endBlock) += (lhs.block(endBlock, startBlock, size-endBlock, endBlock-startBlock)
// * other.col(c).block(startBlock,endBlock-startBlock)).lazy();
}
/* Now we have to process the remaining part as usual */
int i;
for(i=blockyEnd; IsLowerTriangular ? i<size-1 : i>0; i += (IsLowerTriangular ? 1 : -1) )
{
if(!(Lhs::Flags & UnitDiagBit))
other.coeffRef(i,c) /= lhs.coeff(i,i);
/* NOTE we cannot use lhs.col(i).end(size-i-1) because Part::coeffRef gets called by .col() to
* get the address of the start of the row
*/
if(IsLowerTriangular)
other.col(c).end(size-i-1) -= other.coeffRef(i,c) * Block<Lhs,Dynamic,1>(lhs, i+1,i, size-i-1,1);
else
other.col(c).start(i) -= other.coeffRef(i,c) * Block<Lhs,Dynamic,1>(lhs, 0,i, i, 1);
}
if(!(Lhs::Flags & UnitDiagBit))
other.coeffRef(i,c) /= lhs.coeff(i,i);
}
}
};
/** "in-place" version of MatrixBase::solveTriangular() where the result is written in \a other
*
* \nonstableyet
*
* The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.
* This function will const_cast it, so constness isn't honored here.
*
* See MatrixBase:solveTriangular() for the details.
*/
template<typename Derived>
template<typename OtherDerived>
void MatrixBase<Derived>::solveTriangularInPlace(const MatrixBase<OtherDerived>& _other) const
{
MatrixBase<OtherDerived>& other = _other.const_cast_derived();
ei_assert(derived().cols() == derived().rows());
ei_assert(derived().cols() == other.rows());
ei_assert(!(Flags & ZeroDiagBit));
ei_assert(Flags & (UpperTriangularBit|LowerTriangularBit));
enum { copy = ei_traits<OtherDerived>::Flags & RowMajorBit };
typedef typename ei_meta_if<copy,
typename ei_plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::ret OtherCopy;
OtherCopy otherCopy(other.derived());
ei_solve_triangular_selector<Derived, typename ei_unref<OtherCopy>::type>::run(derived(), otherCopy);
if (copy)
other = otherCopy;
}
/** \returns the product of the inverse of \c *this with \a other, \a *this being triangular.
*
* \nonstableyet
*
* This function computes the inverse-matrix matrix product inverse(\c *this) * \a other.
* The matrix \c *this must be triangular and invertible (i.e., all the coefficients of the
* diagonal must be non zero). It works as a forward (resp. backward) substitution if \c *this
* is an upper (resp. lower) triangular matrix.
*
* It is required that \c *this be marked as either an upper or a lower triangular matrix, which
* can be done by marked(), and that is automatically the case with expressions such as those returned
* by extract().
*
* \addexample SolveTriangular \label How to solve a triangular system (aka. how to multiply the inverse of a triangular matrix by another one)
*
* Example: \include MatrixBase_marked.cpp
* Output: \verbinclude MatrixBase_marked.out
*
* This function is essentially a wrapper to the faster solveTriangularInPlace() function creating
* a temporary copy of \a other, calling solveTriangularInPlace() on the copy and returning it.
* Therefore, if \a other is not needed anymore, it is quite faster to call solveTriangularInPlace()
* instead of solveTriangular().
*
* For users coming from BLAS, this function (and more specifically solveTriangularInPlace()) offer
* all the operations supported by the \c *TRSV and \c *TRSM BLAS routines.
*
* \b Tips: to perform a \em "right-inverse-multiply" you can simply transpose the operation, e.g.:
* \code
* M * T^1 <=> T.transpose().solveTriangularInPlace(M.transpose());
* \endcode
*
* \sa solveTriangularInPlace(), marked(), extract()
*/
template<typename Derived>
template<typename OtherDerived>
typename ei_plain_matrix_type_column_major<OtherDerived>::type
MatrixBase<Derived>::solveTriangular(const MatrixBase<OtherDerived>& other) const
{
typename ei_plain_matrix_type_column_major<OtherDerived>::type res(other);
solveTriangularInPlace(res);
return res;
}
#endif // EIGEN_SOLVETRIANGULAR_H

271
extern/Eigen2/Eigen/src/Core/Sum.h vendored Normal file
View File

@@ -0,0 +1,271 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_SUM_H
#define EIGEN_SUM_H
/***************************************************************************
* Part 1 : the logic deciding a strategy for vectorization and unrolling
***************************************************************************/
template<typename Derived>
struct ei_sum_traits
{
private:
enum {
PacketSize = ei_packet_traits<typename Derived::Scalar>::size
};
public:
enum {
Vectorization = (int(Derived::Flags)&ActualPacketAccessBit)
&& (int(Derived::Flags)&LinearAccessBit)
? LinearVectorization
: NoVectorization
};
private:
enum {
Cost = Derived::SizeAtCompileTime * Derived::CoeffReadCost
+ (Derived::SizeAtCompileTime-1) * NumTraits<typename Derived::Scalar>::AddCost,
UnrollingLimit = EIGEN_UNROLLING_LIMIT * (int(Vectorization) == int(NoVectorization) ? 1 : int(PacketSize))
};
public:
enum {
Unrolling = Cost <= UnrollingLimit
? CompleteUnrolling
: NoUnrolling
};
};
/***************************************************************************
* Part 2 : unrollers
***************************************************************************/
/*** no vectorization ***/
template<typename Derived, int Start, int Length>
struct ei_sum_novec_unroller
{
enum {
HalfLength = Length/2
};
typedef typename Derived::Scalar Scalar;
inline static Scalar run(const Derived &mat)
{
return ei_sum_novec_unroller<Derived, Start, HalfLength>::run(mat)
+ ei_sum_novec_unroller<Derived, Start+HalfLength, Length-HalfLength>::run(mat);
}
};
template<typename Derived, int Start>
struct ei_sum_novec_unroller<Derived, Start, 1>
{
enum {
col = Start / Derived::RowsAtCompileTime,
row = Start % Derived::RowsAtCompileTime
};
typedef typename Derived::Scalar Scalar;
inline static Scalar run(const Derived &mat)
{
return mat.coeff(row, col);
}
};
/*** vectorization ***/
template<typename Derived, int Start, int Length>
struct ei_sum_vec_unroller
{
enum {
PacketSize = ei_packet_traits<typename Derived::Scalar>::size,
HalfLength = Length/2
};
typedef typename Derived::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
inline static PacketScalar run(const Derived &mat)
{
return ei_padd(
ei_sum_vec_unroller<Derived, Start, HalfLength>::run(mat),
ei_sum_vec_unroller<Derived, Start+HalfLength, Length-HalfLength>::run(mat) );
}
};
template<typename Derived, int Start>
struct ei_sum_vec_unroller<Derived, Start, 1>
{
enum {
index = Start * ei_packet_traits<typename Derived::Scalar>::size,
row = int(Derived::Flags)&RowMajorBit
? index / int(Derived::ColsAtCompileTime)
: index % Derived::RowsAtCompileTime,
col = int(Derived::Flags)&RowMajorBit
? index % int(Derived::ColsAtCompileTime)
: index / Derived::RowsAtCompileTime,
alignment = (Derived::Flags & AlignedBit) ? Aligned : Unaligned
};
typedef typename Derived::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
inline static PacketScalar run(const Derived &mat)
{
return mat.template packet<alignment>(row, col);
}
};
/***************************************************************************
* Part 3 : implementation of all cases
***************************************************************************/
template<typename Derived,
int Vectorization = ei_sum_traits<Derived>::Vectorization,
int Unrolling = ei_sum_traits<Derived>::Unrolling
>
struct ei_sum_impl;
template<typename Derived>
struct ei_sum_impl<Derived, NoVectorization, NoUnrolling>
{
typedef typename Derived::Scalar Scalar;
static Scalar run(const Derived& mat)
{
ei_assert(mat.rows()>0 && mat.cols()>0 && "you are using a non initialized matrix");
Scalar res;
res = mat.coeff(0, 0);
for(int i = 1; i < mat.rows(); ++i)
res += mat.coeff(i, 0);
for(int j = 1; j < mat.cols(); ++j)
for(int i = 0; i < mat.rows(); ++i)
res += mat.coeff(i, j);
return res;
}
};
template<typename Derived>
struct ei_sum_impl<Derived, NoVectorization, CompleteUnrolling>
: public ei_sum_novec_unroller<Derived, 0, Derived::SizeAtCompileTime>
{};
template<typename Derived>
struct ei_sum_impl<Derived, LinearVectorization, NoUnrolling>
{
typedef typename Derived::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
static Scalar run(const Derived& mat)
{
const int size = mat.size();
const int packetSize = ei_packet_traits<Scalar>::size;
const int alignedStart = (Derived::Flags & AlignedBit)
|| !(Derived::Flags & DirectAccessBit)
? 0
: ei_alignmentOffset(&mat.const_cast_derived().coeffRef(0), size);
enum {
alignment = (Derived::Flags & DirectAccessBit) || (Derived::Flags & AlignedBit)
? Aligned : Unaligned
};
const int alignedSize = ((size-alignedStart)/packetSize)*packetSize;
const int alignedEnd = alignedStart + alignedSize;
Scalar res;
if(alignedSize)
{
PacketScalar packet_res = mat.template packet<alignment>(alignedStart);
for(int index = alignedStart + packetSize; index < alignedEnd; index += packetSize)
packet_res = ei_padd(packet_res, mat.template packet<alignment>(index));
res = ei_predux(packet_res);
}
else // too small to vectorize anything.
// since this is dynamic-size hence inefficient anyway for such small sizes, don't try to optimize.
{
res = Scalar(0);
}
for(int index = 0; index < alignedStart; ++index)
res += mat.coeff(index);
for(int index = alignedEnd; index < size; ++index)
res += mat.coeff(index);
return res;
}
};
template<typename Derived>
struct ei_sum_impl<Derived, LinearVectorization, CompleteUnrolling>
{
typedef typename Derived::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
enum {
PacketSize = ei_packet_traits<Scalar>::size,
Size = Derived::SizeAtCompileTime,
VectorizationSize = (Size / PacketSize) * PacketSize
};
static Scalar run(const Derived& mat)
{
Scalar res = ei_predux(ei_sum_vec_unroller<Derived, 0, Size / PacketSize>::run(mat));
if (VectorizationSize != Size)
res += ei_sum_novec_unroller<Derived, VectorizationSize, Size-VectorizationSize>::run(mat);
return res;
}
};
/***************************************************************************
* Part 4 : implementation of MatrixBase methods
***************************************************************************/
/** \returns the sum of all coefficients of *this
*
* \sa trace()
*/
template<typename Derived>
inline typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::sum() const
{
return ei_sum_impl<Derived>::run(derived());
}
/** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal.
*
* \c *this can be any matrix, not necessarily square.
*
* \sa diagonal(), sum()
*/
template<typename Derived>
inline typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::trace() const
{
return diagonal().sum();
}
#endif // EIGEN_SUM_H

145
extern/Eigen2/Eigen/src/Core/Swap.h vendored Normal file
View File

@@ -0,0 +1,145 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_SWAP_H
#define EIGEN_SWAP_H
/** \class SwapWrapper
*
* \internal
*
* \brief Internal helper class for swapping two expressions
*/
template<typename ExpressionType>
struct ei_traits<SwapWrapper<ExpressionType> >
{
typedef typename ExpressionType::Scalar Scalar;
enum {
RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
Flags = ExpressionType::Flags,
CoeffReadCost = ExpressionType::CoeffReadCost
};
};
template<typename ExpressionType> class SwapWrapper
: public MatrixBase<SwapWrapper<ExpressionType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(SwapWrapper)
typedef typename ei_packet_traits<Scalar>::type Packet;
inline SwapWrapper(ExpressionType& xpr) : m_expression(xpr) {}
inline int rows() const { return m_expression.rows(); }
inline int cols() const { return m_expression.cols(); }
inline int stride() const { return m_expression.stride(); }
inline Scalar& coeffRef(int row, int col)
{
return m_expression.const_cast_derived().coeffRef(row, col);
}
inline Scalar& coeffRef(int index)
{
return m_expression.const_cast_derived().coeffRef(index);
}
template<typename OtherDerived>
void copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other)
{
OtherDerived& _other = other.const_cast_derived();
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
Scalar tmp = m_expression.coeff(row, col);
m_expression.coeffRef(row, col) = _other.coeff(row, col);
_other.coeffRef(row, col) = tmp;
}
template<typename OtherDerived>
void copyCoeff(int index, const MatrixBase<OtherDerived>& other)
{
OtherDerived& _other = other.const_cast_derived();
ei_internal_assert(index >= 0 && index < m_expression.size());
Scalar tmp = m_expression.coeff(index);
m_expression.coeffRef(index) = _other.coeff(index);
_other.coeffRef(index) = tmp;
}
template<typename OtherDerived, int StoreMode, int LoadMode>
void copyPacket(int row, int col, const MatrixBase<OtherDerived>& other)
{
OtherDerived& _other = other.const_cast_derived();
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
Packet tmp = m_expression.template packet<StoreMode>(row, col);
m_expression.template writePacket<StoreMode>(row, col,
_other.template packet<LoadMode>(row, col)
);
_other.template writePacket<LoadMode>(row, col, tmp);
}
template<typename OtherDerived, int StoreMode, int LoadMode>
void copyPacket(int index, const MatrixBase<OtherDerived>& other)
{
OtherDerived& _other = other.const_cast_derived();
ei_internal_assert(index >= 0 && index < m_expression.size());
Packet tmp = m_expression.template packet<StoreMode>(index);
m_expression.template writePacket<StoreMode>(index,
_other.template packet<LoadMode>(index)
);
_other.template writePacket<LoadMode>(index, tmp);
}
protected:
ExpressionType& m_expression;
private:
SwapWrapper& operator=(const SwapWrapper&);
};
/** swaps *this with the expression \a other.
*
* \note \a other is only marked for internal reasons, but of course
* it gets const-casted. One reason is that one will often call swap
* on temporary objects (hence non-const references are forbidden).
* Another reason is that lazyAssign takes a const argument anyway.
*/
template<typename Derived>
template<typename OtherDerived>
void MatrixBase<Derived>::swap(const MatrixBase<OtherDerived>& other)
{
(SwapWrapper<Derived>(derived())).lazyAssign(other);
}
#endif // EIGEN_SWAP_H

228
extern/Eigen2/Eigen/src/Core/Transpose.h vendored Normal file
View File

@@ -0,0 +1,228 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_TRANSPOSE_H
#define EIGEN_TRANSPOSE_H
/** \class Transpose
*
* \brief Expression of the transpose of a matrix
*
* \param MatrixType the type of the object of which we are taking the transpose
*
* This class represents an expression of the transpose of a matrix.
* It is the return type of MatrixBase::transpose() and MatrixBase::adjoint()
* and most of the time this is the only way it is used.
*
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
*/
template<typename MatrixType>
struct ei_traits<Transpose<MatrixType> >
{
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
Flags = ((int(_MatrixTypeNested::Flags) ^ RowMajorBit)
& ~(LowerTriangularBit | UpperTriangularBit))
| (int(_MatrixTypeNested::Flags)&UpperTriangularBit ? LowerTriangularBit : 0)
| (int(_MatrixTypeNested::Flags)&LowerTriangularBit ? UpperTriangularBit : 0),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
};
};
template<typename MatrixType> class Transpose
: public MatrixBase<Transpose<MatrixType> >
{
public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose)
inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
inline int rows() const { return m_matrix.cols(); }
inline int cols() const { return m_matrix.rows(); }
inline int nonZeros() const { return m_matrix.nonZeros(); }
inline int stride(void) const { return m_matrix.stride(); }
inline Scalar& coeffRef(int row, int col)
{
return m_matrix.const_cast_derived().coeffRef(col, row);
}
inline const Scalar coeff(int row, int col) const
{
return m_matrix.coeff(col, row);
}
inline const Scalar coeff(int index) const
{
return m_matrix.coeff(index);
}
inline Scalar& coeffRef(int index)
{
return m_matrix.const_cast_derived().coeffRef(index);
}
template<int LoadMode>
inline const PacketScalar packet(int row, int col) const
{
return m_matrix.template packet<LoadMode>(col, row);
}
template<int LoadMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<LoadMode>(col, row, x);
}
template<int LoadMode>
inline const PacketScalar packet(int index) const
{
return m_matrix.template packet<LoadMode>(index);
}
template<int LoadMode>
inline void writePacket(int index, const PacketScalar& x)
{
m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
}
protected:
const typename MatrixType::Nested m_matrix;
};
/** \returns an expression of the transpose of *this.
*
* Example: \include MatrixBase_transpose.cpp
* Output: \verbinclude MatrixBase_transpose.out
*
* \warning If you want to replace a matrix by its own transpose, do \b NOT do this:
* \code
* m = m.transpose(); // bug!!! caused by aliasing effect
* \endcode
* Instead, use the transposeInPlace() method:
* \code
* m.transposeInPlace();
* \endcode
* which gives Eigen good opportunities for optimization, or alternatively you can also do:
* \code
* m = m.transpose().eval();
* \endcode
*
* \sa transposeInPlace(), adjoint() */
template<typename Derived>
inline Transpose<Derived>
MatrixBase<Derived>::transpose()
{
return derived();
}
/** This is the const version of transpose().
*
* Make sure you read the warning for transpose() !
*
* \sa transposeInPlace(), adjoint() */
template<typename Derived>
inline const Transpose<Derived>
MatrixBase<Derived>::transpose() const
{
return derived();
}
/** \returns an expression of the adjoint (i.e. conjugate transpose) of *this.
*
* Example: \include MatrixBase_adjoint.cpp
* Output: \verbinclude MatrixBase_adjoint.out
*
* \warning If you want to replace a matrix by its own adjoint, do \b NOT do this:
* \code
* m = m.adjoint(); // bug!!! caused by aliasing effect
* \endcode
* Instead, do:
* \code
* m = m.adjoint().eval();
* \endcode
*
* \sa transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op */
template<typename Derived>
inline const typename MatrixBase<Derived>::AdjointReturnType
MatrixBase<Derived>::adjoint() const
{
return conjugate().nestByValue();
}
/***************************************************************************
* "in place" transpose implementation
***************************************************************************/
template<typename MatrixType,
bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=Dynamic>
struct ei_inplace_transpose_selector;
template<typename MatrixType>
struct ei_inplace_transpose_selector<MatrixType,true> { // square matrix
static void run(MatrixType& m) {
m.template part<StrictlyUpperTriangular>().swap(m.transpose());
}
};
template<typename MatrixType>
struct ei_inplace_transpose_selector<MatrixType,false> { // non square matrix
static void run(MatrixType& m) {
if (m.rows()==m.cols())
m.template part<StrictlyUpperTriangular>().swap(m.transpose());
else
m = m.transpose().eval();
}
};
/** This is the "in place" version of transpose: it transposes \c *this.
*
* In most cases it is probably better to simply use the transposed expression
* of a matrix. However, when transposing the matrix data itself is really needed,
* then this "in-place" version is probably the right choice because it provides
* the following additional features:
* - less error prone: doing the same operation with .transpose() requires special care:
* \code m = m.transpose().eval(); \endcode
* - no temporary object is created (currently only for squared matrices)
* - it allows future optimizations (cache friendliness, etc.)
*
* \note if the matrix is not square, then \c *this must be a resizable matrix.
*
* \sa transpose(), adjoint() */
template<typename Derived>
inline void MatrixBase<Derived>::transposeInPlace()
{
ei_inplace_transpose_selector<Derived>::run(derived());
}
#endif // EIGEN_TRANSPOSE_H

228
extern/Eigen2/Eigen/src/Core/Visitor.h vendored Normal file
View File

@@ -0,0 +1,228 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_VISITOR_H
#define EIGEN_VISITOR_H
template<typename Visitor, typename Derived, int UnrollCount>
struct ei_visitor_impl
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
row = (UnrollCount-1) % Derived::RowsAtCompileTime
};
inline static void run(const Derived &mat, Visitor& visitor)
{
ei_visitor_impl<Visitor, Derived, UnrollCount-1>::run(mat, visitor);
visitor(mat.coeff(row, col), row, col);
}
};
template<typename Visitor, typename Derived>
struct ei_visitor_impl<Visitor, Derived, 1>
{
inline static void run(const Derived &mat, Visitor& visitor)
{
return visitor.init(mat.coeff(0, 0), 0, 0);
}
};
template<typename Visitor, typename Derived>
struct ei_visitor_impl<Visitor, Derived, Dynamic>
{
inline static void run(const Derived& mat, Visitor& visitor)
{
visitor.init(mat.coeff(0,0), 0, 0);
for(int i = 1; i < mat.rows(); ++i)
visitor(mat.coeff(i, 0), i, 0);
for(int j = 1; j < mat.cols(); ++j)
for(int i = 0; i < mat.rows(); ++i)
visitor(mat.coeff(i, j), i, j);
}
};
/** Applies the visitor \a visitor to the whole coefficients of the matrix or vector.
*
* The template parameter \a Visitor is the type of the visitor and provides the following interface:
* \code
* struct MyVisitor {
* // called for the first coefficient
* void init(const Scalar& value, int i, int j);
* // called for all other coefficients
* void operator() (const Scalar& value, int i, int j);
* };
* \endcode
*
* \note compared to one or two \em for \em loops, visitors offer automatic
* unrolling for small fixed size matrix.
*
* \sa minCoeff(int*,int*), maxCoeff(int*,int*), MatrixBase::redux()
*/
template<typename Derived>
template<typename Visitor>
void MatrixBase<Derived>::visit(Visitor& visitor) const
{
const bool unroll = SizeAtCompileTime * CoeffReadCost
+ (SizeAtCompileTime-1) * ei_functor_traits<Visitor>::Cost
<= EIGEN_UNROLLING_LIMIT;
return ei_visitor_impl<Visitor, Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived(), visitor);
}
/** \internal
* \brief Base class to implement min and max visitors
*/
template <typename Scalar>
struct ei_coeff_visitor
{
int row, col;
Scalar res;
inline void init(const Scalar& value, int i, int j)
{
res = value;
row = i;
col = j;
}
};
/** \internal
* \brief Visitor computing the min coefficient with its value and coordinates
*
* \sa MatrixBase::minCoeff(int*, int*)
*/
template <typename Scalar>
struct ei_min_coeff_visitor : ei_coeff_visitor<Scalar>
{
void operator() (const Scalar& value, int i, int j)
{
if(value < this->res)
{
this->res = value;
this->row = i;
this->col = j;
}
}
};
template<typename Scalar>
struct ei_functor_traits<ei_min_coeff_visitor<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost
};
};
/** \internal
* \brief Visitor computing the max coefficient with its value and coordinates
*
* \sa MatrixBase::maxCoeff(int*, int*)
*/
template <typename Scalar>
struct ei_max_coeff_visitor : ei_coeff_visitor<Scalar>
{
void operator() (const Scalar& value, int i, int j)
{
if(value > this->res)
{
this->res = value;
this->row = i;
this->col = j;
}
}
};
template<typename Scalar>
struct ei_functor_traits<ei_max_coeff_visitor<Scalar> > {
enum {
Cost = NumTraits<Scalar>::AddCost
};
};
/** \returns the minimum of all coefficients of *this
* and puts in *row and *col its location.
*
* \sa MatrixBase::minCoeff(int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::minCoeff(int* row, int* col) const
{
ei_min_coeff_visitor<Scalar> minVisitor;
this->visit(minVisitor);
*row = minVisitor.row;
if (col) *col = minVisitor.col;
return minVisitor.res;
}
/** \returns the minimum of all coefficients of *this
* and puts in *index its location.
*
* \sa MatrixBase::minCoeff(int*,int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::minCoeff(int* index) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_min_coeff_visitor<Scalar> minVisitor;
this->visit(minVisitor);
*index = (RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row;
return minVisitor.res;
}
/** \returns the maximum of all coefficients of *this
* and puts in *row and *col its location.
*
* \sa MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::maxCoeff(int* row, int* col) const
{
ei_max_coeff_visitor<Scalar> maxVisitor;
this->visit(maxVisitor);
*row = maxVisitor.row;
if (col) *col = maxVisitor.col;
return maxVisitor.res;
}
/** \returns the maximum of all coefficients of *this
* and puts in *index its location.
*
* \sa MatrixBase::maxCoeff(int*,int*), MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
MatrixBase<Derived>::maxCoeff(int* index) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_max_coeff_visitor<Scalar> maxVisitor;
this->visit(maxVisitor);
*index = (RowsAtCompileTime==1) ? maxVisitor.col : maxVisitor.row;
return maxVisitor.res;
}
#endif // EIGEN_VISITOR_H

View File

@@ -0,0 +1,354 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Konstantinos Margaritis <markos@codex.gr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PACKET_MATH_ALTIVEC_H
#define EIGEN_PACKET_MATH_ALTIVEC_H
#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4
#endif
typedef __vector float v4f;
typedef __vector int v4i;
typedef __vector unsigned int v4ui;
typedef __vector __bool int v4bi;
// We don't want to write the same code all the time, but we need to reuse the constants
// and it doesn't really work to declare them global, so we define macros instead
#define USE_CONST_v0i const v4i v0i = vec_splat_s32(0)
#define USE_CONST_v1i const v4i v1i = vec_splat_s32(1)
#define USE_CONST_v16i_ const v4i v16i_ = vec_splat_s32(-16)
#define USE_CONST_v0f USE_CONST_v0i; const v4f v0f = (v4f) v0i
#define USE_CONST_v1f USE_CONST_v1i; const v4f v1f = vec_ctf(v1i, 0)
#define USE_CONST_v1i_ const v4ui v1i_ = vec_splat_u32(-1)
#define USE_CONST_v0f_ USE_CONST_v1i_; const v4f v0f_ = (v4f) vec_sl(v1i_, v1i_)
template<> struct ei_packet_traits<float> { typedef v4f type; enum {size=4}; };
template<> struct ei_packet_traits<int> { typedef v4i type; enum {size=4}; };
template<> struct ei_unpacket_traits<v4f> { typedef float type; enum {size=4}; };
template<> struct ei_unpacket_traits<v4i> { typedef int type; enum {size=4}; };
inline std::ostream & operator <<(std::ostream & s, const v4f & v)
{
union {
v4f v;
float n[4];
} vt;
vt.v = v;
s << vt.n[0] << ", " << vt.n[1] << ", " << vt.n[2] << ", " << vt.n[3];
return s;
}
inline std::ostream & operator <<(std::ostream & s, const v4i & v)
{
union {
v4i v;
int n[4];
} vt;
vt.v = v;
s << vt.n[0] << ", " << vt.n[1] << ", " << vt.n[2] << ", " << vt.n[3];
return s;
}
inline std::ostream & operator <<(std::ostream & s, const v4ui & v)
{
union {
v4ui v;
unsigned int n[4];
} vt;
vt.v = v;
s << vt.n[0] << ", " << vt.n[1] << ", " << vt.n[2] << ", " << vt.n[3];
return s;
}
inline std::ostream & operator <<(std::ostream & s, const v4bi & v)
{
union {
__vector __bool int v;
unsigned int n[4];
} vt;
vt.v = v;
s << vt.n[0] << ", " << vt.n[1] << ", " << vt.n[2] << ", " << vt.n[3];
return s;
}
template<> inline v4f ei_padd(const v4f& a, const v4f& b) { return vec_add(a,b); }
template<> inline v4i ei_padd(const v4i& a, const v4i& b) { return vec_add(a,b); }
template<> inline v4f ei_psub(const v4f& a, const v4f& b) { return vec_sub(a,b); }
template<> inline v4i ei_psub(const v4i& a, const v4i& b) { return vec_sub(a,b); }
template<> inline v4f ei_pmul(const v4f& a, const v4f& b) { USE_CONST_v0f; return vec_madd(a,b, v0f); }
template<> inline v4i ei_pmul(const v4i& a, const v4i& b)
{
// Detailed in: http://freevec.org/content/32bit_signed_integer_multiplication_altivec
//Set up constants, variables
v4i a1, b1, bswap, low_prod, high_prod, prod, prod_, v1sel;
USE_CONST_v0i;
USE_CONST_v1i;
USE_CONST_v16i_;
// Get the absolute values
a1 = vec_abs(a);
b1 = vec_abs(b);
// Get the signs using xor
v4bi sgn = (v4bi) vec_cmplt(vec_xor(a, b), v0i);
// Do the multiplication for the asbolute values.
bswap = (v4i) vec_rl((v4ui) b1, (v4ui) v16i_ );
low_prod = vec_mulo((__vector short)a1, (__vector short)b1);
high_prod = vec_msum((__vector short)a1, (__vector short)bswap, v0i);
high_prod = (v4i) vec_sl((v4ui) high_prod, (v4ui) v16i_);
prod = vec_add( low_prod, high_prod );
// NOR the product and select only the negative elements according to the sign mask
prod_ = vec_nor(prod, prod);
prod_ = vec_sel(v0i, prod_, sgn);
// Add 1 to the result to get the negative numbers
v1sel = vec_sel(v0i, v1i, sgn);
prod_ = vec_add(prod_, v1sel);
// Merge the results back to the final vector.
prod = vec_sel(prod, prod_, sgn);
return prod;
}
template<> inline v4f ei_pdiv(const v4f& a, const v4f& b) {
v4f t, y_0, y_1, res;
USE_CONST_v0f;
USE_CONST_v1f;
// Altivec does not offer a divide instruction, we have to do a reciprocal approximation
y_0 = vec_re(b);
// Do one Newton-Raphson iteration to get the needed accuracy
t = vec_nmsub(y_0, b, v1f);
y_1 = vec_madd(y_0, t, y_0);
res = vec_madd(a, y_1, v0f);
return res;
}
template<> inline v4f ei_pmadd(const v4f& a, const v4f& b, const v4f& c) { return vec_madd(a, b, c); }
template<> inline v4f ei_pmin(const v4f& a, const v4f& b) { return vec_min(a,b); }
template<> inline v4i ei_pmin(const v4i& a, const v4i& b) { return vec_min(a,b); }
template<> inline v4f ei_pmax(const v4f& a, const v4f& b) { return vec_max(a,b); }
template<> inline v4i ei_pmax(const v4i& a, const v4i& b) { return vec_max(a,b); }
template<> inline v4f ei_pload(const float* from) { return vec_ld(0, from); }
template<> inline v4i ei_pload(const int* from) { return vec_ld(0, from); }
template<> inline v4f ei_ploadu(const float* from)
{
// Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html
__vector unsigned char MSQ, LSQ;
__vector unsigned char mask;
MSQ = vec_ld(0, (unsigned char *)from); // most significant quadword
LSQ = vec_ld(15, (unsigned char *)from); // least significant quadword
mask = vec_lvsl(0, from); // create the permute mask
return (v4f) vec_perm(MSQ, LSQ, mask); // align the data
}
template<> inline v4i ei_ploadu(const int* from)
{
// Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html
__vector unsigned char MSQ, LSQ;
__vector unsigned char mask;
MSQ = vec_ld(0, (unsigned char *)from); // most significant quadword
LSQ = vec_ld(15, (unsigned char *)from); // least significant quadword
mask = vec_lvsl(0, from); // create the permute mask
return (v4i) vec_perm(MSQ, LSQ, mask); // align the data
}
template<> inline v4f ei_pset1(const float& from)
{
// Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html
float __attribute__(aligned(16)) af[4];
af[0] = from;
v4f vc = vec_ld(0, af);
vc = vec_splat(vc, 0);
return vc;
}
template<> inline v4i ei_pset1(const int& from)
{
int __attribute__(aligned(16)) ai[4];
ai[0] = from;
v4i vc = vec_ld(0, ai);
vc = vec_splat(vc, 0);
return vc;
}
template<> inline void ei_pstore(float* to, const v4f& from) { vec_st(from, 0, to); }
template<> inline void ei_pstore(int* to, const v4i& from) { vec_st(from, 0, to); }
template<> inline void ei_pstoreu(float* to, const v4f& from)
{
// Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html
// Warning: not thread safe!
__vector unsigned char MSQ, LSQ, edges;
__vector unsigned char edgeAlign, align;
MSQ = vec_ld(0, (unsigned char *)to); // most significant quadword
LSQ = vec_ld(15, (unsigned char *)to); // least significant quadword
edgeAlign = vec_lvsl(0, to); // permute map to extract edges
edges=vec_perm(LSQ,MSQ,edgeAlign); // extract the edges
align = vec_lvsr( 0, to ); // permute map to misalign data
MSQ = vec_perm(edges,(__vector unsigned char)from,align); // misalign the data (MSQ)
LSQ = vec_perm((__vector unsigned char)from,edges,align); // misalign the data (LSQ)
vec_st( LSQ, 15, (unsigned char *)to ); // Store the LSQ part first
vec_st( MSQ, 0, (unsigned char *)to ); // Store the MSQ part
}
template<> inline void ei_pstoreu(int* to , const v4i& from )
{
// Taken from http://developer.apple.com/hardwaredrivers/ve/alignment.html
// Warning: not thread safe!
__vector unsigned char MSQ, LSQ, edges;
__vector unsigned char edgeAlign, align;
MSQ = vec_ld(0, (unsigned char *)to); // most significant quadword
LSQ = vec_ld(15, (unsigned char *)to); // least significant quadword
edgeAlign = vec_lvsl(0, to); // permute map to extract edges
edges=vec_perm(LSQ,MSQ,edgeAlign); // extract the edges
align = vec_lvsr( 0, to ); // permute map to misalign data
MSQ = vec_perm(edges,(__vector unsigned char)from,align); // misalign the data (MSQ)
LSQ = vec_perm((__vector unsigned char)from,edges,align); // misalign the data (LSQ)
vec_st( LSQ, 15, (unsigned char *)to ); // Store the LSQ part first
vec_st( MSQ, 0, (unsigned char *)to ); // Store the MSQ part
}
template<> inline float ei_pfirst(const v4f& a)
{
float __attribute__(aligned(16)) af[4];
vec_st(a, 0, af);
return af[0];
}
template<> inline int ei_pfirst(const v4i& a)
{
int __attribute__(aligned(16)) ai[4];
vec_st(a, 0, ai);
return ai[0];
}
inline v4f ei_preduxp(const v4f* vecs)
{
v4f v[4], sum[4];
// It's easier and faster to transpose then add as columns
// Check: http://www.freevec.org/function/matrix_4x4_transpose_floats for explanation
// Do the transpose, first set of moves
v[0] = vec_mergeh(vecs[0], vecs[2]);
v[1] = vec_mergel(vecs[0], vecs[2]);
v[2] = vec_mergeh(vecs[1], vecs[3]);
v[3] = vec_mergel(vecs[1], vecs[3]);
// Get the resulting vectors
sum[0] = vec_mergeh(v[0], v[2]);
sum[1] = vec_mergel(v[0], v[2]);
sum[2] = vec_mergeh(v[1], v[3]);
sum[3] = vec_mergel(v[1], v[3]);
// Now do the summation:
// Lines 0+1
sum[0] = vec_add(sum[0], sum[1]);
// Lines 2+3
sum[1] = vec_add(sum[2], sum[3]);
// Add the results
sum[0] = vec_add(sum[0], sum[1]);
return sum[0];
}
inline float ei_predux(const v4f& a)
{
v4f b, sum;
b = (v4f)vec_sld(a, a, 8);
sum = vec_add(a, b);
b = (v4f)vec_sld(sum, sum, 4);
sum = vec_add(sum, b);
return ei_pfirst(sum);
}
inline v4i ei_preduxp(const v4i* vecs)
{
v4i v[4], sum[4];
// It's easier and faster to transpose then add as columns
// Check: http://www.freevec.org/function/matrix_4x4_transpose_floats for explanation
// Do the transpose, first set of moves
v[0] = vec_mergeh(vecs[0], vecs[2]);
v[1] = vec_mergel(vecs[0], vecs[2]);
v[2] = vec_mergeh(vecs[1], vecs[3]);
v[3] = vec_mergel(vecs[1], vecs[3]);
// Get the resulting vectors
sum[0] = vec_mergeh(v[0], v[2]);
sum[1] = vec_mergel(v[0], v[2]);
sum[2] = vec_mergeh(v[1], v[3]);
sum[3] = vec_mergel(v[1], v[3]);
// Now do the summation:
// Lines 0+1
sum[0] = vec_add(sum[0], sum[1]);
// Lines 2+3
sum[1] = vec_add(sum[2], sum[3]);
// Add the results
sum[0] = vec_add(sum[0], sum[1]);
return sum[0];
}
inline int ei_predux(const v4i& a)
{
USE_CONST_v0i;
v4i sum;
sum = vec_sums(a, v0i);
sum = vec_sld(sum, v0i, 12);
return ei_pfirst(sum);
}
template<int Offset>
struct ei_palign_impl<Offset, v4f>
{
inline static void run(v4f& first, const v4f& second)
{
first = vec_sld(first, second, Offset*4);
}
};
template<int Offset>
struct ei_palign_impl<Offset, v4i>
{
inline static void run(v4i& first, const v4i& second)
{
first = vec_sld(first, second, Offset*4);
}
};
#endif // EIGEN_PACKET_MATH_ALTIVEC_H

View File

@@ -0,0 +1,321 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PACKET_MATH_SSE_H
#define EIGEN_PACKET_MATH_SSE_H
#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 16
#endif
template<> struct ei_packet_traits<float> { typedef __m128 type; enum {size=4}; };
template<> struct ei_packet_traits<double> { typedef __m128d type; enum {size=2}; };
template<> struct ei_packet_traits<int> { typedef __m128i type; enum {size=4}; };
template<> struct ei_unpacket_traits<__m128> { typedef float type; enum {size=4}; };
template<> struct ei_unpacket_traits<__m128d> { typedef double type; enum {size=2}; };
template<> struct ei_unpacket_traits<__m128i> { typedef int type; enum {size=4}; };
template<> EIGEN_STRONG_INLINE __m128 ei_pset1<float>(const float& from) { return _mm_set1_ps(from); }
template<> EIGEN_STRONG_INLINE __m128d ei_pset1<double>(const double& from) { return _mm_set1_pd(from); }
template<> EIGEN_STRONG_INLINE __m128i ei_pset1<int>(const int& from) { return _mm_set1_epi32(from); }
template<> EIGEN_STRONG_INLINE __m128 ei_padd<__m128>(const __m128& a, const __m128& b) { return _mm_add_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_padd<__m128d>(const __m128d& a, const __m128d& b) { return _mm_add_pd(a,b); }
template<> EIGEN_STRONG_INLINE __m128i ei_padd<__m128i>(const __m128i& a, const __m128i& b) { return _mm_add_epi32(a,b); }
template<> EIGEN_STRONG_INLINE __m128 ei_psub<__m128>(const __m128& a, const __m128& b) { return _mm_sub_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_psub<__m128d>(const __m128d& a, const __m128d& b) { return _mm_sub_pd(a,b); }
template<> EIGEN_STRONG_INLINE __m128i ei_psub<__m128i>(const __m128i& a, const __m128i& b) { return _mm_sub_epi32(a,b); }
template<> EIGEN_STRONG_INLINE __m128 ei_pmul<__m128>(const __m128& a, const __m128& b) { return _mm_mul_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_pmul<__m128d>(const __m128d& a, const __m128d& b) { return _mm_mul_pd(a,b); }
template<> EIGEN_STRONG_INLINE __m128i ei_pmul<__m128i>(const __m128i& a, const __m128i& b)
{
return _mm_or_si128(
_mm_and_si128(
_mm_mul_epu32(a,b),
_mm_setr_epi32(0xffffffff,0,0xffffffff,0)),
_mm_slli_si128(
_mm_and_si128(
_mm_mul_epu32(_mm_srli_si128(a,4),_mm_srli_si128(b,4)),
_mm_setr_epi32(0xffffffff,0,0xffffffff,0)), 4));
}
template<> EIGEN_STRONG_INLINE __m128 ei_pdiv<__m128>(const __m128& a, const __m128& b) { return _mm_div_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_pdiv<__m128d>(const __m128d& a, const __m128d& b) { return _mm_div_pd(a,b); }
template<> EIGEN_STRONG_INLINE __m128i ei_pdiv<__m128i>(const __m128i& /*a*/, const __m128i& /*b*/)
{ ei_assert(false && "packet integer division are not supported by SSE");
__m128i dummy = ei_pset1<int>(0);
return dummy;
}
// for some weird raisons, it has to be overloaded for packet integer
template<> EIGEN_STRONG_INLINE __m128i ei_pmadd(const __m128i& a, const __m128i& b, const __m128i& c) { return ei_padd(ei_pmul(a,b), c); }
template<> EIGEN_STRONG_INLINE __m128 ei_pmin<__m128>(const __m128& a, const __m128& b) { return _mm_min_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_pmin<__m128d>(const __m128d& a, const __m128d& b) { return _mm_min_pd(a,b); }
// FIXME this vectorized min operator is likely to be slower than the standard one
template<> EIGEN_STRONG_INLINE __m128i ei_pmin<__m128i>(const __m128i& a, const __m128i& b)
{
__m128i mask = _mm_cmplt_epi32(a,b);
return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b));
}
template<> EIGEN_STRONG_INLINE __m128 ei_pmax<__m128>(const __m128& a, const __m128& b) { return _mm_max_ps(a,b); }
template<> EIGEN_STRONG_INLINE __m128d ei_pmax<__m128d>(const __m128d& a, const __m128d& b) { return _mm_max_pd(a,b); }
// FIXME this vectorized max operator is likely to be slower than the standard one
template<> EIGEN_STRONG_INLINE __m128i ei_pmax<__m128i>(const __m128i& a, const __m128i& b)
{
__m128i mask = _mm_cmpgt_epi32(a,b);
return _mm_or_si128(_mm_and_si128(mask,a),_mm_andnot_si128(mask,b));
}
template<> EIGEN_STRONG_INLINE __m128 ei_pload<float>(const float* from) { return _mm_load_ps(from); }
template<> EIGEN_STRONG_INLINE __m128d ei_pload<double>(const double* from) { return _mm_load_pd(from); }
template<> EIGEN_STRONG_INLINE __m128i ei_pload<int>(const int* from) { return _mm_load_si128(reinterpret_cast<const __m128i*>(from)); }
template<> EIGEN_STRONG_INLINE __m128 ei_ploadu<float>(const float* from) { return _mm_loadu_ps(from); }
// template<> EIGEN_STRONG_INLINE __m128 ei_ploadu(const float* from) {
// if (size_t(from)&0xF)
// return _mm_loadu_ps(from);
// else
// return _mm_loadu_ps(from);
// }
template<> EIGEN_STRONG_INLINE __m128d ei_ploadu<double>(const double* from) { return _mm_loadu_pd(from); }
template<> EIGEN_STRONG_INLINE __m128i ei_ploadu<int>(const int* from) { return _mm_loadu_si128(reinterpret_cast<const __m128i*>(from)); }
template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const __m128& from) { _mm_store_ps(to, from); }
template<> EIGEN_STRONG_INLINE void ei_pstore<double>(double* to, const __m128d& from) { _mm_store_pd(to, from); }
template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const __m128i& from) { _mm_store_si128(reinterpret_cast<__m128i*>(to), from); }
template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const __m128& from) { _mm_storeu_ps(to, from); }
template<> EIGEN_STRONG_INLINE void ei_pstoreu<double>(double* to, const __m128d& from) { _mm_storeu_pd(to, from); }
template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const __m128i& from) { _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from); }
#ifdef _MSC_VER
// this fix internal compilation error
template<> EIGEN_STRONG_INLINE float ei_pfirst<__m128>(const __m128& a) { float x = _mm_cvtss_f32(a); return x; }
template<> EIGEN_STRONG_INLINE double ei_pfirst<__m128d>(const __m128d& a) { double x = _mm_cvtsd_f64(a); return x; }
template<> EIGEN_STRONG_INLINE int ei_pfirst<__m128i>(const __m128i& a) { int x = _mm_cvtsi128_si32(a); return x; }
#else
template<> EIGEN_STRONG_INLINE float ei_pfirst<__m128>(const __m128& a) { return _mm_cvtss_f32(a); }
template<> EIGEN_STRONG_INLINE double ei_pfirst<__m128d>(const __m128d& a) { return _mm_cvtsd_f64(a); }
template<> EIGEN_STRONG_INLINE int ei_pfirst<__m128i>(const __m128i& a) { return _mm_cvtsi128_si32(a); }
#endif
#ifdef __SSE3__
// TODO implement SSE2 versions as well as integer versions
template<> EIGEN_STRONG_INLINE __m128 ei_preduxp<__m128>(const __m128* vecs)
{
return _mm_hadd_ps(_mm_hadd_ps(vecs[0], vecs[1]),_mm_hadd_ps(vecs[2], vecs[3]));
}
template<> EIGEN_STRONG_INLINE __m128d ei_preduxp<__m128d>(const __m128d* vecs)
{
return _mm_hadd_pd(vecs[0], vecs[1]);
}
// SSSE3 version:
// EIGEN_STRONG_INLINE __m128i ei_preduxp(const __m128i* vecs)
// {
// return _mm_hadd_epi32(_mm_hadd_epi32(vecs[0], vecs[1]),_mm_hadd_epi32(vecs[2], vecs[3]));
// }
template<> EIGEN_STRONG_INLINE float ei_predux<__m128>(const __m128& a)
{
__m128 tmp0 = _mm_hadd_ps(a,a);
return ei_pfirst(_mm_hadd_ps(tmp0, tmp0));
}
template<> EIGEN_STRONG_INLINE double ei_predux<__m128d>(const __m128d& a) { return ei_pfirst(_mm_hadd_pd(a, a)); }
// SSSE3 version:
// EIGEN_STRONG_INLINE float ei_predux(const __m128i& a)
// {
// __m128i tmp0 = _mm_hadd_epi32(a,a);
// return ei_pfirst(_mm_hadd_epi32(tmp0, tmp0));
// }
#else
// SSE2 versions
template<> EIGEN_STRONG_INLINE float ei_predux<__m128>(const __m128& a)
{
__m128 tmp = _mm_add_ps(a, _mm_movehl_ps(a,a));
return ei_pfirst(_mm_add_ss(tmp, _mm_shuffle_ps(tmp,tmp, 1)));
}
template<> EIGEN_STRONG_INLINE double ei_predux<__m128d>(const __m128d& a)
{
return ei_pfirst(_mm_add_sd(a, _mm_unpackhi_pd(a,a)));
}
template<> EIGEN_STRONG_INLINE __m128 ei_preduxp<__m128>(const __m128* vecs)
{
__m128 tmp0, tmp1, tmp2;
tmp0 = _mm_unpacklo_ps(vecs[0], vecs[1]);
tmp1 = _mm_unpackhi_ps(vecs[0], vecs[1]);
tmp2 = _mm_unpackhi_ps(vecs[2], vecs[3]);
tmp0 = _mm_add_ps(tmp0, tmp1);
tmp1 = _mm_unpacklo_ps(vecs[2], vecs[3]);
tmp1 = _mm_add_ps(tmp1, tmp2);
tmp2 = _mm_movehl_ps(tmp1, tmp0);
tmp0 = _mm_movelh_ps(tmp0, tmp1);
return _mm_add_ps(tmp0, tmp2);
}
template<> EIGEN_STRONG_INLINE __m128d ei_preduxp<__m128d>(const __m128d* vecs)
{
return _mm_add_pd(_mm_unpacklo_pd(vecs[0], vecs[1]), _mm_unpackhi_pd(vecs[0], vecs[1]));
}
#endif // SSE3
template<> EIGEN_STRONG_INLINE int ei_predux<__m128i>(const __m128i& a)
{
__m128i tmp = _mm_add_epi32(a, _mm_unpackhi_epi64(a,a));
return ei_pfirst(tmp) + ei_pfirst(_mm_shuffle_epi32(tmp, 1));
}
template<> EIGEN_STRONG_INLINE __m128i ei_preduxp<__m128i>(const __m128i* vecs)
{
__m128i tmp0, tmp1, tmp2;
tmp0 = _mm_unpacklo_epi32(vecs[0], vecs[1]);
tmp1 = _mm_unpackhi_epi32(vecs[0], vecs[1]);
tmp2 = _mm_unpackhi_epi32(vecs[2], vecs[3]);
tmp0 = _mm_add_epi32(tmp0, tmp1);
tmp1 = _mm_unpacklo_epi32(vecs[2], vecs[3]);
tmp1 = _mm_add_epi32(tmp1, tmp2);
tmp2 = _mm_unpacklo_epi64(tmp0, tmp1);
tmp0 = _mm_unpackhi_epi64(tmp0, tmp1);
return _mm_add_epi32(tmp0, tmp2);
}
#if (defined __GNUC__)
// template <> EIGEN_STRONG_INLINE __m128 ei_pmadd(const __m128& a, const __m128& b, const __m128& c)
// {
// __m128 res = b;
// asm("mulps %[a], %[b] \n\taddps %[c], %[b]" : [b] "+x" (res) : [a] "x" (a), [c] "x" (c));
// return res;
// }
// EIGEN_STRONG_INLINE __m128i _mm_alignr_epi8(const __m128i& a, const __m128i& b, const int i)
// {
// __m128i res = a;
// asm("palignr %[i], %[a], %[b] " : [b] "+x" (res) : [a] "x" (a), [i] "i" (i));
// return res;
// }
#endif
#ifdef __SSSE3__
// SSSE3 versions
template<int Offset>
struct ei_palign_impl<Offset,__m128>
{
EIGEN_STRONG_INLINE static void run(__m128& first, const __m128& second)
{
if (Offset!=0)
first = _mm_castsi128_ps(_mm_alignr_epi8(_mm_castps_si128(second), _mm_castps_si128(first), Offset*4));
}
};
template<int Offset>
struct ei_palign_impl<Offset,__m128i>
{
EIGEN_STRONG_INLINE static void run(__m128i& first, const __m128i& second)
{
if (Offset!=0)
first = _mm_alignr_epi8(second,first, Offset*4);
}
};
template<int Offset>
struct ei_palign_impl<Offset,__m128d>
{
EIGEN_STRONG_INLINE static void run(__m128d& first, const __m128d& second)
{
if (Offset==1)
first = _mm_castsi128_pd(_mm_alignr_epi8(_mm_castpd_si128(second), _mm_castpd_si128(first), 8));
}
};
#else
// SSE2 versions
template<int Offset>
struct ei_palign_impl<Offset,__m128>
{
EIGEN_STRONG_INLINE static void run(__m128& first, const __m128& second)
{
if (Offset==1)
{
first = _mm_move_ss(first,second);
first = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(first),0x39));
}
else if (Offset==2)
{
first = _mm_movehl_ps(first,first);
first = _mm_movelh_ps(first,second);
}
else if (Offset==3)
{
first = _mm_move_ss(first,second);
first = _mm_shuffle_ps(first,second,0x93);
}
}
};
template<int Offset>
struct ei_palign_impl<Offset,__m128i>
{
EIGEN_STRONG_INLINE static void run(__m128i& first, const __m128i& second)
{
if (Offset==1)
{
first = _mm_castps_si128(_mm_move_ss(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));
first = _mm_shuffle_epi32(first,0x39);
}
else if (Offset==2)
{
first = _mm_castps_si128(_mm_movehl_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(first)));
first = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));
}
else if (Offset==3)
{
first = _mm_castps_si128(_mm_move_ss(_mm_castsi128_ps(first),_mm_castsi128_ps(second)));
first = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(first),_mm_castsi128_ps(second),0x93));
}
}
};
template<int Offset>
struct ei_palign_impl<Offset,__m128d>
{
EIGEN_STRONG_INLINE static void run(__m128d& first, const __m128d& second)
{
if (Offset==1)
{
first = _mm_castps_pd(_mm_movehl_ps(_mm_castpd_ps(first),_mm_castpd_ps(first)));
first = _mm_castps_pd(_mm_movelh_ps(_mm_castpd_ps(first),_mm_castpd_ps(second)));
}
}
};
#endif
#define ei_vec4f_swizzle1(v,p,q,r,s) \
(_mm_castsi128_ps(_mm_shuffle_epi32( _mm_castps_si128(v), ((s)<<6|(r)<<4|(q)<<2|(p)))))
#endif // EIGEN_PACKET_MATH_SSE_H

View File

@@ -0,0 +1,254 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_CONSTANTS_H
#define EIGEN_CONSTANTS_H
/** This value means that a quantity is not known at compile-time, and that instead the value is
* stored in some runtime variable.
*
* Explanation for the choice of this value:
* - It should be positive and larger than any reasonable compile-time-fixed number of rows or columns.
* This allows to simplify many compile-time conditions throughout Eigen.
* - It should be smaller than the sqrt of INT_MAX. Indeed, we often multiply a number of rows with a number
* of columns in order to compute a number of coefficients. Even if we guard that with an "if" checking whether
* the values are Dynamic, we still get a compiler warning "integer overflow". So the only way to get around
* it would be a meta-selector. Doing this everywhere would reduce code readability and lenghten compilation times.
* Also, disabling compiler warnings for integer overflow, sounds like a bad idea.
*
* If you wish to port Eigen to a platform where sizeof(int)==2, it is perfectly possible to set Dynamic to, say, 100.
*/
const int Dynamic = 10000;
/** This value means +Infinity; it is currently used only as the p parameter to MatrixBase::lpNorm<int>().
* The value Infinity there means the L-infinity norm.
*/
const int Infinity = -1;
/** \defgroup flags flags
* \ingroup Core_Module
*
* These are the possible bits which can be OR'ed to constitute the flags of a matrix or
* expression.
*
* It is important to note that these flags are a purely compile-time notion. They are a compile-time property of
* an expression type, implemented as enum's. They are not stored in memory at runtime, and they do not incur any
* runtime overhead.
*
* \sa MatrixBase::Flags
*/
/** \ingroup flags
*
* for a matrix, this means that the storage order is row-major.
* If this bit is not set, the storage order is column-major.
* For an expression, this determines the storage order of
* the matrix created by evaluation of that expression. */
const unsigned int RowMajorBit = 0x1;
/** \ingroup flags
*
* means the expression should be evaluated by the calling expression */
const unsigned int EvalBeforeNestingBit = 0x2;
/** \ingroup flags
*
* means the expression should be evaluated before any assignement */
const unsigned int EvalBeforeAssigningBit = 0x4;
/** \ingroup flags
*
* Short version: means the expression might be vectorized
*
* Long version: means that the coefficients can be handled by packets
* and start at a memory location whose alignment meets the requirements
* of the present CPU architecture for optimized packet access. In the fixed-size
* case, there is the additional condition that the total size of the coefficients
* array is a multiple of the packet size, so that it is possible to access all the
* coefficients by packets. In the dynamic-size case, there is no such condition
* on the total size, so it might not be possible to access the few last coeffs
* by packets.
*
* \note This bit can be set regardless of whether vectorization is actually enabled.
* To check for actual vectorizability, see \a ActualPacketAccessBit.
*/
const unsigned int PacketAccessBit = 0x8;
#ifdef EIGEN_VECTORIZE
/** \ingroup flags
*
* If vectorization is enabled (EIGEN_VECTORIZE is defined) this constant
* is set to the value \a PacketAccessBit.
*
* If vectorization is not enabled (EIGEN_VECTORIZE is not defined) this constant
* is set to the value 0.
*/
const unsigned int ActualPacketAccessBit = PacketAccessBit;
#else
const unsigned int ActualPacketAccessBit = 0x0;
#endif
/** \ingroup flags
*
* Short version: means the expression can be seen as 1D vector.
*
* Long version: means that one can access the coefficients
* of this expression by coeff(int), and coeffRef(int) in the case of a lvalue expression. These
* index-based access methods are guaranteed
* to not have to do any runtime computation of a (row, col)-pair from the index, so that it
* is guaranteed that whenever it is available, index-based access is at least as fast as
* (row,col)-based access. Expressions for which that isn't possible don't have the LinearAccessBit.
*
* If both PacketAccessBit and LinearAccessBit are set, then the
* packets of this expression can be accessed by packet(int), and writePacket(int) in the case of a
* lvalue expression.
*
* Typically, all vector expressions have the LinearAccessBit, but there is one exception:
* Product expressions don't have it, because it would be troublesome for vectorization, even when the
* Product is a vector expression. Thus, vector Product expressions allow index-based coefficient access but
* not index-based packet access, so they don't have the LinearAccessBit.
*/
const unsigned int LinearAccessBit = 0x10;
/** \ingroup flags
*
* Means that the underlying array of coefficients can be directly accessed. This means two things.
* First, references to the coefficients must be available through coeffRef(int, int). This rules out read-only
* expressions whose coefficients are computed on demand by coeff(int, int). Second, the memory layout of the
* array of coefficients must be exactly the natural one suggested by rows(), cols(), stride(), and the RowMajorBit.
* This rules out expressions such as DiagonalCoeffs, whose coefficients, though referencable, do not have
* such a regular memory layout.
*/
const unsigned int DirectAccessBit = 0x20;
/** \ingroup flags
*
* means the first coefficient packet is guaranteed to be aligned */
const unsigned int AlignedBit = 0x40;
/** \ingroup flags
*
* means all diagonal coefficients are equal to 0 */
const unsigned int ZeroDiagBit = 0x80;
/** \ingroup flags
*
* means all diagonal coefficients are equal to 1 */
const unsigned int UnitDiagBit = 0x100;
/** \ingroup flags
*
* means the matrix is selfadjoint (M=M*). */
const unsigned int SelfAdjointBit = 0x200;
/** \ingroup flags
*
* means the strictly lower triangular part is 0 */
const unsigned int UpperTriangularBit = 0x400;
/** \ingroup flags
*
* means the strictly upper triangular part is 0 */
const unsigned int LowerTriangularBit = 0x800;
/** \ingroup flags
*
* means the expression includes sparse matrices and the sparse path has to be taken. */
const unsigned int SparseBit = 0x1000;
// list of flags that are inherited by default
const unsigned int HereditaryBits = RowMajorBit
| EvalBeforeNestingBit
| EvalBeforeAssigningBit
| SparseBit;
// Possible values for the Mode parameter of part() and of extract()
const unsigned int UpperTriangular = UpperTriangularBit;
const unsigned int StrictlyUpperTriangular = UpperTriangularBit | ZeroDiagBit;
const unsigned int LowerTriangular = LowerTriangularBit;
const unsigned int StrictlyLowerTriangular = LowerTriangularBit | ZeroDiagBit;
const unsigned int SelfAdjoint = SelfAdjointBit;
// additional possible values for the Mode parameter of extract()
const unsigned int UnitUpperTriangular = UpperTriangularBit | UnitDiagBit;
const unsigned int UnitLowerTriangular = LowerTriangularBit | UnitDiagBit;
const unsigned int Diagonal = UpperTriangular | LowerTriangular;
enum { Aligned, Unaligned };
enum { ForceAligned, AsRequested };
enum { ConditionalJumpCost = 5 };
enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight };
enum DirectionType { Vertical, Horizontal };
enum ProductEvaluationMode { NormalProduct, CacheFriendlyProduct, DiagonalProduct, SparseTimeSparseProduct, SparseTimeDenseProduct, DenseTimeSparseProduct };
enum {
/** \internal Equivalent to a slice vectorization for fixed-size matrices having good alignment
* and good size */
InnerVectorization,
/** \internal Vectorization path using a single loop plus scalar loops for the
* unaligned boundaries */
LinearVectorization,
/** \internal Generic vectorization path using one vectorized loop per row/column with some
* scalar loops to handle the unaligned boundaries */
SliceVectorization,
NoVectorization
};
enum {
NoUnrolling,
InnerUnrolling,
CompleteUnrolling
};
enum {
ColMajor = 0,
RowMajor = 0x1, // it is only a coincidence that this is equal to RowMajorBit -- don't rely on that
/** \internal Don't require alignment for the matrix itself (the array of coefficients, if dynamically allocated, may still be
requested to be aligned) */
DontAlign = 0,
/** \internal Align the matrix itself if it is vectorizable fixed-size */
AutoAlign = 0x2
};
enum {
IsDense = 0,
IsSparse = SparseBit,
NoDirectAccess = 0,
HasDirectAccess = DirectAccessBit
};
const int EiArch_Generic = 0x0;
const int EiArch_SSE = 0x1;
const int EiArch_AltiVec = 0x2;
#if defined EIGEN_VECTORIZE_SSE
const int EiArch = EiArch_SSE;
#elif defined EIGEN_VECTORIZE_ALTIVEC
const int EiArch = EiArch_AltiVec;
#else
const int EiArch = EiArch_Generic;
#endif
#endif // EIGEN_CONSTANTS_H

View File

@@ -0,0 +1,5 @@
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4181 4244 4127 4211 4717 )
#endif

View File

@@ -0,0 +1,4 @@
#ifdef _MSC_VER
#pragma warning( pop )
#endif

View File

@@ -0,0 +1,125 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_FORWARDDECLARATIONS_H
#define EIGEN_FORWARDDECLARATIONS_H
template<typename T> struct ei_traits;
template<typename T> struct NumTraits;
template<typename _Scalar, int _Rows, int _Cols,
int _Options = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION | AutoAlign,
int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix;
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;
template<typename ExpressionType> class NestByValue;
template<typename ExpressionType> class SwapWrapper;
template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic, int PacketAccess=AsRequested,
int _DirectAccessStatus = ei_traits<MatrixType>::Flags&DirectAccessBit ? DirectAccessBit
: ei_traits<MatrixType>::Flags&SparseBit> class Block;
template<typename MatrixType> class Transpose;
template<typename MatrixType> class Conjugate;
template<typename NullaryOp, typename MatrixType> class CwiseNullaryOp;
template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp;
template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp;
template<typename Lhs, typename Rhs, int ProductMode> class Product;
template<typename CoeffsVectorType> class DiagonalMatrix;
template<typename MatrixType> class DiagonalCoeffs;
template<typename MatrixType, int PacketAccess = AsRequested> class Map;
template<typename MatrixType, unsigned int Mode> class Part;
template<typename MatrixType, unsigned int Mode> class Extract;
template<typename ExpressionType> class Cwise;
template<typename ExpressionType> class WithFormat;
template<typename MatrixType> struct CommaInitializer;
template<typename Lhs, typename Rhs> struct ei_product_mode;
template<typename Lhs, typename Rhs, int ProductMode = ei_product_mode<Lhs,Rhs>::value> struct ProductReturnType;
template<typename Scalar> struct ei_scalar_sum_op;
template<typename Scalar> struct ei_scalar_difference_op;
template<typename Scalar> struct ei_scalar_product_op;
template<typename Scalar> struct ei_scalar_quotient_op;
template<typename Scalar> struct ei_scalar_opposite_op;
template<typename Scalar> struct ei_scalar_conjugate_op;
template<typename Scalar> struct ei_scalar_real_op;
template<typename Scalar> struct ei_scalar_imag_op;
template<typename Scalar> struct ei_scalar_abs_op;
template<typename Scalar> struct ei_scalar_abs2_op;
template<typename Scalar> struct ei_scalar_sqrt_op;
template<typename Scalar> struct ei_scalar_exp_op;
template<typename Scalar> struct ei_scalar_log_op;
template<typename Scalar> struct ei_scalar_cos_op;
template<typename Scalar> struct ei_scalar_sin_op;
template<typename Scalar> struct ei_scalar_pow_op;
template<typename Scalar> struct ei_scalar_inverse_op;
template<typename Scalar> struct ei_scalar_square_op;
template<typename Scalar> struct ei_scalar_cube_op;
template<typename Scalar, typename NewType> struct ei_scalar_cast_op;
template<typename Scalar> struct ei_scalar_multiple_op;
template<typename Scalar> struct ei_scalar_quotient1_op;
template<typename Scalar> struct ei_scalar_min_op;
template<typename Scalar> struct ei_scalar_max_op;
template<typename Scalar> struct ei_scalar_random_op;
template<typename Scalar> struct ei_scalar_add_op;
template<typename Scalar> struct ei_scalar_constant_op;
template<typename Scalar> struct ei_scalar_identity_op;
struct IOFormat;
template<typename Scalar>
void ei_cache_friendly_product(
int _rows, int _cols, int depth,
bool _lhsRowMajor, const Scalar* _lhs, int _lhsStride,
bool _rhsRowMajor, const Scalar* _rhs, int _rhsStride,
bool resRowMajor, Scalar* res, int resStride);
// Array module
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> class Select;
template<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr;
template<typename ExpressionType, int Direction> class PartialRedux;
template<typename MatrixType> class LU;
template<typename MatrixType> class QR;
template<typename MatrixType> class SVD;
template<typename MatrixType> class LLT;
template<typename MatrixType> class LDLT;
// Geometry module:
template<typename Derived, int _Dim> class RotationBase;
template<typename Lhs, typename Rhs> class Cross;
template<typename Scalar> class Quaternion;
template<typename Scalar> class Rotation2D;
template<typename Scalar> class AngleAxis;
template<typename Scalar,int Dim> class Transform;
template <typename _Scalar, int _AmbientDim> class ParametrizedLine;
template <typename _Scalar, int _AmbientDim> class Hyperplane;
template<typename Scalar,int Dim> class Translation;
template<typename Scalar,int Dim> class Scaling;
// Sparse module:
template<typename Lhs, typename Rhs, int ProductMode> class SparseProduct;
#endif // EIGEN_FORWARDDECLARATIONS_H

View File

@@ -0,0 +1,273 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MACROS_H
#define EIGEN_MACROS_H
#undef minor
#define EIGEN_WORLD_VERSION 2
#define EIGEN_MAJOR_VERSION 0
#define EIGEN_MINOR_VERSION 6
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
(EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
EIGEN_MINOR_VERSION>=z))))
// 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable 16 byte alignment on all
// platforms where vectorization might be enabled. In theory we could always enable alignment, but it can be a cause of problems
// on some platforms, so we just disable it in certain common platform (compiler+architecture combinations) to avoid these problems.
#if defined(__GNUC__) && !(defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__ia64__) || defined(__ppc__))
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_ALIGNMENT 1
#else
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_ALIGNMENT 0
#endif
#if defined(__GNUC__) && (__GNUC__ <= 3)
#define EIGEN_GCC3_OR_OLDER 1
#else
#define EIGEN_GCC3_OR_OLDER 0
#endif
// FIXME vectorization + alignment is completely disabled with sun studio
#if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_ALIGNMENT && !EIGEN_GCC3_OR_OLDER && !defined(__SUNPRO_CC)
#define EIGEN_ARCH_WANTS_ALIGNMENT 1
#else
#define EIGEN_ARCH_WANTS_ALIGNMENT 0
#endif
// EIGEN_ALIGN is the true test whether we want to align or not. It takes into account both the user choice to explicitly disable
// alignment (EIGEN_DONT_ALIGN) and the architecture config (EIGEN_ARCH_WANTS_ALIGNMENT). Henceforth, only EIGEN_ALIGN should be used.
#if EIGEN_ARCH_WANTS_ALIGNMENT && !defined(EIGEN_DONT_ALIGN)
#define EIGEN_ALIGN 1
#else
#define EIGEN_ALIGN 0
#ifdef EIGEN_VECTORIZE
#error "Vectorization enabled, but our platform checks say that we don't do 16 byte alignment on this platform. If you added vectorization for another architecture, you also need to edit this platform check."
#endif
#ifndef EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
#endif
#endif
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION RowMajor
#else
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ColMajor
#endif
/** \internal Defines the maximal loop size to enable meta unrolling of loops.
* Note that the value here is expressed in Eigen's own notion of "number of FLOPS",
* it does not correspond to the number of iterations or the number of instructions
*/
#ifndef EIGEN_UNROLLING_LIMIT
#define EIGEN_UNROLLING_LIMIT 100
#endif
/** \internal Define the maximal size in Bytes of blocks fitting in CPU cache.
* The current value is set to generate blocks of 256x256 for float
*
* Typically for a single-threaded application you would set that to 25% of the size of your CPU caches in bytes
*/
#ifndef EIGEN_TUNE_FOR_CPU_CACHE_SIZE
#define EIGEN_TUNE_FOR_CPU_CACHE_SIZE (sizeof(float)*256*256)
#endif
// FIXME this should go away quickly
#ifdef EIGEN_TUNE_FOR_L2_CACHE_SIZE
#error EIGEN_TUNE_FOR_L2_CACHE_SIZE is now called EIGEN_TUNE_FOR_CPU_CACHE_SIZE.
#endif
#define USING_PART_OF_NAMESPACE_EIGEN \
EIGEN_USING_MATRIX_TYPEDEFS \
using Eigen::Matrix; \
using Eigen::MatrixBase; \
using Eigen::ei_random; \
using Eigen::ei_real; \
using Eigen::ei_imag; \
using Eigen::ei_conj; \
using Eigen::ei_abs; \
using Eigen::ei_abs2; \
using Eigen::ei_sqrt; \
using Eigen::ei_exp; \
using Eigen::ei_log; \
using Eigen::ei_sin; \
using Eigen::ei_cos;
#ifdef NDEBUG
# ifndef EIGEN_NO_DEBUG
# define EIGEN_NO_DEBUG
# endif
#endif
#ifndef ei_assert
#ifdef EIGEN_NO_DEBUG
#define ei_assert(x)
#else
#define ei_assert(x) assert(x)
#endif
#endif
#ifdef EIGEN_INTERNAL_DEBUGGING
#define ei_internal_assert(x) ei_assert(x)
#else
#define ei_internal_assert(x)
#endif
#ifdef EIGEN_NO_DEBUG
#define EIGEN_ONLY_USED_FOR_DEBUG(x) (void)x
#else
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
#endif
// EIGEN_ALWAYS_INLINE_ATTRIB should be use in the declaration of function
// which should be inlined even in debug mode.
// FIXME with the always_inline attribute,
// gcc 3.4.x reports the following compilation error:
// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
// : function body not available
#if EIGEN_GNUC_AT_LEAST(4,0)
#define EIGEN_ALWAYS_INLINE_ATTRIB __attribute__((always_inline))
#else
#define EIGEN_ALWAYS_INLINE_ATTRIB
#endif
// EIGEN_FORCE_INLINE means "inline as much as possible"
#if (defined _MSC_VER)
#define EIGEN_STRONG_INLINE __forceinline
#else
#define EIGEN_STRONG_INLINE inline
#endif
#if (defined __GNUC__)
#define EIGEN_DONT_INLINE __attribute__((noinline))
#elif (defined _MSC_VER)
#define EIGEN_DONT_INLINE __declspec(noinline)
#else
#define EIGEN_DONT_INLINE
#endif
#if (defined __GNUC__)
#define EIGEN_DEPRECATED __attribute__((deprecated))
#elif (defined _MSC_VER)
#define EIGEN_DEPRECATED __declspec(deprecated)
#else
#define EIGEN_DEPRECATED
#endif
/* EIGEN_ALIGN_128 forces data to be 16-byte aligned, EVEN if vectorization (EIGEN_VECTORIZE) is disabled,
* so that vectorization doesn't affect binary compatibility.
*
* If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link
* vectorized and non-vectorized code.
*/
#if !EIGEN_ALIGN
#define EIGEN_ALIGN_128
#elif (defined __GNUC__)
#define EIGEN_ALIGN_128 __attribute__((aligned(16)))
#elif (defined _MSC_VER)
#define EIGEN_ALIGN_128 __declspec(align(16))
#else
#error Please tell me what is the equivalent of __attribute__((aligned(16))) for your compiler
#endif
#ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
#define EIGEN_RESTRICT
#endif
#ifndef EIGEN_RESTRICT
#define EIGEN_RESTRICT __restrict
#endif
#ifndef EIGEN_STACK_ALLOCATION_LIMIT
#define EIGEN_STACK_ALLOCATION_LIMIT 1000000
#endif
#ifndef EIGEN_DEFAULT_IO_FORMAT
#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
#endif
// format used in Eigen's documentation
// needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
#define EIGEN_DOCS_IO_FORMAT IOFormat(3, AlignCols, " ", "\n", "", "")
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename OtherDerived> \
EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::MatrixBase<OtherDerived>& other) \
{ \
return Base::operator Op(other.derived()); \
} \
EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
{ \
return Base::operator Op(other); \
}
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename Other> \
EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
{ \
return Base::operator Op(scalar); \
}
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
#define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
typedef BaseClass Base; \
typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
typedef typename Base::PacketScalar PacketScalar; \
typedef typename Eigen::ei_nested<Derived>::type Nested; \
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
Flags = Eigen::ei_traits<Derived>::Flags, \
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
SizeAtCompileTime = Base::SizeAtCompileTime, \
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
#define EIGEN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
// just an empty macro !
#define EIGEN_EMPTY
// concatenate two tokens
#define EIGEN_CAT2(a,b) a ## b
#define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
// convert a token to a string
#define EIGEN_MAKESTRING2(a) #a
#define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
#endif // EIGEN_MACROS_H

View File

@@ -0,0 +1,387 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2008-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
// Copyright (C) 2009 Kenneth Riddile <kfriddile@yahoo.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_MEMORY_H
#define EIGEN_MEMORY_H
// FreeBSD 6 seems to have 16-byte aligned malloc
// See http://svn.freebsd.org/viewvc/base/stable/6/lib/libc/stdlib/malloc.c?view=markup
// FreeBSD 7 seems to have 16-byte aligned malloc except on ARM and MIPS architectures
// See http://svn.freebsd.org/viewvc/base/stable/7/lib/libc/stdlib/malloc.c?view=markup
#if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 1
#else
#define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0
#endif
#if defined(__APPLE__) || defined(_WIN64) || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED
#define EIGEN_MALLOC_ALREADY_ALIGNED 1
#else
#define EIGEN_MALLOC_ALREADY_ALIGNED 0
#endif
#if ((defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
#define EIGEN_HAS_POSIX_MEMALIGN 1
#else
#define EIGEN_HAS_POSIX_MEMALIGN 0
#endif
#ifdef EIGEN_VECTORIZE_SSE
#define EIGEN_HAS_MM_MALLOC 1
#else
#define EIGEN_HAS_MM_MALLOC 0
#endif
/** \internal like malloc, but the returned pointer is guaranteed to be 16-byte aligned.
* Fast, but wastes 16 additional bytes of memory.
* Does not throw any exception.
*/
inline void* ei_handmade_aligned_malloc(size_t size)
{
void *original = malloc(size+16);
void *aligned = reinterpret_cast<void*>((reinterpret_cast<size_t>(original) & ~(size_t(15))) + 16);
*(reinterpret_cast<void**>(aligned) - 1) = original;
return aligned;
}
/** \internal frees memory allocated with ei_handmade_aligned_malloc */
inline void ei_handmade_aligned_free(void *ptr)
{
if(ptr)
free(*(reinterpret_cast<void**>(ptr) - 1));
}
/** \internal allocates \a size bytes. The returned pointer is guaranteed to have 16 bytes alignment.
* On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown.
*/
inline void* ei_aligned_malloc(size_t size)
{
#ifdef EIGEN_NO_MALLOC
ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)");
#endif
void *result;
#if !EIGEN_ALIGN
result = malloc(size);
#elif EIGEN_MALLOC_ALREADY_ALIGNED
result = malloc(size);
#elif EIGEN_HAS_POSIX_MEMALIGN
if(posix_memalign(&result, 16, size)) result = 0;
#elif EIGEN_HAS_MM_MALLOC
result = _mm_malloc(size, 16);
#elif (defined _MSC_VER)
result = _aligned_malloc(size, 16);
#else
result = ei_handmade_aligned_malloc(size);
#endif
#ifdef EIGEN_EXCEPTIONS
if(result == 0)
throw std::bad_alloc();
#endif
return result;
}
/** allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned.
* On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown.
*/
template<bool Align> inline void* ei_conditional_aligned_malloc(size_t size)
{
return ei_aligned_malloc(size);
}
template<> inline void* ei_conditional_aligned_malloc<false>(size_t size)
{
#ifdef EIGEN_NO_MALLOC
ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)");
#endif
void *result = malloc(size);
#ifdef EIGEN_EXCEPTIONS
if(!result) throw std::bad_alloc();
#endif
return result;
}
/** \internal construct the elements of an array.
* The \a size parameter tells on how many objects to call the constructor of T.
*/
template<typename T> inline T* ei_construct_elements_of_array(T *ptr, size_t size)
{
for (size_t i=0; i < size; ++i) ::new (ptr + i) T;
return ptr;
}
/** allocates \a size objects of type T. The returned pointer is guaranteed to have 16 bytes alignment.
* On allocation error, the returned pointer is undefined, but if exceptions are enabled then a std::bad_alloc is thrown.
* The default constructor of T is called.
*/
template<typename T> inline T* ei_aligned_new(size_t size)
{
T *result = reinterpret_cast<T*>(ei_aligned_malloc(sizeof(T)*size));
return ei_construct_elements_of_array(result, size);
}
template<typename T, bool Align> inline T* ei_conditional_aligned_new(size_t size)
{
T *result = reinterpret_cast<T*>(ei_conditional_aligned_malloc<Align>(sizeof(T)*size));
return ei_construct_elements_of_array(result, size);
}
/** \internal free memory allocated with ei_aligned_malloc
*/
inline void ei_aligned_free(void *ptr)
{
#if !EIGEN_ALIGN
free(ptr);
#elif EIGEN_MALLOC_ALREADY_ALIGNED
free(ptr);
#elif EIGEN_HAS_POSIX_MEMALIGN
free(ptr);
#elif EIGEN_HAS_MM_MALLOC
_mm_free(ptr);
#elif defined(_MSC_VER)
_aligned_free(ptr);
#else
ei_handmade_aligned_free(ptr);
#endif
}
/** \internal free memory allocated with ei_conditional_aligned_malloc
*/
template<bool Align> inline void ei_conditional_aligned_free(void *ptr)
{
ei_aligned_free(ptr);
}
template<> inline void ei_conditional_aligned_free<false>(void *ptr)
{
free(ptr);
}
/** \internal destruct the elements of an array.
* The \a size parameters tells on how many objects to call the destructor of T.
*/
template<typename T> inline void ei_destruct_elements_of_array(T *ptr, size_t size)
{
// always destruct an array starting from the end.
while(size) ptr[--size].~T();
}
/** \internal delete objects constructed with ei_aligned_new
* The \a size parameters tells on how many objects to call the destructor of T.
*/
template<typename T> inline void ei_aligned_delete(T *ptr, size_t size)
{
ei_destruct_elements_of_array<T>(ptr, size);
ei_aligned_free(ptr);
}
/** \internal delete objects constructed with ei_conditional_aligned_new
* The \a size parameters tells on how many objects to call the destructor of T.
*/
template<typename T, bool Align> inline void ei_conditional_aligned_delete(T *ptr, size_t size)
{
ei_destruct_elements_of_array<T>(ptr, size);
ei_conditional_aligned_free<Align>(ptr);
}
/** \internal \returns the number of elements which have to be skipped such that data are 16 bytes aligned */
template<typename Scalar>
inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
{
typedef typename ei_packet_traits<Scalar>::type Packet;
const int PacketSize = ei_packet_traits<Scalar>::size;
const int PacketAlignedMask = PacketSize-1;
const bool Vectorized = PacketSize>1;
return Vectorized
? std::min<int>( (PacketSize - (int((size_t(ptr)/sizeof(Scalar))) & PacketAlignedMask))
& PacketAlignedMask, maxOffset)
: 0;
}
/** \internal
* ei_aligned_stack_alloc(SIZE) allocates an aligned buffer of SIZE bytes
* on the stack if SIZE is smaller than EIGEN_STACK_ALLOCATION_LIMIT.
* Otherwise the memory is allocated on the heap.
* Data allocated with ei_aligned_stack_alloc \b must be freed by calling ei_aligned_stack_free(PTR,SIZE).
* \code
* float * data = ei_aligned_stack_alloc(float,array.size());
* // ...
* ei_aligned_stack_free(data,float,array.size());
* \endcode
*/
#ifdef __linux__
#define ei_aligned_stack_alloc(SIZE) (SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) \
? alloca(SIZE) \
: ei_aligned_malloc(SIZE)
#define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) ei_aligned_free(PTR)
#else
#define ei_aligned_stack_alloc(SIZE) ei_aligned_malloc(SIZE)
#define ei_aligned_stack_free(PTR,SIZE) ei_aligned_free(PTR)
#endif
#define ei_aligned_stack_new(TYPE,SIZE) ei_construct_elements_of_array(reinterpret_cast<TYPE*>(ei_aligned_stack_alloc(sizeof(TYPE)*SIZE)), SIZE)
#define ei_aligned_stack_delete(TYPE,PTR,SIZE) do {ei_destruct_elements_of_array<TYPE>(PTR, SIZE); \
ei_aligned_stack_free(PTR,sizeof(TYPE)*SIZE);} while(0)
#if EIGEN_ALIGN
#ifdef EIGEN_EXCEPTIONS
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) throw() { \
try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \
catch (...) { return 0; } \
return 0; \
}
#else
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) throw() { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
}
#endif
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \
void *operator new(size_t size) { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
} \
void *operator new[](size_t size) { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
} \
void operator delete(void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \
void operator delete[](void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \
/* in-place new and delete. since (at least afaik) there is no actual */ \
/* memory allocated we can safely let the default implementation handle */ \
/* this particular case. */ \
static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \
void operator delete(void * memory, void *ptr) throw() { return ::operator delete(memory,ptr); } \
/* nothrow-new (returns zero instead of std::bad_alloc) */ \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void operator delete(void *ptr, const std::nothrow_t&) throw() { \
Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); \
} \
typedef void ei_operator_new_marker_type;
#else
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
#endif
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar,Size) \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(((Size)!=Eigen::Dynamic) && ((sizeof(Scalar)*(Size))%16==0))
/** \class aligned_allocator
*
* \brief stl compatible allocator to use with with 16 byte aligned types
*
* Example:
* \code
* // Matrix4f requires 16 bytes alignment:
* std::map< int, Matrix4f, std::less<int>, aligned_allocator<Matrix4f> > my_map_mat4;
* // Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:
* std::map< int, Vector3f > my_map_vec3;
* \endcode
*
*/
template<class T>
class aligned_allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
template<class U>
struct rebind
{
typedef aligned_allocator<U> other;
};
pointer address( reference value ) const
{
return &value;
}
const_pointer address( const_reference value ) const
{
return &value;
}
aligned_allocator() throw()
{
}
aligned_allocator( const aligned_allocator& ) throw()
{
}
template<class U>
aligned_allocator( const aligned_allocator<U>& ) throw()
{
}
~aligned_allocator() throw()
{
}
size_type max_size() const throw()
{
return std::numeric_limits<size_type>::max();
}
pointer allocate( size_type num, const_pointer* hint = 0 )
{
static_cast<void>( hint ); // suppress unused variable warning
return static_cast<pointer>( ei_aligned_malloc( num * sizeof(T) ) );
}
void construct( pointer p, const T& value )
{
::new( p ) T( value );
}
void destroy( pointer p )
{
p->~T();
}
void deallocate( pointer p, size_type /*num*/ )
{
ei_aligned_free( p );
}
bool operator!=(const aligned_allocator<T>& other) const
{ return false; }
bool operator==(const aligned_allocator<T>& other) const
{ return true; }
};
#endif // EIGEN_MEMORY_H

183
extern/Eigen2/Eigen/src/Core/util/Meta.h vendored Normal file
View File

@@ -0,0 +1,183 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_META_H
#define EIGEN_META_H
/** \internal
* \file Meta.h
* This file contains generic metaprogramming classes which are not specifically related to Eigen.
* \note In case you wonder, yes we're aware that Boost already provides all these features,
* we however don't want to add a dependency to Boost.
*/
struct ei_meta_true { enum { ret = 1 }; };
struct ei_meta_false { enum { ret = 0 }; };
template<bool Condition, typename Then, typename Else>
struct ei_meta_if { typedef Then ret; };
template<typename Then, typename Else>
struct ei_meta_if <false, Then, Else> { typedef Else ret; };
template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; };
template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; };
template<typename T> struct ei_unref { typedef T type; };
template<typename T> struct ei_unref<T&> { typedef T type; };
template<typename T> struct ei_unpointer { typedef T type; };
template<typename T> struct ei_unpointer<T*> { typedef T type; };
template<typename T> struct ei_unpointer<T*const> { typedef T type; };
template<typename T> struct ei_unconst { typedef T type; };
template<typename T> struct ei_unconst<const T> { typedef T type; };
template<typename T> struct ei_unconst<T const &> { typedef T & type; };
template<typename T> struct ei_unconst<T const *> { typedef T * type; };
template<typename T> struct ei_cleantype { typedef T type; };
template<typename T> struct ei_cleantype<const T> { typedef typename ei_cleantype<T>::type type; };
template<typename T> struct ei_cleantype<const T&> { typedef typename ei_cleantype<T>::type type; };
template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleantype<T>::type type; };
template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; };
template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; };
/** \internal
* Convenient struct to get the result type of a unary or binary functor.
*
* It supports both the current STL mechanism (using the result_type member) as well as
* upcoming next STL generation (using a templated result member).
* If none of these members is provided, then the type of the first argument is returned. FIXME, that behavior is a pretty bad hack.
*/
template<typename T> struct ei_result_of {};
struct ei_has_none {int a[1];};
struct ei_has_std_result_type {int a[2];};
struct ei_has_tr1_result {int a[3];};
template<typename Func, typename ArgType, int SizeOf=sizeof(ei_has_none)>
struct ei_unary_result_of_select {typedef ArgType type;};
template<typename Func, typename ArgType>
struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_std_result_type)> {typedef typename Func::result_type type;};
template<typename Func, typename ArgType>
struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;};
template<typename Func, typename ArgType>
struct ei_result_of<Func(ArgType)> {
template<typename T>
static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
template<typename T>
static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);
static ei_has_none testFunctor(...);
// note that the following indirection is needed for gcc-3.3
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
typedef typename ei_unary_result_of_select<Func, ArgType, FunctorType>::type type;
};
template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(ei_has_none)>
struct ei_binary_result_of_select {typedef ArgType0 type;};
template<typename Func, typename ArgType0, typename ArgType1>
struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_std_result_type)>
{typedef typename Func::result_type type;};
template<typename Func, typename ArgType0, typename ArgType1>
struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_tr1_result)>
{typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
template<typename Func, typename ArgType0, typename ArgType1>
struct ei_result_of<Func(ArgType0,ArgType1)> {
template<typename T>
static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
template<typename T>
static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);
static ei_has_none testFunctor(...);
// note that the following indirection is needed for gcc-3.3
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
typedef typename ei_binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
};
/** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer.
* Usage example: \code ei_meta_sqrt<1023>::ret \endcode
*/
template<int Y,
int InfX = 0,
int SupX = ((Y==1) ? 1 : Y/2),
bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
// use ?: instead of || just to shut up a stupid gcc 4.3 warning
class ei_meta_sqrt
{
enum {
MidX = (InfX+SupX)/2,
TakeInf = MidX*MidX > Y ? 1 : 0,
NewInf = int(TakeInf) ? InfX : int(MidX),
NewSup = int(TakeInf) ? int(MidX) : SupX
};
public:
enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret };
};
template<int Y, int InfX, int SupX>
class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
/** \internal determines whether the product of two numeric types is allowed and what the return type is */
template<typename T, typename U> struct ei_scalar_product_traits
{
// dummy general case where T and U aren't compatible -- not allowed anyway but we catch it elsewhere
//enum { Cost = NumTraits<T>::MulCost };
typedef T ReturnType;
};
template<typename T> struct ei_scalar_product_traits<T,T>
{
//enum { Cost = NumTraits<T>::MulCost };
typedef T ReturnType;
};
template<typename T> struct ei_scalar_product_traits<T,std::complex<T> >
{
//enum { Cost = 2*NumTraits<T>::MulCost };
typedef std::complex<T> ReturnType;
};
template<typename T> struct ei_scalar_product_traits<std::complex<T>, T>
{
//enum { Cost = 2*NumTraits<T>::MulCost };
typedef std::complex<T> ReturnType;
};
// FIXME quick workaround around current limitation of ei_result_of
template<typename Scalar, typename ArgType0, typename ArgType1>
struct ei_result_of<ei_scalar_product_op<Scalar>(ArgType0,ArgType1)> {
typedef typename ei_scalar_product_traits<typename ei_cleantype<ArgType0>::type, typename ei_cleantype<ArgType1>::type>::ReturnType type;
};
#endif // EIGEN_META_H

View File

@@ -0,0 +1,148 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_STATIC_ASSERT_H
#define EIGEN_STATIC_ASSERT_H
/* Some notes on Eigen's static assertion mechanism:
*
* - in EIGEN_STATIC_ASSERT(CONDITION,MSG) the parameter CONDITION must be a compile time boolean
* expression, and MSG an enum listed in struct ei_static_assert<true>
*
* - define EIGEN_NO_STATIC_ASSERT to disable them (and save compilation time)
* in that case, the static assertion is converted to the following runtime assert:
* ei_assert(CONDITION && "MSG")
*
* - currently EIGEN_STATIC_ASSERT can only be used in function scope
*
*/
#ifndef EIGEN_NO_STATIC_ASSERT
#ifdef __GXX_EXPERIMENTAL_CXX0X__
// if native static_assert is enabled, let's use it
#define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
#else // CXX0X
template<bool condition>
struct ei_static_assert {};
template<>
struct ei_static_assert<true>
{
enum {
YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,
YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,
YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES,
THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE,
THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE,
YOU_MADE_A_PROGRAMMING_MISTAKE,
YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR,
UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,
NUMERIC_TYPE_MUST_BE_FLOATING_POINT,
COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED,
WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED,
THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE,
INVALID_MATRIX_PRODUCT,
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS,
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION,
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY,
THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES,
THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,
INVALID_MATRIX_TEMPLATE_PARAMETERS,
BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,
THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX
};
};
// Specialized implementation for MSVC to avoid "conditional
// expression is constant" warnings. This implementation doesn't
// appear to work under GCC, hence the multiple implementations.
#ifdef _MSC_VER
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
{Eigen::ei_static_assert<CONDITION ? true : false>::MSG;}
#else
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
if (Eigen::ei_static_assert<CONDITION ? true : false>::MSG) {}
#endif
#endif // not CXX0X
#else // EIGEN_NO_STATIC_ASSERT
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) ei_assert((CONDITION) && #MSG);
#endif // EIGEN_NO_STATIC_ASSERT
// static assertion failing if the type \a TYPE is not a vector type
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \
EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \
YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)
// static assertion failing if the type \a TYPE is not fixed-size
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \
EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \
YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
// static assertion failing if the type \a TYPE is not a vector type of the given size
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \
EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \
THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)
// static assertion failing if the type \a TYPE is not a vector type of the given size
#define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \
EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \
THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
// static assertion failing if the two vector expression types are not compatible (same fixed-size or dynamic size)
#define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \
EIGEN_STATIC_ASSERT( \
(int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \
|| int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \
|| int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\
YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
((int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
|| int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \
|| int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \
&& (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \
|| int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \
|| int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime)))
// static assertion failing if it is guaranteed at compile-time that the two matrix expression types have different sizes
#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
EIGEN_STATIC_ASSERT( \
EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\
YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
#endif // EIGEN_STATIC_ASSERT_H

View File

@@ -0,0 +1,219 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_XPRHELPER_H
#define EIGEN_XPRHELPER_H
// just a workaround because GCC seems to not really like empty structs
#ifdef __GNUG__
struct ei_empty_struct{char _ei_dummy_;};
#define EIGEN_EMPTY_STRUCT : Eigen::ei_empty_struct
#else
#define EIGEN_EMPTY_STRUCT
#endif
//classes inheriting ei_no_assignment_operator don't generate a default operator=.
class ei_no_assignment_operator
{
private:
ei_no_assignment_operator& operator=(const ei_no_assignment_operator&);
};
/** \internal If the template parameter Value is Dynamic, this class is just a wrapper around an int variable that
* can be accessed using value() and setValue().
* Otherwise, this class is an empty structure and value() just returns the template parameter Value.
*/
template<int Value> class ei_int_if_dynamic EIGEN_EMPTY_STRUCT
{
public:
ei_int_if_dynamic() {}
explicit ei_int_if_dynamic(int) {}
static int value() { return Value; }
void setValue(int) {}
};
template<> class ei_int_if_dynamic<Dynamic>
{
int m_value;
ei_int_if_dynamic() {}
public:
explicit ei_int_if_dynamic(int value) : m_value(value) {}
int value() const { return m_value; }
void setValue(int value) { m_value = value; }
};
template<typename T> struct ei_functor_traits
{
enum
{
Cost = 10,
PacketAccess = false
};
};
template<typename T> struct ei_packet_traits
{
typedef T type;
enum {size=1};
};
template<typename T> struct ei_unpacket_traits
{
typedef T type;
enum {size=1};
};
template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
class ei_compute_matrix_flags
{
enum {
row_major_bit = Options&RowMajor ? RowMajorBit : 0,
inner_max_size = row_major_bit ? MaxCols : MaxRows,
is_big = inner_max_size == Dynamic,
is_packet_size_multiple = (Cols*Rows) % ei_packet_traits<Scalar>::size == 0,
aligned_bit = ((Options&AutoAlign) && (is_big || is_packet_size_multiple)) ? AlignedBit : 0,
packet_access_bit = ei_packet_traits<Scalar>::size > 1 && aligned_bit ? PacketAccessBit : 0
};
public:
enum { ret = LinearAccessBit | DirectAccessBit | packet_access_bit | row_major_bit | aligned_bit };
};
template<int _Rows, int _Cols> struct ei_size_at_compile_time
{
enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols };
};
/* ei_eval : the return type of eval(). For matrices, this is just a const reference
* in order to avoid a useless copy
*/
template<typename T, int Sparseness = ei_traits<T>::Flags&SparseBit> class ei_eval;
template<typename T> struct ei_eval<T,IsDense>
{
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;
};
// for matrices, no need to evaluate, just use a const reference to avoid a useless copy
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, IsDense>
{
typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type;
};
/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type,
* whereas ei_eval is a const reference in the case of a matrix
*/
template<typename T> struct ei_plain_matrix_type
{
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;
};
/* ei_plain_matrix_type_column_major : same as ei_plain_matrix_type but guaranteed to be column-major
*/
template<typename T> struct ei_plain_matrix_type_column_major
{
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | ColMajor,
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;
};
template<typename T> struct ei_must_nest_by_value { enum { ret = false }; };
template<typename T> struct ei_must_nest_by_value<NestByValue<T> > { enum { ret = true }; };
/** \internal Determines how a given expression should be nested into another one.
* For example, when you do a * (b+c), Eigen will determine how the expression b+c should be
* nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or
* evaluating that expression b+c into a temporary variable d, and nest d so that the resulting expression is
* a*d. Evaluating can be beneficial for example if every coefficient access in the resulting expression causes
* many coefficient accesses in the nested expressions -- as is the case with matrix product for example.
*
* \param T the type of the expression being nested
* \param n the number of coefficient accesses in the nested expression for each coefficient access in the bigger expression.
*
* Example. Suppose that a, b, and c are of type Matrix3d. The user forms the expression a*(b+c).
* b+c is an expression "sum of matrices", which we will denote by S. In order to determine how to nest it,
* the Product expression uses: ei_nested<S, 3>::ret, which turns out to be Matrix3d because the internal logic of
* ei_nested determined that in this case it was better to evaluate the expression b+c into a temporary. On the other hand,
* since a is of type Matrix3d, the Product expression nests it as ei_nested<Matrix3d, 3>::ret, which turns out to be
* const Matrix3d&, because the internal logic of ei_nested determined that since a was already a matrix, there was no point
* in copying it into another matrix.
*/
template<typename T, int n=1, typename PlainMatrixType = typename ei_eval<T>::type> struct ei_nested
{
enum {
CostEval = (n+1) * int(NumTraits<typename ei_traits<T>::Scalar>::ReadCost),
CostNoEval = (n-1) * int(ei_traits<T>::CoeffReadCost)
};
typedef typename ei_meta_if<
ei_must_nest_by_value<T>::ret,
T,
typename ei_meta_if<
(int(ei_traits<T>::Flags) & EvalBeforeNestingBit)
|| ( int(CostEval) <= int(CostNoEval) ),
PlainMatrixType,
const T&
>::ret
>::ret type;
};
template<unsigned int Flags> struct ei_are_flags_consistent
{
enum { ret = !( (Flags&UnitDiagBit && Flags&ZeroDiagBit) )
};
};
/** \internal Gives the type of a sub-matrix or sub-vector of a matrix of type \a ExpressionType and size \a Size
* TODO: could be a good idea to define a big ReturnType struct ??
*/
template<typename ExpressionType, int RowsOrSize=Dynamic, int Cols=Dynamic> struct BlockReturnType {
typedef Block<ExpressionType, (ei_traits<ExpressionType>::RowsAtCompileTime == 1 ? 1 : RowsOrSize),
(ei_traits<ExpressionType>::ColsAtCompileTime == 1 ? 1 : RowsOrSize)> SubVectorType;
typedef Block<ExpressionType, RowsOrSize, Cols> Type;
};
template<typename CurrentType, typename NewType> struct ei_cast_return_type
{
typedef typename ei_meta_if<ei_is_same_type<CurrentType,NewType>::ret,const CurrentType&,NewType>::ret type;
};
#endif // EIGEN_XPRHELPER_H

View File

@@ -0,0 +1,173 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ALIGNEDBOX_H
#define EIGEN_ALIGNEDBOX_H
/** \geometry_module \ingroup Geometry_Module
* \nonstableyet
*
* \class AlignedBox
*
* \brief An axis aligned box
*
* \param _Scalar the type of the scalar coefficients
* \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
*
* This class represents an axis aligned box as a pair of the minimal and maximal corners.
*/
template <typename _Scalar, int _AmbientDim>
class AlignedBox
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)
enum { AmbientDimAtCompileTime = _AmbientDim };
typedef _Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
/** Default constructor initializing a null box. */
inline explicit AlignedBox()
{ if (AmbientDimAtCompileTime!=Dynamic) setNull(); }
/** Constructs a null box with \a _dim the dimension of the ambient space. */
inline explicit AlignedBox(int _dim) : m_min(_dim), m_max(_dim)
{ setNull(); }
/** Constructs a box with extremities \a _min and \a _max. */
inline AlignedBox(const VectorType& _min, const VectorType& _max) : m_min(_min), m_max(_max) {}
/** Constructs a box containing a single point \a p. */
inline explicit AlignedBox(const VectorType& p) : m_min(p), m_max(p) {}
~AlignedBox() {}
/** \returns the dimension in which the box holds */
inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size()-1 : AmbientDimAtCompileTime; }
/** \returns true if the box is null, i.e, empty. */
inline bool isNull() const { return (m_min.cwise() > m_max).any(); }
/** Makes \c *this a null/empty box. */
inline void setNull()
{
m_min.setConstant( std::numeric_limits<Scalar>::max());
m_max.setConstant(-std::numeric_limits<Scalar>::max());
}
/** \returns the minimal corner */
inline const VectorType& min() const { return m_min; }
/** \returns a non const reference to the minimal corner */
inline VectorType& min() { return m_min; }
/** \returns the maximal corner */
inline const VectorType& max() const { return m_max; }
/** \returns a non const reference to the maximal corner */
inline VectorType& max() { return m_max; }
/** \returns true if the point \a p is inside the box \c *this. */
inline bool contains(const VectorType& p) const
{ return (m_min.cwise()<=p).all() && (p.cwise()<=m_max).all(); }
/** \returns true if the box \a b is entirely inside the box \c *this. */
inline bool contains(const AlignedBox& b) const
{ return (m_min.cwise()<=b.min()).all() && (b.max().cwise()<=m_max).all(); }
/** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */
inline AlignedBox& extend(const VectorType& p)
{ m_min = m_min.cwise().min(p); m_max = m_max.cwise().max(p); return *this; }
/** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */
inline AlignedBox& extend(const AlignedBox& b)
{ m_min = m_min.cwise().min(b.m_min); m_max = m_max.cwise().max(b.m_max); return *this; }
/** Clamps \c *this by the box \a b and returns a reference to \c *this. */
inline AlignedBox& clamp(const AlignedBox& b)
{ m_min = m_min.cwise().max(b.m_min); m_max = m_max.cwise().min(b.m_max); return *this; }
/** Translate \c *this by the vector \a t and returns a reference to \c *this. */
inline AlignedBox& translate(const VectorType& t)
{ m_min += t; m_max += t; return *this; }
/** \returns the squared distance between the point \a p and the box \c *this,
* and zero if \a p is inside the box.
* \sa exteriorDistance()
*/
inline Scalar squaredExteriorDistance(const VectorType& p) const;
/** \returns the distance between the point \a p and the box \c *this,
* and zero if \a p is inside the box.
* \sa squaredExteriorDistance()
*/
inline Scalar exteriorDistance(const VectorType& p) const
{ return ei_sqrt(squaredExteriorDistance(p)); }
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<AlignedBox,
AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
{
return typename ei_cast_return_type<AlignedBox,
AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
}
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit AlignedBox(const AlignedBox<OtherScalarType,AmbientDimAtCompileTime>& other)
{
m_min = other.min().template cast<Scalar>();
m_max = other.max().template cast<Scalar>();
}
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const AlignedBox& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_min.isApprox(other.m_min, prec) && m_max.isApprox(other.m_max, prec); }
protected:
VectorType m_min, m_max;
};
template<typename Scalar,int AmbiantDim>
inline Scalar AlignedBox<Scalar,AmbiantDim>::squaredExteriorDistance(const VectorType& p) const
{
Scalar dist2 = 0.;
Scalar aux;
for (int k=0; k<dim(); ++k)
{
if ((aux = (p[k]-m_min[k]))<0.)
dist2 += aux*aux;
else if ( (aux = (m_max[k]-p[k]))<0. )
dist2 += aux*aux;
}
return dist2;
}
#endif // EIGEN_ALIGNEDBOX_H

View File

@@ -0,0 +1,228 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ANGLEAXIS_H
#define EIGEN_ANGLEAXIS_H
/** \geometry_module \ingroup Geometry_Module
*
* \class AngleAxis
*
* \brief Represents a 3D rotation as a rotation angle around an arbitrary 3D axis
*
* \param _Scalar the scalar type, i.e., the type of the coefficients.
*
* The following two typedefs are provided for convenience:
* \li \c AngleAxisf for \c float
* \li \c AngleAxisd for \c double
*
* \addexample AngleAxisForEuler \label How to define a rotation from Euler-angles
*
* Combined with MatrixBase::Unit{X,Y,Z}, AngleAxis can be used to easily
* mimic Euler-angles. Here is an example:
* \include AngleAxis_mimic_euler.cpp
* Output: \verbinclude AngleAxis_mimic_euler.out
*
* \note This class is not aimed to be used to store a rotation transformation,
* but rather to make easier the creation of other rotation (Quaternion, rotation Matrix)
* and transformation objects.
*
* \sa class Quaternion, class Transform, MatrixBase::UnitX()
*/
template<typename _Scalar> struct ei_traits<AngleAxis<_Scalar> >
{
typedef _Scalar Scalar;
};
template<typename _Scalar>
class AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>
{
typedef RotationBase<AngleAxis<_Scalar>,3> Base;
public:
using Base::operator*;
enum { Dim = 3 };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
typedef Matrix<Scalar,3,3> Matrix3;
typedef Matrix<Scalar,3,1> Vector3;
typedef Quaternion<Scalar> QuaternionType;
protected:
Vector3 m_axis;
Scalar m_angle;
public:
/** Default constructor without initialization. */
AngleAxis() {}
/** Constructs and initialize the angle-axis rotation from an \a angle in radian
* and an \a axis which must be normalized. */
template<typename Derived>
inline AngleAxis(Scalar angle, const MatrixBase<Derived>& axis) : m_axis(axis), m_angle(angle) {}
/** Constructs and initialize the angle-axis rotation from a quaternion \a q. */
inline AngleAxis(const QuaternionType& q) { *this = q; }
/** Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix. */
template<typename Derived>
inline explicit AngleAxis(const MatrixBase<Derived>& m) { *this = m; }
Scalar angle() const { return m_angle; }
Scalar& angle() { return m_angle; }
const Vector3& axis() const { return m_axis; }
Vector3& axis() { return m_axis; }
/** Concatenates two rotations */
inline QuaternionType operator* (const AngleAxis& other) const
{ return QuaternionType(*this) * QuaternionType(other); }
/** Concatenates two rotations */
inline QuaternionType operator* (const QuaternionType& other) const
{ return QuaternionType(*this) * other; }
/** Concatenates two rotations */
friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b)
{ return a * QuaternionType(b); }
/** Concatenates two rotations */
inline Matrix3 operator* (const Matrix3& other) const
{ return toRotationMatrix() * other; }
/** Concatenates two rotations */
inline friend Matrix3 operator* (const Matrix3& a, const AngleAxis& b)
{ return a * b.toRotationMatrix(); }
/** Applies rotation to vector */
inline Vector3 operator* (const Vector3& other) const
{ return toRotationMatrix() * other; }
/** \returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */
AngleAxis inverse() const
{ return AngleAxis(-m_angle, m_axis); }
AngleAxis& operator=(const QuaternionType& q);
template<typename Derived>
AngleAxis& operator=(const MatrixBase<Derived>& m);
template<typename Derived>
AngleAxis& fromRotationMatrix(const MatrixBase<Derived>& m);
Matrix3 toRotationMatrix(void) const;
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type cast() const
{ return typename ei_cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit AngleAxis(const AngleAxis<OtherScalarType>& other)
{
m_axis = other.axis().template cast<Scalar>();
m_angle = Scalar(other.angle());
}
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const AngleAxis& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_axis.isApprox(other.m_axis, prec) && ei_isApprox(m_angle,other.m_angle, prec); }
};
/** \ingroup Geometry_Module
* single precision angle-axis type */
typedef AngleAxis<float> AngleAxisf;
/** \ingroup Geometry_Module
* double precision angle-axis type */
typedef AngleAxis<double> AngleAxisd;
/** Set \c *this from a quaternion.
* The axis is normalized.
*/
template<typename Scalar>
AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionType& q)
{
Scalar n2 = q.vec().squaredNorm();
if (n2 < precision<Scalar>()*precision<Scalar>())
{
m_angle = 0;
m_axis << 1, 0, 0;
}
else
{
m_angle = 2*std::acos(q.w());
m_axis = q.vec() / ei_sqrt(n2);
}
return *this;
}
/** Set \c *this from a 3x3 rotation matrix \a mat.
*/
template<typename Scalar>
template<typename Derived>
AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const MatrixBase<Derived>& mat)
{
// Since a direct conversion would not be really faster,
// let's use the robust Quaternion implementation:
return *this = QuaternionType(mat);
}
/** Constructs and \returns an equivalent 3x3 rotation matrix.
*/
template<typename Scalar>
typename AngleAxis<Scalar>::Matrix3
AngleAxis<Scalar>::toRotationMatrix(void) const
{
Matrix3 res;
Vector3 sin_axis = ei_sin(m_angle) * m_axis;
Scalar c = ei_cos(m_angle);
Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
Scalar tmp;
tmp = cos1_axis.x() * m_axis.y();
res.coeffRef(0,1) = tmp - sin_axis.z();
res.coeffRef(1,0) = tmp + sin_axis.z();
tmp = cos1_axis.x() * m_axis.z();
res.coeffRef(0,2) = tmp + sin_axis.y();
res.coeffRef(2,0) = tmp - sin_axis.y();
tmp = cos1_axis.y() * m_axis.z();
res.coeffRef(1,2) = tmp - sin_axis.x();
res.coeffRef(2,1) = tmp + sin_axis.x();
res.diagonal() = (cos1_axis.cwise() * m_axis).cwise() + c;
return res;
}
#endif // EIGEN_ANGLEAXIS_H

View File

@@ -0,0 +1,96 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_EULERANGLES_H
#define EIGEN_EULERANGLES_H
/** \geometry_module \ingroup Geometry_Module
* \nonstableyet
*
* \returns the Euler-angles of the rotation matrix \c *this using the convention defined by the triplet (\a a0,\a a1,\a a2)
*
* Each of the three parameters \a a0,\a a1,\a a2 represents the respective rotation axis as an integer in {0,1,2}.
* For instance, in:
* \code Vector3f ea = mat.eulerAngles(2, 0, 2); \endcode
* "2" represents the z axis and "0" the x axis, etc. The returned angles are such that
* we have the following equality:
* \code
* mat == AngleAxisf(ea[0], Vector3f::UnitZ())
* * AngleAxisf(ea[1], Vector3f::UnitX())
* * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode
* This corresponds to the right-multiply conventions (with right hand side frames).
*/
template<typename Derived>
inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>
MatrixBase<Derived>::eulerAngles(int a0, int a1, int a2) const
{
/* Implemented from Graphics Gems IV */
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3)
Matrix<Scalar,3,1> res;
typedef Matrix<typename Derived::Scalar,2,1> Vector2;
const Scalar epsilon = precision<Scalar>();
const int odd = ((a0+1)%3 == a1) ? 0 : 1;
const int i = a0;
const int j = (a0 + 1 + odd)%3;
const int k = (a0 + 2 - odd)%3;
if (a0==a2)
{
Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm();
res[1] = ei_atan2(s, coeff(i,i));
if (s > epsilon)
{
res[0] = ei_atan2(coeff(j,i), coeff(k,i));
res[2] = ei_atan2(coeff(i,j),-coeff(i,k));
}
else
{
res[0] = Scalar(0);
res[2] = (coeff(i,i)>0?1:-1)*ei_atan2(-coeff(k,j), coeff(j,j));
}
}
else
{
Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm();
res[1] = ei_atan2(-coeff(i,k), c);
if (c > epsilon)
{
res[0] = ei_atan2(coeff(j,k), coeff(k,k));
res[2] = ei_atan2(coeff(i,j), coeff(i,i));
}
else
{
res[0] = Scalar(0);
res[2] = (coeff(i,k)>0?1:-1)*ei_atan2(-coeff(k,j), coeff(j,j));
}
}
if (!odd)
res = -res;
return res;
}
#endif // EIGEN_EULERANGLES_H

View File

@@ -0,0 +1,268 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_HYPERPLANE_H
#define EIGEN_HYPERPLANE_H
/** \geometry_module \ingroup Geometry_Module
*
* \class Hyperplane
*
* \brief A hyperplane
*
* A hyperplane is an affine subspace of dimension n-1 in a space of dimension n.
* For example, a hyperplane in a plane is a line; a hyperplane in 3-space is a plane.
*
* \param _Scalar the scalar type, i.e., the type of the coefficients
* \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
* Notice that the dimension of the hyperplane is _AmbientDim-1.
*
* This class represents an hyperplane as the zero set of the implicit equation
* \f$ n \cdot x + d = 0 \f$ where \f$ n \f$ is a unit normal vector of the plane (linear part)
* and \f$ d \f$ is the distance (offset) to the origin.
*/
template <typename _Scalar, int _AmbientDim>
class Hyperplane
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)
enum { AmbientDimAtCompileTime = _AmbientDim };
typedef _Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
typedef Matrix<Scalar,AmbientDimAtCompileTime==Dynamic
? Dynamic
: AmbientDimAtCompileTime+1,1> Coefficients;
typedef Block<Coefficients,AmbientDimAtCompileTime,1> NormalReturnType;
/** Default constructor without initialization */
inline explicit Hyperplane() {}
/** Constructs a dynamic-size hyperplane with \a _dim the dimension
* of the ambient space */
inline explicit Hyperplane(int _dim) : m_coeffs(_dim+1) {}
/** Construct a plane from its normal \a n and a point \a e onto the plane.
* \warning the vector normal is assumed to be normalized.
*/
inline Hyperplane(const VectorType& n, const VectorType& e)
: m_coeffs(n.size()+1)
{
normal() = n;
offset() = -e.dot(n);
}
/** Constructs a plane from its normal \a n and distance to the origin \a d
* such that the algebraic equation of the plane is \f$ n \cdot x + d = 0 \f$.
* \warning the vector normal is assumed to be normalized.
*/
inline Hyperplane(const VectorType& n, Scalar d)
: m_coeffs(n.size()+1)
{
normal() = n;
offset() = d;
}
/** Constructs a hyperplane passing through the two points. If the dimension of the ambient space
* is greater than 2, then there isn't uniqueness, so an arbitrary choice is made.
*/
static inline Hyperplane Through(const VectorType& p0, const VectorType& p1)
{
Hyperplane result(p0.size());
result.normal() = (p1 - p0).unitOrthogonal();
result.offset() = -result.normal().dot(p0);
return result;
}
/** Constructs a hyperplane passing through the three points. The dimension of the ambient space
* is required to be exactly 3.
*/
static inline Hyperplane Through(const VectorType& p0, const VectorType& p1, const VectorType& p2)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
Hyperplane result(p0.size());
result.normal() = (p2 - p0).cross(p1 - p0).normalized();
result.offset() = -result.normal().dot(p0);
return result;
}
/** Constructs a hyperplane passing through the parametrized line \a parametrized.
* If the dimension of the ambient space is greater than 2, then there isn't uniqueness,
* so an arbitrary choice is made.
*/
// FIXME to be consitent with the rest this could be implemented as a static Through function ??
explicit Hyperplane(const ParametrizedLine<Scalar, AmbientDimAtCompileTime>& parametrized)
{
normal() = parametrized.direction().unitOrthogonal();
offset() = -normal().dot(parametrized.origin());
}
~Hyperplane() {}
/** \returns the dimension in which the plane holds */
inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_coeffs.size()-1 : AmbientDimAtCompileTime; }
/** normalizes \c *this */
void normalize(void)
{
m_coeffs /= normal().norm();
}
/** \returns the signed distance between the plane \c *this and a point \a p.
* \sa absDistance()
*/
inline Scalar signedDistance(const VectorType& p) const { return p.dot(normal()) + offset(); }
/** \returns the absolute distance between the plane \c *this and a point \a p.
* \sa signedDistance()
*/
inline Scalar absDistance(const VectorType& p) const { return ei_abs(signedDistance(p)); }
/** \returns the projection of a point \a p onto the plane \c *this.
*/
inline VectorType projection(const VectorType& p) const { return p - signedDistance(p) * normal(); }
/** \returns a constant reference to the unit normal vector of the plane, which corresponds
* to the linear part of the implicit equation.
*/
inline const NormalReturnType normal() const { return NormalReturnType(m_coeffs,0,0,dim(),1); }
/** \returns a non-constant reference to the unit normal vector of the plane, which corresponds
* to the linear part of the implicit equation.
*/
inline NormalReturnType normal() { return NormalReturnType(m_coeffs,0,0,dim(),1); }
/** \returns the distance to the origin, which is also the "constant term" of the implicit equation
* \warning the vector normal is assumed to be normalized.
*/
inline const Scalar& offset() const { return m_coeffs.coeff(dim()); }
/** \returns a non-constant reference to the distance to the origin, which is also the constant part
* of the implicit equation */
inline Scalar& offset() { return m_coeffs(dim()); }
/** \returns a constant reference to the coefficients c_i of the plane equation:
* \f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \f$
*/
inline const Coefficients& coeffs() const { return m_coeffs; }
/** \returns a non-constant reference to the coefficients c_i of the plane equation:
* \f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \f$
*/
inline Coefficients& coeffs() { return m_coeffs; }
/** \returns the intersection of *this with \a other.
*
* \warning The ambient space must be a plane, i.e. have dimension 2, so that \c *this and \a other are lines.
*
* \note If \a other is approximately parallel to *this, this method will return any point on *this.
*/
VectorType intersection(const Hyperplane& other)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);
// since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests
// whether the two lines are approximately parallel.
if(ei_isMuchSmallerThan(det, Scalar(1)))
{ // special case where the two lines are approximately parallel. Pick any point on the first line.
if(ei_abs(coeffs().coeff(1))>ei_abs(coeffs().coeff(0)))
return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));
else
return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));
}
else
{ // general case
Scalar invdet = Scalar(1) / det;
return VectorType(invdet*(coeffs().coeff(1)*other.coeffs().coeff(2)-other.coeffs().coeff(1)*coeffs().coeff(2)),
invdet*(other.coeffs().coeff(0)*coeffs().coeff(2)-coeffs().coeff(0)*other.coeffs().coeff(2)));
}
}
/** Applies the transformation matrix \a mat to \c *this and returns a reference to \c *this.
*
* \param mat the Dim x Dim transformation matrix
* \param traits specifies whether the matrix \a mat represents an Isometry
* or a more generic Affine transformation. The default is Affine.
*/
template<typename XprType>
inline Hyperplane& transform(const MatrixBase<XprType>& mat, TransformTraits traits = Affine)
{
if (traits==Affine)
normal() = mat.inverse().transpose() * normal();
else if (traits==Isometry)
normal() = mat * normal();
else
{
ei_assert("invalid traits value in Hyperplane::transform()");
}
return *this;
}
/** Applies the transformation \a t to \c *this and returns a reference to \c *this.
*
* \param t the transformation of dimension Dim
* \param traits specifies whether the transformation \a t represents an Isometry
* or a more generic Affine transformation. The default is Affine.
* Other kind of transformations are not supported.
*/
inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime>& t,
TransformTraits traits = Affine)
{
transform(t.linear(), traits);
offset() -= t.translation().dot(normal());
return *this;
}
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Hyperplane,
Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
{
return typename ei_cast_return_type<Hyperplane,
Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
}
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Hyperplane(const Hyperplane<OtherScalarType,AmbientDimAtCompileTime>& other)
{ m_coeffs = other.coeffs().template cast<Scalar>(); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Hyperplane& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
protected:
Coefficients m_coeffs;
};
#endif // EIGEN_HYPERPLANE_H

View File

@@ -0,0 +1,119 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ORTHOMETHODS_H
#define EIGEN_ORTHOMETHODS_H
/** \geometry_module
*
* \returns the cross product of \c *this and \a other
*
* Here is a very good explanation of cross-product: http://xkcd.com/199/
*/
template<typename Derived>
template<typename OtherDerived>
inline typename MatrixBase<Derived>::PlainMatrixType
MatrixBase<Derived>::cross(const MatrixBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,3)
// Note that there is no need for an expression here since the compiler
// optimize such a small temporary very well (even within a complex expression)
const typename ei_nested<Derived,2>::type lhs(derived());
const typename ei_nested<OtherDerived,2>::type rhs(other.derived());
return typename ei_plain_matrix_type<Derived>::type(
lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1),
lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2),
lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)
);
}
template<typename Derived, int Size = Derived::SizeAtCompileTime>
struct ei_unitOrthogonal_selector
{
typedef typename ei_plain_matrix_type<Derived>::type VectorType;
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
inline static VectorType run(const Derived& src)
{
VectorType perp(src.size());
/* Let us compute the crossed product of *this with a vector
* that is not too close to being colinear to *this.
*/
/* unless the x and y coords are both close to zero, we can
* simply take ( -y, x, 0 ) and normalize it.
*/
if((!ei_isMuchSmallerThan(src.x(), src.z()))
|| (!ei_isMuchSmallerThan(src.y(), src.z())))
{
RealScalar invnm = RealScalar(1)/src.template start<2>().norm();
perp.coeffRef(0) = -ei_conj(src.y())*invnm;
perp.coeffRef(1) = ei_conj(src.x())*invnm;
perp.coeffRef(2) = 0;
}
/* if both x and y are close to zero, then the vector is close
* to the z-axis, so it's far from colinear to the x-axis for instance.
* So we take the crossed product with (1,0,0) and normalize it.
*/
else
{
RealScalar invnm = RealScalar(1)/src.template end<2>().norm();
perp.coeffRef(0) = 0;
perp.coeffRef(1) = -ei_conj(src.z())*invnm;
perp.coeffRef(2) = ei_conj(src.y())*invnm;
}
if( (Derived::SizeAtCompileTime!=Dynamic && Derived::SizeAtCompileTime>3)
|| (Derived::SizeAtCompileTime==Dynamic && src.size()>3) )
perp.end(src.size()-3).setZero();
return perp;
}
};
template<typename Derived>
struct ei_unitOrthogonal_selector<Derived,2>
{
typedef typename ei_plain_matrix_type<Derived>::type VectorType;
inline static VectorType run(const Derived& src)
{ return VectorType(-ei_conj(src.y()), ei_conj(src.x())).normalized(); }
};
/** \returns a unit vector which is orthogonal to \c *this
*
* The size of \c *this must be at least 2. If the size is exactly 2,
* then the returned vector is a counter clock wise rotation of \c *this, i.e., (-y,x).normalized().
*
* \sa cross()
*/
template<typename Derived>
typename MatrixBase<Derived>::PlainMatrixType
MatrixBase<Derived>::unitOrthogonal() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return ei_unitOrthogonal_selector<Derived>::run(derived());
}
#endif // EIGEN_ORTHOMETHODS_H

View File

@@ -0,0 +1,155 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_PARAMETRIZEDLINE_H
#define EIGEN_PARAMETRIZEDLINE_H
/** \geometry_module \ingroup Geometry_Module
*
* \class ParametrizedLine
*
* \brief A parametrized line
*
* A parametrized line is defined by an origin point \f$ \mathbf{o} \f$ and a unit
* direction vector \f$ \mathbf{d} \f$ such that the line corresponds to
* the set \f$ l(t) = \mathbf{o} + t \mathbf{d} \f$, \f$ l \in \mathbf{R} \f$.
*
* \param _Scalar the scalar type, i.e., the type of the coefficients
* \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
*/
template <typename _Scalar, int _AmbientDim>
class ParametrizedLine
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
enum { AmbientDimAtCompileTime = _AmbientDim };
typedef _Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
/** Default constructor without initialization */
inline explicit ParametrizedLine() {}
/** Constructs a dynamic-size line with \a _dim the dimension
* of the ambient space */
inline explicit ParametrizedLine(int _dim) : m_origin(_dim), m_direction(_dim) {}
/** Initializes a parametrized line of direction \a direction and origin \a origin.
* \warning the vector direction is assumed to be normalized.
*/
ParametrizedLine(const VectorType& origin, const VectorType& direction)
: m_origin(origin), m_direction(direction) {}
explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
/** Constructs a parametrized line going from \a p0 to \a p1. */
static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)
{ return ParametrizedLine(p0, (p1-p0).normalized()); }
~ParametrizedLine() {}
/** \returns the dimension in which the line holds */
inline int dim() const { return m_direction.size(); }
const VectorType& origin() const { return m_origin; }
VectorType& origin() { return m_origin; }
const VectorType& direction() const { return m_direction; }
VectorType& direction() { return m_direction; }
/** \returns the squared distance of a point \a p to its projection onto the line \c *this.
* \sa distance()
*/
RealScalar squaredDistance(const VectorType& p) const
{
VectorType diff = p-origin();
return (diff - diff.dot(direction())* direction()).squaredNorm();
}
/** \returns the distance of a point \a p to its projection onto the line \c *this.
* \sa squaredDistance()
*/
RealScalar distance(const VectorType& p) const { return ei_sqrt(squaredDistance(p)); }
/** \returns the projection of a point \a p onto the line \c *this. */
VectorType projection(const VectorType& p) const
{ return origin() + (p-origin()).dot(direction()) * direction(); }
Scalar intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<ParametrizedLine,
ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
{
return typename ei_cast_return_type<ParametrizedLine,
ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
}
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit ParametrizedLine(const ParametrizedLine<OtherScalarType,AmbientDimAtCompileTime>& other)
{
m_origin = other.origin().template cast<Scalar>();
m_direction = other.direction().template cast<Scalar>();
}
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const ParametrizedLine& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
protected:
VectorType m_origin, m_direction;
};
/** Constructs a parametrized line from a 2D hyperplane
*
* \warning the ambient space must have dimension 2 such that the hyperplane actually describes a line
*/
template <typename _Scalar, int _AmbientDim>
inline ParametrizedLine<_Scalar, _AmbientDim>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
direction() = hyperplane.normal().unitOrthogonal();
origin() = -hyperplane.normal()*hyperplane.offset();
}
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
*/
template <typename _Scalar, int _AmbientDim>
inline _Scalar ParametrizedLine<_Scalar, _AmbientDim>::intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
{
return -(hyperplane.offset()+origin().dot(hyperplane.normal()))
/(direction().dot(hyperplane.normal()));
}
#endif // EIGEN_PARAMETRIZEDLINE_H

View File

@@ -0,0 +1,521 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_QUATERNION_H
#define EIGEN_QUATERNION_H
template<typename Other,
int OtherRows=Other::RowsAtCompileTime,
int OtherCols=Other::ColsAtCompileTime>
struct ei_quaternion_assign_impl;
/** \geometry_module \ingroup Geometry_Module
*
* \class Quaternion
*
* \brief The quaternion class used to represent 3D orientations and rotations
*
* \param _Scalar the scalar type, i.e., the type of the coefficients
*
* This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
* orientations and rotations of objects in three dimensions. Compared to other representations
* like Euler angles or 3x3 matrices, quatertions offer the following advantages:
* \li \b compact storage (4 scalars)
* \li \b efficient to compose (28 flops),
* \li \b stable spherical interpolation
*
* The following two typedefs are provided for convenience:
* \li \c Quaternionf for \c float
* \li \c Quaterniond for \c double
*
* \sa class AngleAxis, class Transform
*/
template<typename _Scalar> struct ei_traits<Quaternion<_Scalar> >
{
typedef _Scalar Scalar;
};
template<typename _Scalar>
class Quaternion : public RotationBase<Quaternion<_Scalar>,3>
{
typedef RotationBase<Quaternion<_Scalar>,3> Base;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,4)
using Base::operator*;
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
/** the type of the Coefficients 4-vector */
typedef Matrix<Scalar, 4, 1> Coefficients;
/** the type of a 3D vector */
typedef Matrix<Scalar,3,1> Vector3;
/** the equivalent rotation matrix type */
typedef Matrix<Scalar,3,3> Matrix3;
/** the equivalent angle-axis type */
typedef AngleAxis<Scalar> AngleAxisType;
/** \returns the \c x coefficient */
inline Scalar x() const { return m_coeffs.coeff(0); }
/** \returns the \c y coefficient */
inline Scalar y() const { return m_coeffs.coeff(1); }
/** \returns the \c z coefficient */
inline Scalar z() const { return m_coeffs.coeff(2); }
/** \returns the \c w coefficient */
inline Scalar w() const { return m_coeffs.coeff(3); }
/** \returns a reference to the \c x coefficient */
inline Scalar& x() { return m_coeffs.coeffRef(0); }
/** \returns a reference to the \c y coefficient */
inline Scalar& y() { return m_coeffs.coeffRef(1); }
/** \returns a reference to the \c z coefficient */
inline Scalar& z() { return m_coeffs.coeffRef(2); }
/** \returns a reference to the \c w coefficient */
inline Scalar& w() { return m_coeffs.coeffRef(3); }
/** \returns a read-only vector expression of the imaginary part (x,y,z) */
inline const Block<Coefficients,3,1> vec() const { return m_coeffs.template start<3>(); }
/** \returns a vector expression of the imaginary part (x,y,z) */
inline Block<Coefficients,3,1> vec() { return m_coeffs.template start<3>(); }
/** \returns a read-only vector expression of the coefficients (x,y,z,w) */
inline const Coefficients& coeffs() const { return m_coeffs; }
/** \returns a vector expression of the coefficients (x,y,z,w) */
inline Coefficients& coeffs() { return m_coeffs; }
/** Default constructor leaving the quaternion uninitialized. */
inline Quaternion() {}
/** Constructs and initializes the quaternion \f$ w+xi+yj+zk \f$ from
* its four coefficients \a w, \a x, \a y and \a z.
*
* \warning Note the order of the arguments: the real \a w coefficient first,
* while internally the coefficients are stored in the following order:
* [\c x, \c y, \c z, \c w]
*/
inline Quaternion(Scalar w, Scalar x, Scalar y, Scalar z)
{ m_coeffs << x, y, z, w; }
/** Copy constructor */
inline Quaternion(const Quaternion& other) { m_coeffs = other.m_coeffs; }
/** Constructs and initializes a quaternion from the angle-axis \a aa */
explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
/** Constructs and initializes a quaternion from either:
* - a rotation matrix expression,
* - a 4D vector expression representing quaternion coefficients.
* \sa operator=(MatrixBase<Derived>)
*/
template<typename Derived>
explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
Quaternion& operator=(const Quaternion& other);
Quaternion& operator=(const AngleAxisType& aa);
template<typename Derived>
Quaternion& operator=(const MatrixBase<Derived>& m);
/** \returns a quaternion representing an identity rotation
* \sa MatrixBase::Identity()
*/
inline static Quaternion Identity() { return Quaternion(1, 0, 0, 0); }
/** \sa Quaternion::Identity(), MatrixBase::setIdentity()
*/
inline Quaternion& setIdentity() { m_coeffs << 0, 0, 0, 1; return *this; }
/** \returns the squared norm of the quaternion's coefficients
* \sa Quaternion::norm(), MatrixBase::squaredNorm()
*/
inline Scalar squaredNorm() const { return m_coeffs.squaredNorm(); }
/** \returns the norm of the quaternion's coefficients
* \sa Quaternion::squaredNorm(), MatrixBase::norm()
*/
inline Scalar norm() const { return m_coeffs.norm(); }
/** Normalizes the quaternion \c *this
* \sa normalized(), MatrixBase::normalize() */
inline void normalize() { m_coeffs.normalize(); }
/** \returns a normalized version of \c *this
* \sa normalize(), MatrixBase::normalized() */
inline Quaternion normalized() const { return Quaternion(m_coeffs.normalized()); }
/** \returns the dot product of \c *this and \a other
* Geometrically speaking, the dot product of two unit quaternions
* corresponds to the cosine of half the angle between the two rotations.
* \sa angularDistance()
*/
inline Scalar dot(const Quaternion& other) const { return m_coeffs.dot(other.m_coeffs); }
inline Scalar angularDistance(const Quaternion& other) const;
Matrix3 toRotationMatrix(void) const;
template<typename Derived1, typename Derived2>
Quaternion& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
inline Quaternion operator* (const Quaternion& q) const;
inline Quaternion& operator*= (const Quaternion& q);
Quaternion inverse(void) const;
Quaternion conjugate(void) const;
Quaternion slerp(Scalar t, const Quaternion& other) const;
template<typename Derived>
Vector3 operator* (const MatrixBase<Derived>& vec) const;
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Quaternion,Quaternion<NewScalarType> >::type cast() const
{ return typename ei_cast_return_type<Quaternion,Quaternion<NewScalarType> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Quaternion(const Quaternion<OtherScalarType>& other)
{ m_coeffs = other.coeffs().template cast<Scalar>(); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Quaternion& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
protected:
Coefficients m_coeffs;
};
/** \ingroup Geometry_Module
* single precision quaternion type */
typedef Quaternion<float> Quaternionf;
/** \ingroup Geometry_Module
* double precision quaternion type */
typedef Quaternion<double> Quaterniond;
// Generic Quaternion * Quaternion product
template<int Arch,typename Scalar> inline Quaternion<Scalar>
ei_quaternion_product(const Quaternion<Scalar>& a, const Quaternion<Scalar>& b)
{
return Quaternion<Scalar>
(
a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
);
}
#ifdef EIGEN_VECTORIZE_SSE
template<> inline Quaternion<float>
ei_quaternion_product<EiArch_SSE,float>(const Quaternion<float>& _a, const Quaternion<float>& _b)
{
const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0,0,0,0x80000000));
Quaternion<float> res;
__m128 a = _a.coeffs().packet<Aligned>(0);
__m128 b = _b.coeffs().packet<Aligned>(0);
__m128 flip1 = _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a,1,2,0,2),
ei_vec4f_swizzle1(b,2,0,1,2)),mask);
__m128 flip2 = _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a,3,3,3,1),
ei_vec4f_swizzle1(b,0,1,2,1)),mask);
ei_pstore(&res.x(),
_mm_add_ps(_mm_sub_ps(_mm_mul_ps(a,ei_vec4f_swizzle1(b,3,3,3,3)),
_mm_mul_ps(ei_vec4f_swizzle1(a,2,0,1,0),
ei_vec4f_swizzle1(b,1,2,0,0))),
_mm_add_ps(flip1,flip2)));
return res;
}
#endif
/** \returns the concatenation of two rotations as a quaternion-quaternion product */
template <typename Scalar>
inline Quaternion<Scalar> Quaternion<Scalar>::operator* (const Quaternion& other) const
{
return ei_quaternion_product<EiArch>(*this,other);
}
/** \sa operator*(Quaternion) */
template <typename Scalar>
inline Quaternion<Scalar>& Quaternion<Scalar>::operator*= (const Quaternion& other)
{
return (*this = *this * other);
}
/** Rotation of a vector by a quaternion.
* \remarks If the quaternion is used to rotate several points (>1)
* then it is much more efficient to first convert it to a 3x3 Matrix.
* Comparison of the operation cost for n transformations:
* - Quaternion: 30n
* - Via a Matrix3: 24 + 15n
*/
template <typename Scalar>
template<typename Derived>
inline typename Quaternion<Scalar>::Vector3
Quaternion<Scalar>::operator* (const MatrixBase<Derived>& v) const
{
// Note that this algorithm comes from the optimization by hand
// of the conversion to a Matrix followed by a Matrix/Vector product.
// It appears to be much faster than the common algorithm found
// in the litterature (30 versus 39 flops). It also requires two
// Vector3 as temporaries.
Vector3 uv;
uv = 2 * this->vec().cross(v);
return v + this->w() * uv + this->vec().cross(uv);
}
template<typename Scalar>
inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const Quaternion& other)
{
m_coeffs = other.m_coeffs;
return *this;
}
/** Set \c *this from an angle-axis \a aa and returns a reference to \c *this
*/
template<typename Scalar>
inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const AngleAxisType& aa)
{
Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
this->w() = ei_cos(ha);
this->vec() = ei_sin(ha) * aa.axis();
return *this;
}
/** Set \c *this from the expression \a xpr:
* - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
* - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
* and \a xpr is converted to a quaternion
*/
template<typename Scalar>
template<typename Derived>
inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const MatrixBase<Derived>& xpr)
{
ei_quaternion_assign_impl<Derived>::run(*this, xpr.derived());
return *this;
}
/** Convert the quaternion to a 3x3 rotation matrix */
template<typename Scalar>
inline typename Quaternion<Scalar>::Matrix3
Quaternion<Scalar>::toRotationMatrix(void) const
{
// NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
// if not inlined then the cost of the return by value is huge ~ +35%,
// however, not inlining this function is an order of magnitude slower, so
// it has to be inlined, and so the return by value is not an issue
Matrix3 res;
const Scalar tx = 2*this->x();
const Scalar ty = 2*this->y();
const Scalar tz = 2*this->z();
const Scalar twx = tx*this->w();
const Scalar twy = ty*this->w();
const Scalar twz = tz*this->w();
const Scalar txx = tx*this->x();
const Scalar txy = ty*this->x();
const Scalar txz = tz*this->x();
const Scalar tyy = ty*this->y();
const Scalar tyz = tz*this->y();
const Scalar tzz = tz*this->z();
res.coeffRef(0,0) = 1-(tyy+tzz);
res.coeffRef(0,1) = txy-twz;
res.coeffRef(0,2) = txz+twy;
res.coeffRef(1,0) = txy+twz;
res.coeffRef(1,1) = 1-(txx+tzz);
res.coeffRef(1,2) = tyz-twx;
res.coeffRef(2,0) = txz-twy;
res.coeffRef(2,1) = tyz+twx;
res.coeffRef(2,2) = 1-(txx+tyy);
return res;
}
/** Sets *this to be a quaternion representing a rotation sending the vector \a a to the vector \a b.
*
* \returns a reference to *this.
*
* Note that the two input vectors do \b not have to be normalized.
*/
template<typename Scalar>
template<typename Derived1, typename Derived2>
inline Quaternion<Scalar>& Quaternion<Scalar>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
{
Vector3 v0 = a.normalized();
Vector3 v1 = b.normalized();
Scalar c = v0.dot(v1);
// if dot == 1, vectors are the same
if (ei_isApprox(c,Scalar(1)))
{
// set to identity
this->w() = 1; this->vec().setZero();
return *this;
}
// if dot == -1, vectors are opposites
if (ei_isApprox(c,Scalar(-1)))
{
this->vec() = v0.unitOrthogonal();
this->w() = 0;
return *this;
}
Vector3 axis = v0.cross(v1);
Scalar s = ei_sqrt((Scalar(1)+c)*Scalar(2));
Scalar invs = Scalar(1)/s;
this->vec() = axis * invs;
this->w() = s * Scalar(0.5);
return *this;
}
/** \returns the multiplicative inverse of \c *this
* Note that in most cases, i.e., if you simply want the opposite rotation,
* and/or the quaternion is normalized, then it is enough to use the conjugate.
*
* \sa Quaternion::conjugate()
*/
template <typename Scalar>
inline Quaternion<Scalar> Quaternion<Scalar>::inverse() const
{
// FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
Scalar n2 = this->squaredNorm();
if (n2 > 0)
return Quaternion(conjugate().coeffs() / n2);
else
{
// return an invalid result to flag the error
return Quaternion(Coefficients::Zero());
}
}
/** \returns the conjugate of the \c *this which is equal to the multiplicative inverse
* if the quaternion is normalized.
* The conjugate of a quaternion represents the opposite rotation.
*
* \sa Quaternion::inverse()
*/
template <typename Scalar>
inline Quaternion<Scalar> Quaternion<Scalar>::conjugate() const
{
return Quaternion(this->w(),-this->x(),-this->y(),-this->z());
}
/** \returns the angle (in radian) between two rotations
* \sa dot()
*/
template <typename Scalar>
inline Scalar Quaternion<Scalar>::angularDistance(const Quaternion& other) const
{
double d = ei_abs(this->dot(other));
if (d>=1.0)
return 0;
return Scalar(2) * std::acos(d);
}
/** \returns the spherical linear interpolation between the two quaternions
* \c *this and \a other at the parameter \a t
*/
template <typename Scalar>
Quaternion<Scalar> Quaternion<Scalar>::slerp(Scalar t, const Quaternion& other) const
{
static const Scalar one = Scalar(1) - precision<Scalar>();
Scalar d = this->dot(other);
Scalar absD = ei_abs(d);
if (absD>=one)
return *this;
// theta is the angle between the 2 quaternions
Scalar theta = std::acos(absD);
Scalar sinTheta = ei_sin(theta);
Scalar scale0 = ei_sin( ( Scalar(1) - t ) * theta) / sinTheta;
Scalar scale1 = ei_sin( ( t * theta) ) / sinTheta;
if (d<0)
scale1 = -scale1;
return Quaternion(scale0 * m_coeffs + scale1 * other.m_coeffs);
}
// set from a rotation matrix
template<typename Other>
struct ei_quaternion_assign_impl<Other,3,3>
{
typedef typename Other::Scalar Scalar;
inline static void run(Quaternion<Scalar>& q, const Other& mat)
{
// This algorithm comes from "Quaternion Calculus and Fast Animation",
// Ken Shoemake, 1987 SIGGRAPH course notes
Scalar t = mat.trace();
if (t > 0)
{
t = ei_sqrt(t + Scalar(1.0));
q.w() = Scalar(0.5)*t;
t = Scalar(0.5)/t;
q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
}
else
{
int i = 0;
if (mat.coeff(1,1) > mat.coeff(0,0))
i = 1;
if (mat.coeff(2,2) > mat.coeff(i,i))
i = 2;
int j = (i+1)%3;
int k = (j+1)%3;
t = ei_sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
q.coeffs().coeffRef(i) = Scalar(0.5) * t;
t = Scalar(0.5)/t;
q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
}
}
};
// set from a vector of coefficients assumed to be a quaternion
template<typename Other>
struct ei_quaternion_assign_impl<Other,4,1>
{
typedef typename Other::Scalar Scalar;
inline static void run(Quaternion<Scalar>& q, const Other& vec)
{
q.coeffs() = vec;
}
};
#endif // EIGEN_QUATERNION_H

View File

@@ -0,0 +1,159 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ROTATION2D_H
#define EIGEN_ROTATION2D_H
/** \geometry_module \ingroup Geometry_Module
*
* \class Rotation2D
*
* \brief Represents a rotation/orientation in a 2 dimensional space.
*
* \param _Scalar the scalar type, i.e., the type of the coefficients
*
* This class is equivalent to a single scalar representing a counter clock wise rotation
* as a single angle in radian. It provides some additional features such as the automatic
* conversion from/to a 2x2 rotation matrix. Moreover this class aims to provide a similar
* interface to Quaternion in order to facilitate the writing of generic algorithms
* dealing with rotations.
*
* \sa class Quaternion, class Transform
*/
template<typename _Scalar> struct ei_traits<Rotation2D<_Scalar> >
{
typedef _Scalar Scalar;
};
template<typename _Scalar>
class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
{
typedef RotationBase<Rotation2D<_Scalar>,2> Base;
public:
using Base::operator*;
enum { Dim = 2 };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
typedef Matrix<Scalar,2,1> Vector2;
typedef Matrix<Scalar,2,2> Matrix2;
protected:
Scalar m_angle;
public:
/** Construct a 2D counter clock wise rotation from the angle \a a in radian. */
inline Rotation2D(Scalar a) : m_angle(a) {}
/** \returns the rotation angle */
inline Scalar angle() const { return m_angle; }
/** \returns a read-write reference to the rotation angle */
inline Scalar& angle() { return m_angle; }
/** \returns the inverse rotation */
inline Rotation2D inverse() const { return -m_angle; }
/** Concatenates two rotations */
inline Rotation2D operator*(const Rotation2D& other) const
{ return m_angle + other.m_angle; }
/** Concatenates two rotations */
inline Rotation2D& operator*=(const Rotation2D& other)
{ return m_angle += other.m_angle; return *this; }
/** Applies the rotation to a 2D vector */
Vector2 operator* (const Vector2& vec) const
{ return toRotationMatrix() * vec; }
template<typename Derived>
Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);
Matrix2 toRotationMatrix(void) const;
/** \returns the spherical interpolation between \c *this and \a other using
* parameter \a t. It is in fact equivalent to a linear interpolation.
*/
inline Rotation2D slerp(Scalar t, const Rotation2D& other) const
{ return m_angle * (1-t) + other.angle() * t; }
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const
{ return typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Rotation2D(const Rotation2D<OtherScalarType>& other)
{
m_angle = Scalar(other.angle());
}
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Rotation2D& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return ei_isApprox(m_angle,other.m_angle, prec); }
};
/** \ingroup Geometry_Module
* single precision 2D rotation type */
typedef Rotation2D<float> Rotation2Df;
/** \ingroup Geometry_Module
* double precision 2D rotation type */
typedef Rotation2D<double> Rotation2Dd;
/** Set \c *this from a 2x2 rotation matrix \a mat.
* In other words, this function extract the rotation angle
* from the rotation matrix.
*/
template<typename Scalar>
template<typename Derived>
Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)
{
EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
m_angle = ei_atan2(mat.coeff(1,0), mat.coeff(0,0));
return *this;
}
/** Constructs and \returns an equivalent 2x2 rotation matrix.
*/
template<typename Scalar>
typename Rotation2D<Scalar>::Matrix2
Rotation2D<Scalar>::toRotationMatrix(void) const
{
Scalar sinA = ei_sin(m_angle);
Scalar cosA = ei_cos(m_angle);
return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
}
#endif // EIGEN_ROTATION2D_H

View File

@@ -0,0 +1,137 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_ROTATIONBASE_H
#define EIGEN_ROTATIONBASE_H
// this file aims to contains the various representations of rotation/orientation
// in 2D and 3D space excepted Matrix and Quaternion.
/** \class RotationBase
*
* \brief Common base class for compact rotation representations
*
* \param Derived is the derived type, i.e., a rotation type
* \param _Dim the dimension of the space
*/
template<typename Derived, int _Dim>
class RotationBase
{
public:
enum { Dim = _Dim };
/** the scalar type of the coefficients */
typedef typename ei_traits<Derived>::Scalar Scalar;
/** corresponding linear transformation matrix type */
typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
inline Derived& derived() { return *static_cast<Derived*>(this); }
/** \returns an equivalent rotation matrix */
inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
/** \returns the inverse rotation */
inline Derived inverse() const { return derived().inverse(); }
/** \returns the concatenation of the rotation \c *this with a translation \a t */
inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const
{ return toRotationMatrix() * t; }
/** \returns the concatenation of the rotation \c *this with a scaling \a s */
inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
{ return toRotationMatrix() * s; }
/** \returns the concatenation of the rotation \c *this with an affine transformation \a t */
inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
{ return toRotationMatrix() * t; }
};
/** \geometry_module
*
* Constructs a Dim x Dim rotation matrix from the rotation \a r
*/
template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
{
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
*this = r.toRotationMatrix();
}
/** \geometry_module
*
* Set a Dim x Dim rotation matrix from the rotation \a r
*/
template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
{
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
return *this = r.toRotationMatrix();
}
/** \internal
*
* Helper function to return an arbitrary rotation object to a rotation matrix.
*
* \param Scalar the numeric type of the matrix coefficients
* \param Dim the dimension of the current space
*
* It returns a Dim x Dim fixed size matrix.
*
* Default specializations are provided for:
* - any scalar type (2D),
* - any matrix expression,
* - any type based on RotationBase (e.g., Quaternion, AngleAxis, Rotation2D)
*
* Currently ei_toRotationMatrix is only used by Transform.
*
* \sa class Transform, class Rotation2D, class Quaternion, class AngleAxis
*/
template<typename Scalar, int Dim>
inline static Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
{
EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
return Rotation2D<Scalar>(s).toRotationMatrix();
}
template<typename Scalar, int Dim, typename OtherDerived>
inline static Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
{
return r.toRotationMatrix();
}
template<typename Scalar, int Dim, typename OtherDerived>
inline static const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
{
EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
YOU_MADE_A_PROGRAMMING_MISTAKE)
return mat;
}
#endif // EIGEN_ROTATIONBASE_H

View File

@@ -0,0 +1,181 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_SCALING_H
#define EIGEN_SCALING_H
/** \geometry_module \ingroup Geometry_Module
*
* \class Scaling
*
* \brief Represents a possibly non uniform scaling transformation
*
* \param _Scalar the scalar type, i.e., the type of the coefficients.
* \param _Dim the dimension of the space, can be a compile time value or Dynamic
*
* \note This class is not aimed to be used to store a scaling transformation,
* but rather to make easier the constructions and updates of Transform objects.
*
* \sa class Translation, class Transform
*/
template<typename _Scalar, int _Dim>
class Scaling
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)
/** dimension of the space */
enum { Dim = _Dim };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
/** corresponding vector type */
typedef Matrix<Scalar,Dim,1> VectorType;
/** corresponding linear transformation matrix type */
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
/** corresponding translation type */
typedef Translation<Scalar,Dim> TranslationType;
/** corresponding affine transformation type */
typedef Transform<Scalar,Dim> TransformType;
protected:
VectorType m_coeffs;
public:
/** Default constructor without initialization. */
Scaling() {}
/** Constructs and initialize a uniform scaling transformation */
explicit inline Scaling(const Scalar& s) { m_coeffs.setConstant(s); }
/** 2D only */
inline Scaling(const Scalar& sx, const Scalar& sy)
{
ei_assert(Dim==2);
m_coeffs.x() = sx;
m_coeffs.y() = sy;
}
/** 3D only */
inline Scaling(const Scalar& sx, const Scalar& sy, const Scalar& sz)
{
ei_assert(Dim==3);
m_coeffs.x() = sx;
m_coeffs.y() = sy;
m_coeffs.z() = sz;
}
/** Constructs and initialize the scaling transformation from a vector of scaling coefficients */
explicit inline Scaling(const VectorType& coeffs) : m_coeffs(coeffs) {}
const VectorType& coeffs() const { return m_coeffs; }
VectorType& coeffs() { return m_coeffs; }
/** Concatenates two scaling */
inline Scaling operator* (const Scaling& other) const
{ return Scaling(coeffs().cwise() * other.coeffs()); }
/** Concatenates a scaling and a translation */
inline TransformType operator* (const TranslationType& t) const;
/** Concatenates a scaling and an affine transformation */
inline TransformType operator* (const TransformType& t) const;
/** Concatenates a scaling and a linear transformation matrix */
// TODO returns an expression
inline LinearMatrixType operator* (const LinearMatrixType& other) const
{ return coeffs().asDiagonal() * other; }
/** Concatenates a linear transformation matrix and a scaling */
// TODO returns an expression
friend inline LinearMatrixType operator* (const LinearMatrixType& other, const Scaling& s)
{ return other * s.coeffs().asDiagonal(); }
template<typename Derived>
inline LinearMatrixType operator*(const RotationBase<Derived,Dim>& r) const
{ return *this * r.toRotationMatrix(); }
/** Applies scaling to vector */
inline VectorType operator* (const VectorType& other) const
{ return coeffs().asDiagonal() * other; }
/** \returns the inverse scaling */
inline Scaling inverse() const
{ return Scaling(coeffs().cwise().inverse()); }
inline Scaling& operator=(const Scaling& other)
{
m_coeffs = other.m_coeffs;
return *this;
}
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Scaling,Scaling<NewScalarType,Dim> >::type cast() const
{ return typename ei_cast_return_type<Scaling,Scaling<NewScalarType,Dim> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Scaling(const Scaling<OtherScalarType,Dim>& other)
{ m_coeffs = other.coeffs().template cast<Scalar>(); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Scaling& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
};
/** \addtogroup Geometry_Module */
//@{
typedef Scaling<float, 2> Scaling2f;
typedef Scaling<double,2> Scaling2d;
typedef Scaling<float, 3> Scaling3f;
typedef Scaling<double,3> Scaling3d;
//@}
template<typename Scalar, int Dim>
inline typename Scaling<Scalar,Dim>::TransformType
Scaling<Scalar,Dim>::operator* (const TranslationType& t) const
{
TransformType res;
res.matrix().setZero();
res.linear().diagonal() = coeffs();
res.translation() = m_coeffs.cwise() * t.vector();
res(Dim,Dim) = Scalar(1);
return res;
}
template<typename Scalar, int Dim>
inline typename Scaling<Scalar,Dim>::TransformType
Scaling<Scalar,Dim>::operator* (const TransformType& t) const
{
TransformType res = t;
res.prescale(m_coeffs);
return res;
}
#endif // EIGEN_SCALING_H

View File

@@ -0,0 +1,785 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_TRANSFORM_H
#define EIGEN_TRANSFORM_H
/** Represents some traits of a transformation */
enum TransformTraits {
Isometry, ///< the transformation is a concatenation of translations and rotations
Affine, ///< the transformation is affine (linear transformation + translation)
Projective ///< the transformation might not be affine
};
// Note that we have to pass Dim and HDim because it is not allowed to use a template
// parameter to define a template specialization. To be more precise, in the following
// specializations, it is not allowed to use Dim+1 instead of HDim.
template< typename Other,
int Dim,
int HDim,
int OtherRows=Other::RowsAtCompileTime,
int OtherCols=Other::ColsAtCompileTime>
struct ei_transform_product_impl;
/** \geometry_module \ingroup Geometry_Module
*
* \class Transform
*
* \brief Represents an homogeneous transformation in a N dimensional space
*
* \param _Scalar the scalar type, i.e., the type of the coefficients
* \param _Dim the dimension of the space
*
* The homography is internally represented and stored as a (Dim+1)^2 matrix which
* is available through the matrix() method.
*
* Conversion methods from/to Qt's QMatrix and QTransform are available if the
* preprocessor token EIGEN_QT_SUPPORT is defined.
*
* \sa class Matrix, class Quaternion
*/
template<typename _Scalar, int _Dim>
class Transform
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim==Dynamic ? Dynamic : (_Dim+1)*(_Dim+1))
enum {
Dim = _Dim, ///< space dimension in which the transformation holds
HDim = _Dim+1 ///< size of a respective homogeneous vector
};
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
/** type of the matrix used to represent the transformation */
typedef Matrix<Scalar,HDim,HDim> MatrixType;
/** type of the matrix used to represent the linear part of the transformation */
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
/** type of read/write reference to the linear part of the transformation */
typedef Block<MatrixType,Dim,Dim> LinearPart;
/** type of a vector */
typedef Matrix<Scalar,Dim,1> VectorType;
/** type of a read/write reference to the translation part of the rotation */
typedef Block<MatrixType,Dim,1> TranslationPart;
/** corresponding translation type */
typedef Translation<Scalar,Dim> TranslationType;
/** corresponding scaling transformation type */
typedef Scaling<Scalar,Dim> ScalingType;
protected:
MatrixType m_matrix;
public:
/** Default constructor without initialization of the coefficients. */
inline Transform() { }
inline Transform(const Transform& other)
{
m_matrix = other.m_matrix;
}
inline explicit Transform(const TranslationType& t) { *this = t; }
inline explicit Transform(const ScalingType& s) { *this = s; }
template<typename Derived>
inline explicit Transform(const RotationBase<Derived, Dim>& r) { *this = r; }
inline Transform& operator=(const Transform& other)
{ m_matrix = other.m_matrix; return *this; }
template<typename OtherDerived, bool BigMatrix> // MSVC 2005 will commit suicide if BigMatrix has a default value
struct construct_from_matrix
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->matrix() = other;
}
};
template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true>
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
{
transform->linear() = other;
transform->translation().setZero();
transform->matrix()(Dim,Dim) = Scalar(1);
transform->matrix().template block<1,Dim>(Dim,0).setZero();
}
};
/** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline explicit Transform(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived, int(OtherDerived::RowsAtCompileTime) == Dim>::run(this, other);
}
/** Set \c *this from a (Dim+1)^2 matrix. */
template<typename OtherDerived>
inline Transform& operator=(const MatrixBase<OtherDerived>& other)
{ m_matrix = other; return *this; }
#ifdef EIGEN_QT_SUPPORT
inline Transform(const QMatrix& other);
inline Transform& operator=(const QMatrix& other);
inline QMatrix toQMatrix(void) const;
inline Transform(const QTransform& other);
inline Transform& operator=(const QTransform& other);
inline QTransform toQTransform(void) const;
#endif
/** shortcut for m_matrix(row,col);
* \sa MatrixBase::operaror(int,int) const */
inline Scalar operator() (int row, int col) const { return m_matrix(row,col); }
/** shortcut for m_matrix(row,col);
* \sa MatrixBase::operaror(int,int) */
inline Scalar& operator() (int row, int col) { return m_matrix(row,col); }
/** \returns a read-only expression of the transformation matrix */
inline const MatrixType& matrix() const { return m_matrix; }
/** \returns a writable expression of the transformation matrix */
inline MatrixType& matrix() { return m_matrix; }
/** \returns a read-only expression of the linear (linear) part of the transformation */
inline const LinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
/** \returns a writable expression of the linear (linear) part of the transformation */
inline LinearPart linear() { return m_matrix.template block<Dim,Dim>(0,0); }
/** \returns a read-only expression of the translation vector of the transformation */
inline const TranslationPart translation() const { return m_matrix.template block<Dim,1>(0,Dim); }
/** \returns a writable expression of the translation vector of the transformation */
inline TranslationPart translation() { return m_matrix.template block<Dim,1>(0,Dim); }
/** \returns an expression of the product between the transform \c *this and a matrix expression \a other
*
* The right hand side \a other might be either:
* \li a vector of size Dim,
* \li an homogeneous vector of size Dim+1,
* \li a transformation matrix of size Dim+1 x Dim+1.
*/
// note: this function is defined here because some compilers cannot find the respective declaration
template<typename OtherDerived>
inline const typename ei_transform_product_impl<OtherDerived,_Dim,_Dim+1>::ResultType
operator * (const MatrixBase<OtherDerived> &other) const
{ return ei_transform_product_impl<OtherDerived,Dim,HDim>::run(*this,other.derived()); }
/** \returns the product expression of a transformation matrix \a a times a transform \a b
* The transformation matrix \a a must have a Dim+1 x Dim+1 sizes. */
template<typename OtherDerived>
friend inline const typename ProductReturnType<OtherDerived,MatrixType>::Type
operator * (const MatrixBase<OtherDerived> &a, const Transform &b)
{ return a.derived() * b.matrix(); }
/** Contatenates two transformations */
inline const Transform
operator * (const Transform& other) const
{ return Transform(m_matrix * other.matrix()); }
/** \sa MatrixBase::setIdentity() */
void setIdentity() { m_matrix.setIdentity(); }
static const typename MatrixType::IdentityReturnType Identity()
{
return MatrixType::Identity();
}
template<typename OtherDerived>
inline Transform& scale(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived>
inline Transform& prescale(const MatrixBase<OtherDerived> &other);
inline Transform& scale(Scalar s);
inline Transform& prescale(Scalar s);
template<typename OtherDerived>
inline Transform& translate(const MatrixBase<OtherDerived> &other);
template<typename OtherDerived>
inline Transform& pretranslate(const MatrixBase<OtherDerived> &other);
template<typename RotationType>
inline Transform& rotate(const RotationType& rotation);
template<typename RotationType>
inline Transform& prerotate(const RotationType& rotation);
Transform& shear(Scalar sx, Scalar sy);
Transform& preshear(Scalar sx, Scalar sy);
inline Transform& operator=(const TranslationType& t);
inline Transform& operator*=(const TranslationType& t) { return translate(t.vector()); }
inline Transform operator*(const TranslationType& t) const;
inline Transform& operator=(const ScalingType& t);
inline Transform& operator*=(const ScalingType& s) { return scale(s.coeffs()); }
inline Transform operator*(const ScalingType& s) const;
friend inline Transform operator*(const LinearMatrixType& mat, const Transform& t)
{
Transform res = t;
res.matrix().row(Dim) = t.matrix().row(Dim);
res.matrix().template block<Dim,HDim>(0,0) = (mat * t.matrix().template block<Dim,HDim>(0,0)).lazy();
return res;
}
template<typename Derived>
inline Transform& operator=(const RotationBase<Derived,Dim>& r);
template<typename Derived>
inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }
template<typename Derived>
inline Transform operator*(const RotationBase<Derived,Dim>& r) const;
LinearMatrixType rotation() const;
template<typename RotationMatrixType, typename ScalingMatrixType>
void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const;
template<typename ScalingMatrixType, typename RotationMatrixType>
void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const;
template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);
inline const MatrixType inverse(TransformTraits traits = Affine) const;
/** \returns a const pointer to the column major internal matrix */
const Scalar* data() const { return m_matrix.data(); }
/** \returns a non-const pointer to the column major internal matrix */
Scalar* data() { return m_matrix.data(); }
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Transform,Transform<NewScalarType,Dim> >::type cast() const
{ return typename ei_cast_return_type<Transform,Transform<NewScalarType,Dim> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Transform(const Transform<OtherScalarType,Dim>& other)
{ m_matrix = other.matrix().template cast<Scalar>(); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Transform& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_matrix.isApprox(other.m_matrix, prec); }
#ifdef EIGEN_TRANSFORM_PLUGIN
#include EIGEN_TRANSFORM_PLUGIN
#endif
protected:
};
/** \ingroup Geometry_Module */
typedef Transform<float,2> Transform2f;
/** \ingroup Geometry_Module */
typedef Transform<float,3> Transform3f;
/** \ingroup Geometry_Module */
typedef Transform<double,2> Transform2d;
/** \ingroup Geometry_Module */
typedef Transform<double,3> Transform3d;
/**************************
*** Optional QT support ***
**************************/
#ifdef EIGEN_QT_SUPPORT
/** Initialises \c *this from a QMatrix assuming the dimension is 2.
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>::Transform(const QMatrix& other)
{
*this = other;
}
/** Set \c *this from a QMatrix assuming the dimension is 2.
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const QMatrix& other)
{
EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
m_matrix << other.m11(), other.m21(), other.dx(),
other.m12(), other.m22(), other.dy(),
0, 0, 1;
return *this;
}
/** \returns a QMatrix from \c *this assuming the dimension is 2.
*
* \warning this convertion might loss data if \c *this is not affine
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
QMatrix Transform<Scalar,Dim>::toQMatrix(void) const
{
EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
m_matrix.coeff(0,1), m_matrix.coeff(1,1),
m_matrix.coeff(0,2), m_matrix.coeff(1,2));
}
/** Initialises \c *this from a QTransform assuming the dimension is 2.
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>::Transform(const QTransform& other)
{
*this = other;
}
/** Set \c *this from a QTransform assuming the dimension is 2.
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const QTransform& other)
{
EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
m_matrix << other.m11(), other.m21(), other.dx(),
other.m12(), other.m22(), other.dy(),
other.m13(), other.m23(), other.m33();
return *this;
}
/** \returns a QTransform from \c *this assuming the dimension is 2.
*
* This function is available only if the token EIGEN_QT_SUPPORT is defined.
*/
template<typename Scalar, int Dim>
QTransform Transform<Scalar,Dim>::toQTransform(void) const
{
EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
}
#endif
/*********************
*** Procedural API ***
*********************/
/** Applies on the right the non uniform scale transformation represented
* by the vector \a other to \c *this and returns a reference to \c *this.
* \sa prescale()
*/
template<typename Scalar, int Dim>
template<typename OtherDerived>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::scale(const MatrixBase<OtherDerived> &other)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
linear() = (linear() * other.asDiagonal()).lazy();
return *this;
}
/** Applies on the right a uniform scale of a factor \a c to \c *this
* and returns a reference to \c *this.
* \sa prescale(Scalar)
*/
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::scale(Scalar s)
{
linear() *= s;
return *this;
}
/** Applies on the left the non uniform scale transformation represented
* by the vector \a other to \c *this and returns a reference to \c *this.
* \sa scale()
*/
template<typename Scalar, int Dim>
template<typename OtherDerived>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::prescale(const MatrixBase<OtherDerived> &other)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
m_matrix.template block<Dim,HDim>(0,0) = (other.asDiagonal() * m_matrix.template block<Dim,HDim>(0,0)).lazy();
return *this;
}
/** Applies on the left a uniform scale of a factor \a c to \c *this
* and returns a reference to \c *this.
* \sa scale(Scalar)
*/
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::prescale(Scalar s)
{
m_matrix.template corner<Dim,HDim>(TopLeft) *= s;
return *this;
}
/** Applies on the right the translation matrix represented by the vector \a other
* to \c *this and returns a reference to \c *this.
* \sa pretranslate()
*/
template<typename Scalar, int Dim>
template<typename OtherDerived>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::translate(const MatrixBase<OtherDerived> &other)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
translation() += linear() * other;
return *this;
}
/** Applies on the left the translation matrix represented by the vector \a other
* to \c *this and returns a reference to \c *this.
* \sa translate()
*/
template<typename Scalar, int Dim>
template<typename OtherDerived>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::pretranslate(const MatrixBase<OtherDerived> &other)
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
translation() += other;
return *this;
}
/** Applies on the right the rotation represented by the rotation \a rotation
* to \c *this and returns a reference to \c *this.
*
* The template parameter \a RotationType is the type of the rotation which
* must be known by ei_toRotationMatrix<>.
*
* Natively supported types includes:
* - any scalar (2D),
* - a Dim x Dim matrix expression,
* - a Quaternion (3D),
* - a AngleAxis (3D)
*
* This mechanism is easily extendable to support user types such as Euler angles,
* or a pair of Quaternion for 4D rotations.
*
* \sa rotate(Scalar), class Quaternion, class AngleAxis, prerotate(RotationType)
*/
template<typename Scalar, int Dim>
template<typename RotationType>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::rotate(const RotationType& rotation)
{
linear() *= ei_toRotationMatrix<Scalar,Dim>(rotation);
return *this;
}
/** Applies on the left the rotation represented by the rotation \a rotation
* to \c *this and returns a reference to \c *this.
*
* See rotate() for further details.
*
* \sa rotate()
*/
template<typename Scalar, int Dim>
template<typename RotationType>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::prerotate(const RotationType& rotation)
{
m_matrix.template block<Dim,HDim>(0,0) = ei_toRotationMatrix<Scalar,Dim>(rotation)
* m_matrix.template block<Dim,HDim>(0,0);
return *this;
}
/** Applies on the right the shear transformation represented
* by the vector \a other to \c *this and returns a reference to \c *this.
* \warning 2D only.
* \sa preshear()
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::shear(Scalar sx, Scalar sy)
{
EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
VectorType tmp = linear().col(0)*sy + linear().col(1);
linear() << linear().col(0) + linear().col(1)*sx, tmp;
return *this;
}
/** Applies on the left the shear transformation represented
* by the vector \a other to \c *this and returns a reference to \c *this.
* \warning 2D only.
* \sa shear()
*/
template<typename Scalar, int Dim>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::preshear(Scalar sx, Scalar sy)
{
EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
return *this;
}
/******************************************************
*** Scaling, Translation and Rotation compatibility ***
******************************************************/
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const TranslationType& t)
{
linear().setIdentity();
translation() = t.vector();
m_matrix.template block<1,Dim>(Dim,0).setZero();
m_matrix(Dim,Dim) = Scalar(1);
return *this;
}
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const TranslationType& t) const
{
Transform res = *this;
res.translate(t.vector());
return res;
}
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const ScalingType& s)
{
m_matrix.setZero();
linear().diagonal() = s.coeffs();
m_matrix.coeffRef(Dim,Dim) = Scalar(1);
return *this;
}
template<typename Scalar, int Dim>
inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const ScalingType& s) const
{
Transform res = *this;
res.scale(s.coeffs());
return res;
}
template<typename Scalar, int Dim>
template<typename Derived>
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const RotationBase<Derived,Dim>& r)
{
linear() = ei_toRotationMatrix<Scalar,Dim>(r);
translation().setZero();
m_matrix.template block<1,Dim>(Dim,0).setZero();
m_matrix.coeffRef(Dim,Dim) = Scalar(1);
return *this;
}
template<typename Scalar, int Dim>
template<typename Derived>
inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const RotationBase<Derived,Dim>& r) const
{
Transform res = *this;
res.rotate(r.derived());
return res;
}
/************************
*** Special functions ***
************************/
/** \returns the rotation part of the transformation
* \nonstableyet
*
* \svd_module
*
* \sa computeRotationScaling(), computeScalingRotation(), class SVD
*/
template<typename Scalar, int Dim>
typename Transform<Scalar,Dim>::LinearMatrixType
Transform<Scalar,Dim>::rotation() const
{
LinearMatrixType result;
computeRotationScaling(&result, (LinearMatrixType*)0);
return result;
}
/** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being
* not necessarily positive.
*
* If either pointer is zero, the corresponding computation is skipped.
*
* \nonstableyet
*
* \svd_module
*
* \sa computeScalingRotation(), rotation(), class SVD
*/
template<typename Scalar, int Dim>
template<typename RotationMatrixType, typename ScalingMatrixType>
void Transform<Scalar,Dim>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
{
linear().svd().computeRotationScaling(rotation, scaling);
}
/** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being
* not necessarily positive.
*
* If either pointer is zero, the corresponding computation is skipped.
*
* \nonstableyet
*
* \svd_module
*
* \sa computeRotationScaling(), rotation(), class SVD
*/
template<typename Scalar, int Dim>
template<typename ScalingMatrixType, typename RotationMatrixType>
void Transform<Scalar,Dim>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
{
linear().svd().computeScalingRotation(scaling, rotation);
}
/** Convenient method to set \c *this from a position, orientation and scale
* of a 3D object.
*/
template<typename Scalar, int Dim>
template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
Transform<Scalar,Dim>&
Transform<Scalar,Dim>::fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale)
{
linear() = ei_toRotationMatrix<Scalar,Dim>(orientation);
linear() *= scale.asDiagonal();
translation() = position;
m_matrix.template block<1,Dim>(Dim,0).setZero();
m_matrix(Dim,Dim) = Scalar(1);
return *this;
}
/** \nonstableyet
*
* \returns the inverse transformation matrix according to some given knowledge
* on \c *this.
*
* \param traits allows to optimize the inversion process when the transformion
* is known to be not a general transformation. The possible values are:
* - Projective if the transformation is not necessarily affine, i.e., if the
* last row is not guaranteed to be [0 ... 0 1]
* - Affine is the default, the last row is assumed to be [0 ... 0 1]
* - Isometry if the transformation is only a concatenations of translations
* and rotations.
*
* \warning unless \a traits is always set to NoShear or NoScaling, this function
* requires the generic inverse method of MatrixBase defined in the LU module. If
* you forget to include this module, then you will get hard to debug linking errors.
*
* \sa MatrixBase::inverse()
*/
template<typename Scalar, int Dim>
inline const typename Transform<Scalar,Dim>::MatrixType
Transform<Scalar,Dim>::inverse(TransformTraits traits) const
{
if (traits == Projective)
{
return m_matrix.inverse();
}
else
{
MatrixType res;
if (traits == Affine)
{
res.template corner<Dim,Dim>(TopLeft) = linear().inverse();
}
else if (traits == Isometry)
{
res.template corner<Dim,Dim>(TopLeft) = linear().transpose();
}
else
{
ei_assert("invalid traits value in Transform::inverse()");
}
// translation and remaining parts
res.template corner<Dim,1>(TopRight) = - res.template corner<Dim,Dim>(TopLeft) * translation();
res.template corner<1,Dim>(BottomLeft).setZero();
res.coeffRef(Dim,Dim) = Scalar(1);
return res;
}
}
/*****************************************************
*** Specializations of operator* with a MatrixBase ***
*****************************************************/
template<typename Other, int Dim, int HDim>
struct ei_transform_product_impl<Other,Dim,HDim, HDim,HDim>
{
typedef Transform<typename Other::Scalar,Dim> TransformType;
typedef typename TransformType::MatrixType MatrixType;
typedef typename ProductReturnType<MatrixType,Other>::Type ResultType;
static ResultType run(const TransformType& tr, const Other& other)
{ return tr.matrix() * other; }
};
template<typename Other, int Dim, int HDim>
struct ei_transform_product_impl<Other,Dim,HDim, Dim,Dim>
{
typedef Transform<typename Other::Scalar,Dim> TransformType;
typedef typename TransformType::MatrixType MatrixType;
typedef TransformType ResultType;
static ResultType run(const TransformType& tr, const Other& other)
{
TransformType res;
res.translation() = tr.translation();
res.matrix().row(Dim) = tr.matrix().row(Dim);
res.linear() = (tr.linear() * other).lazy();
return res;
}
};
template<typename Other, int Dim, int HDim>
struct ei_transform_product_impl<Other,Dim,HDim, HDim,1>
{
typedef Transform<typename Other::Scalar,Dim> TransformType;
typedef typename TransformType::MatrixType MatrixType;
typedef typename ProductReturnType<MatrixType,Other>::Type ResultType;
static ResultType run(const TransformType& tr, const Other& other)
{ return tr.matrix() * other; }
};
template<typename Other, int Dim, int HDim>
struct ei_transform_product_impl<Other,Dim,HDim, Dim,1>
{
typedef typename Other::Scalar Scalar;
typedef Transform<Scalar,Dim> TransformType;
typedef typename TransformType::LinearPart MatrixType;
typedef const CwiseUnaryOp<
ei_scalar_multiple_op<Scalar>,
NestByValue<CwiseBinaryOp<
ei_scalar_sum_op<Scalar>,
NestByValue<typename ProductReturnType<NestByValue<MatrixType>,Other>::Type >,
NestByValue<typename TransformType::TranslationPart> > >
> ResultType;
// FIXME should we offer an optimized version when the last row is known to be 0,0...,0,1 ?
static ResultType run(const TransformType& tr, const Other& other)
{ return ((tr.linear().nestByValue() * other).nestByValue() + tr.translation().nestByValue()).nestByValue()
* (Scalar(1) / ( (tr.matrix().template block<1,Dim>(Dim,0) * other).coeff(0) + tr.matrix().coeff(Dim,Dim))); }
};
#endif // EIGEN_TRANSFORM_H

View File

@@ -0,0 +1,198 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_TRANSLATION_H
#define EIGEN_TRANSLATION_H
/** \geometry_module \ingroup Geometry_Module
*
* \class Translation
*
* \brief Represents a translation transformation
*
* \param _Scalar the scalar type, i.e., the type of the coefficients.
* \param _Dim the dimension of the space, can be a compile time value or Dynamic
*
* \note This class is not aimed to be used to store a translation transformation,
* but rather to make easier the constructions and updates of Transform objects.
*
* \sa class Scaling, class Transform
*/
template<typename _Scalar, int _Dim>
class Translation
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)
/** dimension of the space */
enum { Dim = _Dim };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
/** corresponding vector type */
typedef Matrix<Scalar,Dim,1> VectorType;
/** corresponding linear transformation matrix type */
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
/** corresponding scaling transformation type */
typedef Scaling<Scalar,Dim> ScalingType;
/** corresponding affine transformation type */
typedef Transform<Scalar,Dim> TransformType;
protected:
VectorType m_coeffs;
public:
/** Default constructor without initialization. */
Translation() {}
/** */
inline Translation(const Scalar& sx, const Scalar& sy)
{
ei_assert(Dim==2);
m_coeffs.x() = sx;
m_coeffs.y() = sy;
}
/** */
inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)
{
ei_assert(Dim==3);
m_coeffs.x() = sx;
m_coeffs.y() = sy;
m_coeffs.z() = sz;
}
/** Constructs and initialize the scaling transformation from a vector of scaling coefficients */
explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}
const VectorType& vector() const { return m_coeffs; }
VectorType& vector() { return m_coeffs; }
/** Concatenates two translation */
inline Translation operator* (const Translation& other) const
{ return Translation(m_coeffs + other.m_coeffs); }
/** Concatenates a translation and a scaling */
inline TransformType operator* (const ScalingType& other) const;
/** Concatenates a translation and a linear transformation */
inline TransformType operator* (const LinearMatrixType& linear) const;
template<typename Derived>
inline TransformType operator*(const RotationBase<Derived,Dim>& r) const
{ return *this * r.toRotationMatrix(); }
/** Concatenates a linear transformation and a translation */
// its a nightmare to define a templated friend function outside its declaration
friend inline TransformType operator* (const LinearMatrixType& linear, const Translation& t)
{
TransformType res;
res.matrix().setZero();
res.linear() = linear;
res.translation() = linear * t.m_coeffs;
res.matrix().row(Dim).setZero();
res(Dim,Dim) = Scalar(1);
return res;
}
/** Concatenates a translation and an affine transformation */
inline TransformType operator* (const TransformType& t) const;
/** Applies translation to vector */
inline VectorType operator* (const VectorType& other) const
{ return m_coeffs + other; }
/** \returns the inverse translation (opposite) */
Translation inverse() const { return Translation(-m_coeffs); }
Translation& operator=(const Translation& other)
{
m_coeffs = other.m_coeffs;
return *this;
}
/** \returns \c *this with scalar type casted to \a NewScalarType
*
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
* then this function smartly returns a const reference to \c *this.
*/
template<typename NewScalarType>
inline typename ei_cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const
{ return typename ei_cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }
/** Copy constructor with scalar type conversion */
template<typename OtherScalarType>
inline explicit Translation(const Translation<OtherScalarType,Dim>& other)
{ m_coeffs = other.vector().template cast<Scalar>(); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
*
* \sa MatrixBase::isApprox() */
bool isApprox(const Translation& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
};
/** \addtogroup Geometry_Module */
//@{
typedef Translation<float, 2> Translation2f;
typedef Translation<double,2> Translation2d;
typedef Translation<float, 3> Translation3f;
typedef Translation<double,3> Translation3d;
//@}
template<typename Scalar, int Dim>
inline typename Translation<Scalar,Dim>::TransformType
Translation<Scalar,Dim>::operator* (const ScalingType& other) const
{
TransformType res;
res.matrix().setZero();
res.linear().diagonal() = other.coeffs();
res.translation() = m_coeffs;
res(Dim,Dim) = Scalar(1);
return res;
}
template<typename Scalar, int Dim>
inline typename Translation<Scalar,Dim>::TransformType
Translation<Scalar,Dim>::operator* (const LinearMatrixType& linear) const
{
TransformType res;
res.matrix().setZero();
res.linear() = linear;
res.translation() = m_coeffs;
res.matrix().row(Dim).setZero();
res(Dim,Dim) = Scalar(1);
return res;
}
template<typename Scalar, int Dim>
inline typename Translation<Scalar,Dim>::TransformType
Translation<Scalar,Dim>::operator* (const TransformType& t) const
{
TransformType res = t;
res.pretranslate(m_coeffs);
return res;
}
#endif // EIGEN_TRANSLATION_H

122
extern/Eigen2/Eigen/src/LU/Determinant.h vendored Normal file
View File

@@ -0,0 +1,122 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_DETERMINANT_H
#define EIGEN_DETERMINANT_H
template<typename Derived>
inline const typename Derived::Scalar ei_bruteforce_det3_helper
(const MatrixBase<Derived>& matrix, int a, int b, int c)
{
return matrix.coeff(0,a)
* (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b));
}
template<typename Derived>
const typename Derived::Scalar ei_bruteforce_det4_helper
(const MatrixBase<Derived>& matrix, int j, int k, int m, int n)
{
return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1))
* (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3));
}
const int TriangularDeterminant = 0;
template<typename Derived,
int DeterminantType =
(Derived::Flags & (UpperTriangularBit | LowerTriangularBit))
? TriangularDeterminant : Derived::RowsAtCompileTime
> struct ei_determinant_impl
{
static inline typename ei_traits<Derived>::Scalar run(const Derived& m)
{
return m.lu().determinant();
}
};
template<typename Derived> struct ei_determinant_impl<Derived, TriangularDeterminant>
{
static inline typename ei_traits<Derived>::Scalar run(const Derived& m)
{
if (Derived::Flags & UnitDiagBit)
return 1;
else if (Derived::Flags & ZeroDiagBit)
return 0;
else
return m.diagonal().redux(ei_scalar_product_op<typename ei_traits<Derived>::Scalar>());
}
};
template<typename Derived> struct ei_determinant_impl<Derived, 1>
{
static inline typename ei_traits<Derived>::Scalar run(const Derived& m)
{
return m.coeff(0,0);
}
};
template<typename Derived> struct ei_determinant_impl<Derived, 2>
{
static inline typename ei_traits<Derived>::Scalar run(const Derived& m)
{
return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1);
}
};
template<typename Derived> struct ei_determinant_impl<Derived, 3>
{
static typename ei_traits<Derived>::Scalar run(const Derived& m)
{
return ei_bruteforce_det3_helper(m,0,1,2)
- ei_bruteforce_det3_helper(m,1,0,2)
+ ei_bruteforce_det3_helper(m,2,0,1);
}
};
template<typename Derived> struct ei_determinant_impl<Derived, 4>
{
static typename ei_traits<Derived>::Scalar run(const Derived& m)
{
// trick by Martin Costabel to compute 4x4 det with only 30 muls
return ei_bruteforce_det4_helper(m,0,1,2,3)
- ei_bruteforce_det4_helper(m,0,2,1,3)
+ ei_bruteforce_det4_helper(m,0,3,1,2)
+ ei_bruteforce_det4_helper(m,1,2,0,3)
- ei_bruteforce_det4_helper(m,1,3,0,2)
+ ei_bruteforce_det4_helper(m,2,3,0,1);
}
};
/** \lu_module
*
* \returns the determinant of this matrix
*/
template<typename Derived>
inline typename ei_traits<Derived>::Scalar MatrixBase<Derived>::determinant() const
{
assert(rows() == cols());
return ei_determinant_impl<Derived>::run(derived());
}
#endif // EIGEN_DETERMINANT_H

258
extern/Eigen2/Eigen/src/LU/Inverse.h vendored Normal file
View File

@@ -0,0 +1,258 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_INVERSE_H
#define EIGEN_INVERSE_H
/********************************************************************
*** Part 1 : optimized implementations for fixed-size 2,3,4 cases ***
********************************************************************/
template<typename MatrixType>
void ei_compute_inverse_in_size2_case(const MatrixType& matrix, MatrixType* result)
{
typedef typename MatrixType::Scalar Scalar;
const Scalar invdet = Scalar(1) / matrix.determinant();
result->coeffRef(0,0) = matrix.coeff(1,1) * invdet;
result->coeffRef(1,0) = -matrix.coeff(1,0) * invdet;
result->coeffRef(0,1) = -matrix.coeff(0,1) * invdet;
result->coeffRef(1,1) = matrix.coeff(0,0) * invdet;
}
template<typename XprType, typename MatrixType>
bool ei_compute_inverse_in_size2_case_with_check(const XprType& matrix, MatrixType* result)
{
typedef typename MatrixType::Scalar Scalar;
const Scalar det = matrix.determinant();
if(ei_isMuchSmallerThan(det, matrix.cwise().abs().maxCoeff())) return false;
const Scalar invdet = Scalar(1) / det;
result->coeffRef(0,0) = matrix.coeff(1,1) * invdet;
result->coeffRef(1,0) = -matrix.coeff(1,0) * invdet;
result->coeffRef(0,1) = -matrix.coeff(0,1) * invdet;
result->coeffRef(1,1) = matrix.coeff(0,0) * invdet;
return true;
}
template<typename MatrixType>
void ei_compute_inverse_in_size3_case(const MatrixType& matrix, MatrixType* result)
{
typedef typename MatrixType::Scalar Scalar;
const Scalar det_minor00 = matrix.minor(0,0).determinant();
const Scalar det_minor10 = matrix.minor(1,0).determinant();
const Scalar det_minor20 = matrix.minor(2,0).determinant();
const Scalar invdet = Scalar(1) / ( det_minor00 * matrix.coeff(0,0)
- det_minor10 * matrix.coeff(1,0)
+ det_minor20 * matrix.coeff(2,0) );
result->coeffRef(0, 0) = det_minor00 * invdet;
result->coeffRef(0, 1) = -det_minor10 * invdet;
result->coeffRef(0, 2) = det_minor20 * invdet;
result->coeffRef(1, 0) = -matrix.minor(0,1).determinant() * invdet;
result->coeffRef(1, 1) = matrix.minor(1,1).determinant() * invdet;
result->coeffRef(1, 2) = -matrix.minor(2,1).determinant() * invdet;
result->coeffRef(2, 0) = matrix.minor(0,2).determinant() * invdet;
result->coeffRef(2, 1) = -matrix.minor(1,2).determinant() * invdet;
result->coeffRef(2, 2) = matrix.minor(2,2).determinant() * invdet;
}
template<typename MatrixType>
bool ei_compute_inverse_in_size4_case_helper(const MatrixType& matrix, MatrixType* result)
{
/* Let's split M into four 2x2 blocks:
* (P Q)
* (R S)
* If P is invertible, with inverse denoted by P_inverse, and if
* (S - R*P_inverse*Q) is also invertible, then the inverse of M is
* (P' Q')
* (R' S')
* where
* S' = (S - R*P_inverse*Q)^(-1)
* P' = P1 + (P1*Q) * S' *(R*P_inverse)
* Q' = -(P_inverse*Q) * S'
* R' = -S' * (R*P_inverse)
*/
typedef Block<MatrixType,2,2> XprBlock22;
typedef typename MatrixBase<XprBlock22>::PlainMatrixType Block22;
Block22 P_inverse;
if(ei_compute_inverse_in_size2_case_with_check(matrix.template block<2,2>(0,0), &P_inverse))
{
const Block22 Q = matrix.template block<2,2>(0,2);
const Block22 P_inverse_times_Q = P_inverse * Q;
const XprBlock22 R = matrix.template block<2,2>(2,0);
const Block22 R_times_P_inverse = R * P_inverse;
const Block22 R_times_P_inverse_times_Q = R_times_P_inverse * Q;
const XprBlock22 S = matrix.template block<2,2>(2,2);
const Block22 X = S - R_times_P_inverse_times_Q;
Block22 Y;
ei_compute_inverse_in_size2_case(X, &Y);
result->template block<2,2>(2,2) = Y;
result->template block<2,2>(2,0) = - Y * R_times_P_inverse;
const Block22 Z = P_inverse_times_Q * Y;
result->template block<2,2>(0,2) = - Z;
result->template block<2,2>(0,0) = P_inverse + Z * R_times_P_inverse;
return true;
}
else
{
return false;
}
}
template<typename MatrixType>
void ei_compute_inverse_in_size4_case(const MatrixType& matrix, MatrixType* result)
{
if(ei_compute_inverse_in_size4_case_helper(matrix, result))
{
// good ! The topleft 2x2 block was invertible, so the 2x2 blocks approach is successful.
return;
}
else
{
// rare case: the topleft 2x2 block is not invertible (but the matrix itself is assumed to be).
// since this is a rare case, we don't need to optimize it. We just want to handle it with little
// additional code.
MatrixType m(matrix);
m.row(0).swap(m.row(2));
m.row(1).swap(m.row(3));
if(ei_compute_inverse_in_size4_case_helper(m, result))
{
// good, the topleft 2x2 block of m is invertible. Since m is different from matrix in that some
// rows were permuted, the actual inverse of matrix is derived from the inverse of m by permuting
// the corresponding columns.
result->col(0).swap(result->col(2));
result->col(1).swap(result->col(3));
}
else
{
// last possible case. Since matrix is assumed to be invertible, this last case has to work.
// first, undo the swaps previously made
m.row(0).swap(m.row(2));
m.row(1).swap(m.row(3));
// swap row 0 with the the row among 0 and 1 that has the biggest 2 first coeffs
int swap0with = ei_abs(m.coeff(0,0))+ei_abs(m.coeff(0,1))>ei_abs(m.coeff(1,0))+ei_abs(m.coeff(1,1)) ? 0 : 1;
m.row(0).swap(m.row(swap0with));
// swap row 1 with the the row among 2 and 3 that has the biggest 2 first coeffs
int swap1with = ei_abs(m.coeff(2,0))+ei_abs(m.coeff(2,1))>ei_abs(m.coeff(3,0))+ei_abs(m.coeff(3,1)) ? 2 : 3;
m.row(1).swap(m.row(swap1with));
ei_compute_inverse_in_size4_case_helper(m, result);
result->col(1).swap(result->col(swap1with));
result->col(0).swap(result->col(swap0with));
}
}
}
/***********************************************
*** Part 2 : selector and MatrixBase methods ***
***********************************************/
template<typename MatrixType, int Size = MatrixType::RowsAtCompileTime>
struct ei_compute_inverse
{
static inline void run(const MatrixType& matrix, MatrixType* result)
{
LU<MatrixType> lu(matrix);
lu.computeInverse(result);
}
};
template<typename MatrixType>
struct ei_compute_inverse<MatrixType, 1>
{
static inline void run(const MatrixType& matrix, MatrixType* result)
{
typedef typename MatrixType::Scalar Scalar;
result->coeffRef(0,0) = Scalar(1) / matrix.coeff(0,0);
}
};
template<typename MatrixType>
struct ei_compute_inverse<MatrixType, 2>
{
static inline void run(const MatrixType& matrix, MatrixType* result)
{
ei_compute_inverse_in_size2_case(matrix, result);
}
};
template<typename MatrixType>
struct ei_compute_inverse<MatrixType, 3>
{
static inline void run(const MatrixType& matrix, MatrixType* result)
{
ei_compute_inverse_in_size3_case(matrix, result);
}
};
template<typename MatrixType>
struct ei_compute_inverse<MatrixType, 4>
{
static inline void run(const MatrixType& matrix, MatrixType* result)
{
ei_compute_inverse_in_size4_case(matrix, result);
}
};
/** \lu_module
*
* Computes the matrix inverse of this matrix.
*
* \note This matrix must be invertible, otherwise the result is undefined.
*
* \param result Pointer to the matrix in which to store the result.
*
* Example: \include MatrixBase_computeInverse.cpp
* Output: \verbinclude MatrixBase_computeInverse.out
*
* \sa inverse()
*/
template<typename Derived>
inline void MatrixBase<Derived>::computeInverse(PlainMatrixType *result) const
{
ei_assert(rows() == cols());
EIGEN_STATIC_ASSERT(NumTraits<Scalar>::HasFloatingPoint,NUMERIC_TYPE_MUST_BE_FLOATING_POINT)
ei_compute_inverse<PlainMatrixType>::run(eval(), result);
}
/** \lu_module
*
* \returns the matrix inverse of this matrix.
*
* \note This matrix must be invertible, otherwise the result is undefined.
*
* \note This method returns a matrix by value, which can be inefficient. To avoid that overhead,
* use computeInverse() instead.
*
* Example: \include MatrixBase_inverse.cpp
* Output: \verbinclude MatrixBase_inverse.out
*
* \sa computeInverse()
*/
template<typename Derived>
inline const typename MatrixBase<Derived>::PlainMatrixType MatrixBase<Derived>::inverse() const
{
PlainMatrixType result(rows(), cols());
computeInverse(&result);
return result;
}
#endif // EIGEN_INVERSE_H

541
extern/Eigen2/Eigen/src/LU/LU.h vendored Normal file
View File

@@ -0,0 +1,541 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_LU_H
#define EIGEN_LU_H
/** \ingroup LU_Module
*
* \class LU
*
* \brief LU decomposition of a matrix with complete pivoting, and related features
*
* \param MatrixType the type of the matrix of which we are computing the LU decomposition
*
* This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A
* is decomposed as A = PLUQ where L is unit-lower-triangular, U is upper-triangular, and P and Q
* are permutation matrices. This is a rank-revealing LU decomposition. The eigenvalues (diagonal
* coefficients) of U are sorted in such a way that any zeros are at the end, so that the rank
* of A is the index of the first zero on the diagonal of U (with indices starting at 0) if any.
*
* This decomposition provides the generic approach to solving systems of linear equations, computing
* the rank, invertibility, inverse, kernel, and determinant.
*
* This LU decomposition is very stable and well tested with large matrices. Even exact rank computation
* works at sizes larger than 1000x1000. However there are use cases where the SVD decomposition is inherently
* more stable when dealing with numerically damaged input. For example, computing the kernel is more stable with
* SVD because the SVD can determine which singular values are negligible while LU has to work at the level of matrix
* coefficients that are less meaningful in this respect.
*
* The data of the LU decomposition can be directly accessed through the methods matrixLU(),
* permutationP(), permutationQ().
*
* As an exemple, here is how the original matrix can be retrieved:
* \include class_LU.cpp
* Output: \verbinclude class_LU.out
*
* \sa MatrixBase::lu(), MatrixBase::determinant(), MatrixBase::inverse(), MatrixBase::computeInverse()
*/
template<typename MatrixType> class LU
{
public:
typedef typename MatrixType::Scalar Scalar;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> ColVectorType;
enum { MaxSmallDimAtCompileTime = EIGEN_ENUM_MIN(
MatrixType::MaxColsAtCompileTime,
MatrixType::MaxRowsAtCompileTime)
};
typedef Matrix<typename MatrixType::Scalar,
MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
// so that the product "matrix * kernel = zero" makes sense
Dynamic, // we don't know at compile-time the dimension of the kernel
MatrixType::Options,
MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
// of columns of the original matrix
> KernelResultType;
typedef Matrix<typename MatrixType::Scalar,
MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
// of rows of the original matrix
Dynamic, // we don't know at compile time the dimension of the image (the rank)
MatrixType::Options,
MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
> ImageResultType;
/** Constructor.
*
* \param matrix the matrix of which to compute the LU decomposition.
*/
LU(const MatrixType& matrix);
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
* unit-lower-triangular part is L (at least for square matrices; in the non-square
* case, special care is needed, see the documentation of class LU).
*
* \sa matrixL(), matrixU()
*/
inline const MatrixType& matrixLU() const
{
return m_lu;
}
/** \returns a vector of integers, whose size is the number of rows of the matrix being decomposed,
* representing the P permutation i.e. the permutation of the rows. For its precise meaning,
* see the examples given in the documentation of class LU.
*
* \sa permutationQ()
*/
inline const IntColVectorType& permutationP() const
{
return m_p;
}
/** \returns a vector of integers, whose size is the number of columns of the matrix being
* decomposed, representing the Q permutation i.e. the permutation of the columns.
* For its precise meaning, see the examples given in the documentation of class LU.
*
* \sa permutationP()
*/
inline const IntRowVectorType& permutationQ() const
{
return m_q;
}
/** Computes a basis of the kernel of the matrix, also called the null-space of the matrix.
*
* \note This method is only allowed on non-invertible matrices, as determined by
* isInvertible(). Calling it on an invertible matrix will make an assertion fail.
*
* \param result a pointer to the matrix in which to store the kernel. The columns of this
* matrix will be set to form a basis of the kernel (it will be resized
* if necessary).
*
* Example: \include LU_computeKernel.cpp
* Output: \verbinclude LU_computeKernel.out
*
* \sa kernel(), computeImage(), image()
*/
template<typename KernelMatrixType>
void computeKernel(KernelMatrixType *result) const;
/** Computes a basis of the image of the matrix, also called the column-space or range of he matrix.
*
* \note Calling this method on the zero matrix will make an assertion fail.
*
* \param result a pointer to the matrix in which to store the image. The columns of this
* matrix will be set to form a basis of the image (it will be resized
* if necessary).
*
* Example: \include LU_computeImage.cpp
* Output: \verbinclude LU_computeImage.out
*
* \sa image(), computeKernel(), kernel()
*/
template<typename ImageMatrixType>
void computeImage(ImageMatrixType *result) const;
/** \returns the kernel of the matrix, also called its null-space. The columns of the returned matrix
* will form a basis of the kernel.
*
* \note: this method is only allowed on non-invertible matrices, as determined by
* isInvertible(). Calling it on an invertible matrix will make an assertion fail.
*
* \note: this method returns a matrix by value, which induces some inefficiency.
* If you prefer to avoid this overhead, use computeKernel() instead.
*
* Example: \include LU_kernel.cpp
* Output: \verbinclude LU_kernel.out
*
* \sa computeKernel(), image()
*/
const KernelResultType kernel() const;
/** \returns the image of the matrix, also called its column-space. The columns of the returned matrix
* will form a basis of the kernel.
*
* \note: Calling this method on the zero matrix will make an assertion fail.
*
* \note: this method returns a matrix by value, which induces some inefficiency.
* If you prefer to avoid this overhead, use computeImage() instead.
*
* Example: \include LU_image.cpp
* Output: \verbinclude LU_image.out
*
* \sa computeImage(), kernel()
*/
const ImageResultType image() const;
/** This method finds a solution x to the equation Ax=b, where A is the matrix of which
* *this is the LU decomposition, if any exists.
*
* \param b the right-hand-side of the equation to solve. Can be a vector or a matrix,
* the only requirement in order for the equation to make sense is that
* b.rows()==A.rows(), where A is the matrix of which *this is the LU decomposition.
* \param result a pointer to the vector or matrix in which to store the solution, if any exists.
* Resized if necessary, so that result->rows()==A.cols() and result->cols()==b.cols().
* If no solution exists, *result is left with undefined coefficients.
*
* \returns true if any solution exists, false if no solution exists.
*
* \note If there exist more than one solution, this method will arbitrarily choose one.
* If you need a complete analysis of the space of solutions, take the one solution obtained
* by this method and add to it elements of the kernel, as determined by kernel().
*
* Example: \include LU_solve.cpp
* Output: \verbinclude LU_solve.out
*
* \sa MatrixBase::solveTriangular(), kernel(), computeKernel(), inverse(), computeInverse()
*/
template<typename OtherDerived, typename ResultType>
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const;
/** \returns the determinant of the matrix of which
* *this is the LU decomposition. It has only linear complexity
* (that is, O(n) where n is the dimension of the square matrix)
* as the LU decomposition has already been computed.
*
* \note This is only for square matrices.
*
* \note For fixed-size matrices of size up to 4, MatrixBase::determinant() offers
* optimized paths.
*
* \warning a determinant can be very big or small, so for matrices
* of large enough dimension, there is a risk of overflow/underflow.
*
* \sa MatrixBase::determinant()
*/
typename ei_traits<MatrixType>::Scalar determinant() const;
/** \returns the rank of the matrix of which *this is the LU decomposition.
*
* \note This is computed at the time of the construction of the LU decomposition. This
* method does not perform any further computation.
*/
inline int rank() const
{
return m_rank;
}
/** \returns the dimension of the kernel of the matrix of which *this is the LU decomposition.
*
* \note Since the rank is computed at the time of the construction of the LU decomposition, this
* method almost does not perform any further computation.
*/
inline int dimensionOfKernel() const
{
return m_lu.cols() - m_rank;
}
/** \returns true if the matrix of which *this is the LU decomposition represents an injective
* linear map, i.e. has trivial kernel; false otherwise.
*
* \note Since the rank is computed at the time of the construction of the LU decomposition, this
* method almost does not perform any further computation.
*/
inline bool isInjective() const
{
return m_rank == m_lu.cols();
}
/** \returns true if the matrix of which *this is the LU decomposition represents a surjective
* linear map; false otherwise.
*
* \note Since the rank is computed at the time of the construction of the LU decomposition, this
* method almost does not perform any further computation.
*/
inline bool isSurjective() const
{
return m_rank == m_lu.rows();
}
/** \returns true if the matrix of which *this is the LU decomposition is invertible.
*
* \note Since the rank is computed at the time of the construction of the LU decomposition, this
* method almost does not perform any further computation.
*/
inline bool isInvertible() const
{
return isInjective() && isSurjective();
}
/** Computes the inverse of the matrix of which *this is the LU decomposition.
*
* \param result a pointer to the matrix into which to store the inverse. Resized if needed.
*
* \note If this matrix is not invertible, *result is left with undefined coefficients.
* Use isInvertible() to first determine whether this matrix is invertible.
*
* \sa MatrixBase::computeInverse(), inverse()
*/
inline void computeInverse(MatrixType *result) const
{
solve(MatrixType::Identity(m_lu.rows(), m_lu.cols()), result);
}
/** \returns the inverse of the matrix of which *this is the LU decomposition.
*
* \note If this matrix is not invertible, the returned matrix has undefined coefficients.
* Use isInvertible() to first determine whether this matrix is invertible.
*
* \sa computeInverse(), MatrixBase::inverse()
*/
inline MatrixType inverse() const
{
MatrixType result;
computeInverse(&result);
return result;
}
protected:
const MatrixType& m_originalMatrix;
MatrixType m_lu;
IntColVectorType m_p;
IntRowVectorType m_q;
int m_det_pq;
int m_rank;
RealScalar m_precision;
};
template<typename MatrixType>
LU<MatrixType>::LU(const MatrixType& matrix)
: m_originalMatrix(matrix),
m_lu(matrix),
m_p(matrix.rows()),
m_q(matrix.cols())
{
const int size = matrix.diagonal().size();
const int rows = matrix.rows();
const int cols = matrix.cols();
// this formula comes from experimenting (see "LU precision tuning" thread on the list)
// and turns out to be identical to Higham's formula used already in LDLt.
m_precision = machine_epsilon<Scalar>() * size;
IntColVectorType rows_transpositions(matrix.rows());
IntRowVectorType cols_transpositions(matrix.cols());
int number_of_transpositions = 0;
RealScalar biggest = RealScalar(0);
m_rank = size;
for(int k = 0; k < size; ++k)
{
int row_of_biggest_in_corner, col_of_biggest_in_corner;
RealScalar biggest_in_corner;
biggest_in_corner = m_lu.corner(Eigen::BottomRight, rows-k, cols-k)
.cwise().abs()
.maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);
row_of_biggest_in_corner += k;
col_of_biggest_in_corner += k;
if(k==0) biggest = biggest_in_corner;
// if the corner is negligible, then we have less than full rank, and we can finish early
if(ei_isMuchSmallerThan(biggest_in_corner, biggest, m_precision))
{
m_rank = k;
for(int i = k; i < size; i++)
{
rows_transpositions.coeffRef(i) = i;
cols_transpositions.coeffRef(i) = i;
}
break;
}
rows_transpositions.coeffRef(k) = row_of_biggest_in_corner;
cols_transpositions.coeffRef(k) = col_of_biggest_in_corner;
if(k != row_of_biggest_in_corner) {
m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
++number_of_transpositions;
}
if(k != col_of_biggest_in_corner) {
m_lu.col(k).swap(m_lu.col(col_of_biggest_in_corner));
++number_of_transpositions;
}
if(k<rows-1)
m_lu.col(k).end(rows-k-1) /= m_lu.coeff(k,k);
if(k<size-1)
for(int col = k + 1; col < cols; ++col)
m_lu.col(col).end(rows-k-1) -= m_lu.col(k).end(rows-k-1) * m_lu.coeff(k,col);
}
for(int k = 0; k < matrix.rows(); ++k) m_p.coeffRef(k) = k;
for(int k = size-1; k >= 0; --k)
std::swap(m_p.coeffRef(k), m_p.coeffRef(rows_transpositions.coeff(k)));
for(int k = 0; k < matrix.cols(); ++k) m_q.coeffRef(k) = k;
for(int k = 0; k < size; ++k)
std::swap(m_q.coeffRef(k), m_q.coeffRef(cols_transpositions.coeff(k)));
m_det_pq = (number_of_transpositions%2) ? -1 : 1;
}
template<typename MatrixType>
typename ei_traits<MatrixType>::Scalar LU<MatrixType>::determinant() const
{
return Scalar(m_det_pq) * m_lu.diagonal().redux(ei_scalar_product_op<Scalar>());
}
template<typename MatrixType>
template<typename KernelMatrixType>
void LU<MatrixType>::computeKernel(KernelMatrixType *result) const
{
ei_assert(!isInvertible());
const int dimker = dimensionOfKernel(), cols = m_lu.cols();
result->resize(cols, dimker);
/* Let us use the following lemma:
*
* Lemma: If the matrix A has the LU decomposition PAQ = LU,
* then Ker A = Q(Ker U).
*
* Proof: trivial: just keep in mind that P, Q, L are invertible.
*/
/* Thus, all we need to do is to compute Ker U, and then apply Q.
*
* U is upper triangular, with eigenvalues sorted so that any zeros appear at the end.
* Thus, the diagonal of U ends with exactly
* m_dimKer zero's. Let us use that to construct m_dimKer linearly
* independent vectors in Ker U.
*/
Matrix<Scalar, Dynamic, Dynamic, MatrixType::Options,
MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime>
y(-m_lu.corner(TopRight, m_rank, dimker));
m_lu.corner(TopLeft, m_rank, m_rank)
.template marked<UpperTriangular>()
.solveTriangularInPlace(y);
for(int i = 0; i < m_rank; ++i) result->row(m_q.coeff(i)) = y.row(i);
for(int i = m_rank; i < cols; ++i) result->row(m_q.coeff(i)).setZero();
for(int k = 0; k < dimker; ++k) result->coeffRef(m_q.coeff(m_rank+k), k) = Scalar(1);
}
template<typename MatrixType>
const typename LU<MatrixType>::KernelResultType
LU<MatrixType>::kernel() const
{
KernelResultType result(m_lu.cols(), dimensionOfKernel());
computeKernel(&result);
return result;
}
template<typename MatrixType>
template<typename ImageMatrixType>
void LU<MatrixType>::computeImage(ImageMatrixType *result) const
{
ei_assert(m_rank > 0);
result->resize(m_originalMatrix.rows(), m_rank);
for(int i = 0; i < m_rank; ++i)
result->col(i) = m_originalMatrix.col(m_q.coeff(i));
}
template<typename MatrixType>
const typename LU<MatrixType>::ImageResultType
LU<MatrixType>::image() const
{
ImageResultType result(m_originalMatrix.rows(), m_rank);
computeImage(&result);
return result;
}
template<typename MatrixType>
template<typename OtherDerived, typename ResultType>
bool LU<MatrixType>::solve(
const MatrixBase<OtherDerived>& b,
ResultType *result
) const
{
/* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}.
* So we proceed as follows:
* Step 1: compute c = Pb.
* Step 2: replace c by the solution x to Lx = c. Exists because L is invertible.
* Step 3: replace c by the solution x to Ux = c. Check if a solution really exists.
* Step 4: result = Qc;
*/
const int rows = m_lu.rows(), cols = m_lu.cols();
ei_assert(b.rows() == rows);
const int smalldim = std::min(rows, cols);
typename OtherDerived::PlainMatrixType c(b.rows(), b.cols());
// Step 1
for(int i = 0; i < rows; ++i) c.row(m_p.coeff(i)) = b.row(i);
// Step 2
m_lu.corner(Eigen::TopLeft,smalldim,smalldim).template marked<UnitLowerTriangular>()
.solveTriangularInPlace(
c.corner(Eigen::TopLeft, smalldim, c.cols()));
if(rows>cols)
{
c.corner(Eigen::BottomLeft, rows-cols, c.cols())
-= m_lu.corner(Eigen::BottomLeft, rows-cols, cols) * c.corner(Eigen::TopLeft, cols, c.cols());
}
// Step 3
if(!isSurjective())
{
// is c is in the image of U ?
RealScalar biggest_in_c = m_rank>0 ? c.corner(TopLeft, m_rank, c.cols()).cwise().abs().maxCoeff() : 0;
for(int col = 0; col < c.cols(); ++col)
for(int row = m_rank; row < c.rows(); ++row)
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
return false;
}
m_lu.corner(TopLeft, m_rank, m_rank)
.template marked<UpperTriangular>()
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
// Step 4
result->resize(m_lu.cols(), b.cols());
for(int i = 0; i < m_rank; ++i) result->row(m_q.coeff(i)) = c.row(i);
for(int i = m_rank; i < m_lu.cols(); ++i) result->row(m_q.coeff(i)).setZero();
return true;
}
/** \lu_module
*
* \return the LU decomposition of \c *this.
*
* \sa class LU
*/
template<typename Derived>
inline const LU<typename MatrixBase<Derived>::PlainMatrixType>
MatrixBase<Derived>::lu() const
{
return LU<PlainMatrixType>(eval());
}
#endif // EIGEN_LU_H

View File

@@ -0,0 +1,182 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project.
//
// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, 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 2 of
// the License, or (at your option) any later version.
//
// Eigen 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 Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#ifndef EIGEN_LEASTSQUARES_H
#define EIGEN_LEASTSQUARES_H
/** \ingroup LeastSquares_Module
*
* \leastsquares_module
*
* For a set of points, this function tries to express
* one of the coords as a linear (affine) function of the other coords.
*
* This is best explained by an example. This function works in full
* generality, for points in a space of arbitrary dimension, and also over
* the complex numbers, but for this example we will work in dimension 3
* over the real numbers (doubles).
*
* So let us work with the following set of 5 points given by their
* \f$(x,y,z)\f$ coordinates:
* @code
Vector3d points[5];
points[0] = Vector3d( 3.02, 6.89, -4.32 );
points[1] = Vector3d( 2.01, 5.39, -3.79 );
points[2] = Vector3d( 2.41, 6.01, -4.01 );
points[3] = Vector3d( 2.09, 5.55, -3.86 );
points[4] = Vector3d( 2.58, 6.32, -4.10 );
* @endcode
* Suppose that we want to express the second coordinate (\f$y\f$) as a linear
* expression in \f$x\f$ and \f$z\f$, that is,
* \f[ y=ax+bz+c \f]
* for some constants \f$a,b,c\f$. Thus, we want to find the best possible
* constants \f$a,b,c\f$ so that the plane of equation \f$y=ax+bz+c\f$ fits
* best the five above points. To do that, call this function as follows:
* @code
Vector3d coeffs; // will store the coefficients a, b, c
linearRegression(
5,
&points,
&coeffs,
1 // the coord to express as a function of
// the other ones. 0 means x, 1 means y, 2 means z.
);
* @endcode
* Now the vector \a coeffs is approximately
* \f$( 0.495 , -1.927 , -2.906 )\f$.
* Thus, we get \f$a=0.495, b = -1.927, c = -2.906\f$. Let us check for
* instance how near points[0] is from the plane of equation \f$y=ax+bz+c\f$.
* Looking at the coords of points[0], we see that:
* \f[ax+bz+c = 0.495 * 3.02 + (-1.927) * (-4.32) + (-2.906) = 6.91.\f]
* On the other hand, we have \f$y=6.89\f$. We see that the values
* \f$6.91\f$ and \f$6.89\f$
* are near, so points[0] is very near the plane of equation \f$y=ax+bz+c\f$.
*
* Let's now describe precisely the parameters:
* @param numPoints the number of points
* @param points the array of pointers to the points on which to perform the linear regression
* @param result pointer to the vector in which to store the result.
This vector must be of the same type and size as the
data points. The meaning of its coords is as follows.
For brevity, let \f$n=Size\f$,
\f$r_i=result[i]\f$,
and \f$f=funcOfOthers\f$. Denote by
\f$x_0,\ldots,x_{n-1}\f$
the n coordinates in the n-dimensional space.
Then the resulting equation is:
\f[ x_f = r_0 x_0 + \cdots + r_{f-1}x_{f-1}
+ r_{f+1}x_{f+1} + \cdots + r_{n-1}x_{n-1} + r_n. \f]
* @param funcOfOthers Determines which coord to express as a function of the
others. Coords are numbered starting from 0, so that a
value of 0 means \f$x\f$, 1 means \f$y\f$,
2 means \f$z\f$, ...
*
* \sa fitHyperplane()
*/
template<typename VectorType>
void linearRegression(int numPoints,
VectorType **points,
VectorType *result,
int funcOfOthers )
{
typedef typename VectorType::Scalar Scalar;
typedef Hyperplane<Scalar, VectorType::SizeAtCompileTime> HyperplaneType;
const int size = points[0]->size();
result->resize(size);
HyperplaneType h(size);
fitHyperplane(numPoints, points, &h);
for(int i = 0; i < funcOfOthers; i++)
result->coeffRef(i) = - h.coeffs()[i] / h.coeffs()[funcOfOthers];
for(int i = funcOfOthers; i < size; i++)
result->coeffRef(i) = - h.coeffs()[i+1] / h.coeffs()[funcOfOthers];
}
/** \ingroup LeastSquares_Module
*
* \leastsquares_module
*
* This function is quite similar to linearRegression(), so we refer to the
* documentation of this function and only list here the differences.
*
* The main difference from linearRegression() is that this function doesn't
* take a \a funcOfOthers argument. Instead, it finds a general equation
* of the form
* \f[ r_0 x_0 + \cdots + r_{n-1}x_{n-1} + r_n = 0, \f]
* where \f$n=Size\f$, \f$r_i=retCoefficients[i]\f$, and we denote by
* \f$x_0,\ldots,x_{n-1}\f$ the n coordinates in the n-dimensional space.
*
* Thus, the vector \a retCoefficients has size \f$n+1\f$, which is another
* difference from linearRegression().
*
* In practice, this function performs an hyper-plane fit in a total least square sense
* via the following steps:
* 1 - center the data to the mean
* 2 - compute the covariance matrix
* 3 - pick the eigenvector corresponding to the smallest eigenvalue of the covariance matrix
* The ratio of the smallest eigenvalue and the second one gives us a hint about the relevance
* of the solution. This value is optionally returned in \a soundness.
*
* \sa linearRegression()
*/
template<typename VectorType, typename HyperplaneType>
void fitHyperplane(int numPoints,
VectorType **points,
HyperplaneType *result,
typename NumTraits<typename VectorType::Scalar>::Real* soundness = 0)
{
typedef typename VectorType::Scalar Scalar;
typedef Matrix<Scalar,VectorType::SizeAtCompileTime,VectorType::SizeAtCompileTime> CovMatrixType;
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType)
ei_assert(numPoints >= 1);
int size = points[0]->size();
ei_assert(size+1 == result->coeffs().size());
// compute the mean of the data
VectorType mean = VectorType::Zero(size);
for(int i = 0; i < numPoints; ++i)
mean += *(points[i]);
mean /= numPoints;
// compute the covariance matrix
CovMatrixType covMat = CovMatrixType::Zero(size, size);
VectorType remean = VectorType::Zero(size);
for(int i = 0; i < numPoints; ++i)
{
VectorType diff = (*(points[i]) - mean).conjugate();
covMat += diff * diff.adjoint();
}
// now we just have to pick the eigen vector with smallest eigen value
SelfAdjointEigenSolver<CovMatrixType> eig(covMat);
result->normal() = eig.eigenvectors().col(0);
if (soundness)
*soundness = eig.eigenvalues().coeff(0)/eig.eigenvalues().coeff(1);
// let's compute the constant coefficient such that the
// plane pass trough the mean point:
result->offset() = - (result->normal().cwise()* mean).sum();
}
#endif // EIGEN_LEASTSQUARES_H

Some files were not shown because too many files have changed in this diff Show More